Commit b40f8d39 authored by Daniel Walker's avatar Daniel Walker Committed by Greg Kroah-Hartman

usb: u132-hcd driver style clean up

I was converting a semaphore in this file to a mutex when I noticed that
this file has some fairly rampant style problems. Practically every line
has spaces instead of tabs .. Once I cleared that up, checkpatch.pl showed
a number of other problem.. I think this file might be a good one to review
for new style checks that could be added..

Below are the only two remaining which I didn't remove. 

#5083: FILE: drivers/usb/host/u132-hcd.c:2907:
+               error:

WARNING: labels should not be indented
#5087: FILE: drivers/usb/host/u132-hcd.c:2911:
+               stall:

These labels are actually inside a switch statement, and they are right
under "default:". "default:" appears to be exempt and these other label
should be too, or default shouldn't be exempt.

I also deleted a few lines due to single statements inside { } , 

if (is_error()) {
	return;
}

becomes,

if (is_error())
	return;

with one line deleted.
Signed-off-by: default avatarDaniel Walker <dwalker@mvista.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 619a6f1d
......@@ -84,8 +84,8 @@ static DECLARE_WAIT_QUEUE_HEAD(u132_hcd_wait);
*
*/
static struct mutex u132_module_lock;
static int u132_exiting = 0;
static int u132_instances = 0;
static int u132_exiting;
static int u132_instances;
static struct list_head u132_static_list;
/*
* end of the global variables protected by u132_module_lock
......@@ -329,9 +329,8 @@ static void u132_ring_queue_work(struct u132 *u132, struct u132_ring *ring,
static void u132_ring_cancel_work(struct u132 *u132, struct u132_ring *ring)
{
if (cancel_delayed_work(&ring->scheduler)) {
if (cancel_delayed_work(&ring->scheduler))
kref_put(&u132->kref, u132_hcd_delete);
}
}
static void u132_endp_delete(struct kref *kref)
......@@ -356,7 +355,8 @@ static void u132_endp_delete(struct kref *kref)
struct u132_endp, endp_ring);
ring->curr_endp = next_endp;
list_del(head);
}} else
}
} else
list_del(head);
if (endp->input) {
udev->endp_number_in[usb_endp] = 0;
......@@ -534,7 +534,8 @@ static void u132_hcd_giveback_urb(struct u132 *u132, struct u132_endp *endp,
endp->active = 0;
spin_unlock_irqrestore(&endp->queue_lock.slock, irqs);
kfree(urbq);
} down(&u132->scheduler_lock);
}
down(&u132->scheduler_lock);
ring = endp->ring;
ring->in_use = 0;
u132_ring_cancel_work(u132, ring);
......@@ -653,9 +654,10 @@ static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf,
u8 *u = urb->transfer_buffer + urb->actual_length;
u8 *b = buf;
int L = len;
while (L-- > 0) {
while (L-- > 0)
*u++ = *b++;
}
urb->actual_length += len;
if ((condition_code == TD_CC_NOERROR) &&
(urb->transfer_buffer_length > urb->actual_length)) {
......@@ -668,8 +670,7 @@ static void u132_hcd_interrupt_recv(void *data, struct urb *urb, u8 *buf,
retval = edset_single(u132, ring, endp, urb,
address, endp->toggle_bits,
u132_hcd_interrupt_recv);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb,
retval);
} else {
......@@ -756,8 +757,7 @@ static void u132_hcd_bulk_output_sent(void *data, struct urb *urb, u8 *buf,
up(&u132->scheduler_lock);
retval = edset_output(u132, ring, endp, urb, address,
endp->toggle_bits, u132_hcd_bulk_output_sent);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb, retval);
return;
} else {
......@@ -805,9 +805,10 @@ static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf,
u8 *u = urb->transfer_buffer + urb->actual_length;
u8 *b = buf;
int L = len;
while (L-- > 0) {
while (L-- > 0)
*u++ = *b++;
}
urb->actual_length += len;
if ((condition_code == TD_CC_NOERROR) &&
(urb->transfer_buffer_length > urb->actual_length)) {
......@@ -820,8 +821,7 @@ static void u132_hcd_bulk_input_recv(void *data, struct urb *urb, u8 *buf,
ring->number, endp, urb, address,
endp->usb_endp, endp->toggle_bits,
u132_hcd_bulk_input_recv);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb, retval);
return;
} else if (condition_code == TD_CC_NOERROR) {
......@@ -944,9 +944,10 @@ static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf,
u8 *u = urb->transfer_buffer;
u8 *b = buf;
int L = len;
while (L-- > 0) {
while (L-- > 0)
*u++ = *b++;
}
urb->actual_length = len;
if ((condition_code == TD_CC_NOERROR) || ((condition_code ==
TD_DATAUNDERRUN) && ((urb->transfer_flags &
......@@ -957,8 +958,7 @@ static void u132_hcd_configure_input_recv(void *data, struct urb *urb, u8 *buf,
ring->number, endp, urb, address,
endp->usb_endp, 0x3,
u132_hcd_configure_empty_sent);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb, retval);
return;
} else if (condition_code == TD_CC_STALL) {
......@@ -1057,8 +1057,7 @@ static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf,
ring->number, endp, urb, address,
endp->usb_endp, 0,
u132_hcd_configure_input_recv);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb, retval);
return;
} else {
......@@ -1069,8 +1068,7 @@ static void u132_hcd_configure_setup_sent(void *data, struct urb *urb, u8 *buf,
ring->number, endp, urb, address,
endp->usb_endp, 0,
u132_hcd_configure_empty_recv);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb, retval);
return;
}
......@@ -1155,8 +1153,7 @@ static void u132_hcd_enumeration_address_sent(void *data, struct urb *urb,
retval = usb_ftdi_elan_edset_input(u132->platform_dev,
ring->number, endp, urb, 0, endp->usb_endp, 0,
u132_hcd_enumeration_empty_recv);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb, retval);
return;
} else {
......@@ -1236,16 +1233,16 @@ static void u132_hcd_initial_input_recv(void *data, struct urb *urb, u8 *buf,
u8 *u = urb->transfer_buffer;
u8 *b = buf;
int L = len;
while (L-- > 0) {
while (L-- > 0)
*u++ = *b++;
}
urb->actual_length = len;
up(&u132->scheduler_lock);
retval = usb_ftdi_elan_edset_empty(u132->platform_dev,
ring->number, endp, urb, address, endp->usb_endp, 0x3,
u132_hcd_initial_empty_sent);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb, retval);
return;
} else {
......@@ -1289,8 +1286,7 @@ static void u132_hcd_initial_setup_sent(void *data, struct urb *urb, u8 *buf,
retval = usb_ftdi_elan_edset_input(u132->platform_dev,
ring->number, endp, urb, address, endp->usb_endp, 0,
u132_hcd_initial_input_recv);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb, retval);
return;
} else {
......@@ -1412,8 +1408,7 @@ static void u132_hcd_endp_work_scheduler(struct work_struct *work)
up(&u132->scheduler_lock);
retval = edset_single(u132, ring, endp, urb, address,
endp->toggle_bits, u132_hcd_interrupt_recv);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb, retval);
return;
}
......@@ -1433,8 +1428,7 @@ static void u132_hcd_endp_work_scheduler(struct work_struct *work)
up(&u132->scheduler_lock);
retval = edset_setup(u132, ring, endp, urb, address,
0x2, u132_hcd_initial_setup_sent);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb, retval);
return;
} else if (endp->usb_addr == 0) {
......@@ -1447,8 +1441,7 @@ static void u132_hcd_endp_work_scheduler(struct work_struct *work)
up(&u132->scheduler_lock);
retval = edset_setup(u132, ring, endp, urb, 0, 0x2,
u132_hcd_enumeration_address_sent);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb, retval);
return;
} else {
......@@ -1462,8 +1455,7 @@ static void u132_hcd_endp_work_scheduler(struct work_struct *work)
up(&u132->scheduler_lock);
retval = edset_setup(u132, ring, endp, urb, address,
0x2, u132_hcd_configure_setup_sent);
if (retval == 0) {
} else
if (retval != 0)
u132_hcd_giveback_urb(u132, endp, urb, retval);
return;
}
......@@ -1555,7 +1547,7 @@ static int u132_periodic_reinit(struct u132 *u132)
if (retval)
return retval;
retval = u132_write_pcimem(u132, periodicstart,
((9 *fi) / 10) & 0x3fff);
((9 * fi) / 10) & 0x3fff);
if (retval)
return retval;
return 0;
......@@ -1598,9 +1590,9 @@ static int u132_init(struct u132 *u132)
if (retval)
return retval;
}
if (u132->num_ports > MAX_U132_PORTS) {
if (u132->num_ports > MAX_U132_PORTS)
return -EINVAL;
}
return 0;
}
......@@ -1629,8 +1621,6 @@ static int u132_run(struct u132 *u132)
if (retval)
return retval;
u132->hc_fminterval = temp & 0x3fff;
if (u132->hc_fminterval != FI) {
}
u132->hc_fminterval |= FSMP(u132->hc_fminterval) << 16;
}
retval = u132_read_pcimem(u132, control, &u132->hc_control);
......@@ -1677,13 +1667,14 @@ static int u132_run(struct u132 *u132)
retval = u132_read_pcimem(u132, control, &control);
if (retval)
return retval;
retry:retval = u132_read_pcimem(u132, cmdstatus, &status);
retry:
retval = u132_read_pcimem(u132, cmdstatus, &status);
if (retval)
return retval;
retval = u132_write_pcimem(u132, cmdstatus, OHCI_HCR);
if (retval)
return retval;
extra:{
extra: {
retval = u132_read_pcimem(u132, cmdstatus, &status);
if (retval)
return retval;
......@@ -1882,9 +1873,8 @@ static int create_endpoint_and_queue_int(struct u132 *u132,
u8 endp_number;
struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags);
if (!endp) {
if (!endp)
return -ENOMEM;
}
spin_lock_init(&endp->queue_lock.slock);
spin_lock_irqsave(&endp->queue_lock.slock, irqs);
......@@ -1982,9 +1972,8 @@ static int create_endpoint_and_queue_bulk(struct u132 *u132,
u8 endp_number;
struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags);
if (!endp) {
if (!endp)
return -ENOMEM;
}
spin_lock_init(&endp->queue_lock.slock);
spin_lock_irqsave(&endp->queue_lock.slock, irqs);
......@@ -2079,9 +2068,8 @@ static int create_endpoint_and_queue_control(struct u132 *u132,
u8 endp_number;
struct u132_endp *endp = kmalloc(sizeof(struct u132_endp), mem_flags);
if (!endp) {
if (!endp)
return -ENOMEM;
}
spin_lock_init(&endp->queue_lock.slock);
spin_lock_irqsave(&endp->queue_lock.slock, irqs);
......@@ -2238,8 +2226,7 @@ static int queue_control_on_old_endpoint(struct u132 *u132,
u8 address = u132->addr[usb_addr].address;
struct u132_udev *udev = &u132->udev[address];
urb->hcpriv = u132;
if (udev->enumeration == 2) {
} else
if (udev->enumeration != 2)
udev->enumeration = 2;
if (endp->queue_size++ < ENDP_QUEUE_SIZE) {
endp->urb_list[ENDP_QUEUE_MASK & endp->queue_last++] =
......@@ -2364,7 +2351,7 @@ static int u132_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
u16 urb_size = 8;
u8 *b = urb->setup_packet;
int i = 0;
char data[30 *3 + 4];
char data[30 * 3 + 4];
char *d = data;
int m = (sizeof(data) - 1) / 3;
int l = 0;
......@@ -2606,15 +2593,15 @@ static int u132_roothub_descriptor(struct u132 *u132,
desc->bHubContrCurrent = 0;
desc->bNbrPorts = u132->num_ports;
temp = 1 + (u132->num_ports / 8);
desc->bDescLength = 7 + 2 *temp;
desc->bDescLength = 7 + 2 * temp;
temp = 0;
if (rh_a & RH_A_NPS)
temp |= 0x0002;
if (rh_a & RH_A_PSM)
temp |= 0x0001;
if (rh_a & RH_A_NOCP) {
if (rh_a & RH_A_NOCP)
temp |= 0x0010;
} else if (rh_a & RH_A_OCPM)
else if (rh_a & RH_A_OCPM)
temp |= 0x0008;
desc->wHubCharacteristics = cpu_to_le16(temp);
retval = u132_read_pcimem(u132, roothub.b, &rh_b);
......@@ -2680,9 +2667,9 @@ static int u132_roothub_portreset(struct u132 *u132, int port_index)
roothub.portstatus[port_index], &portstat);
if (retval)
return retval;
if (RH_PS_PRS & portstat) {
if (RH_PS_PRS & portstat)
continue;
} else
else
break;
} while (tick_before(now, reset_done));
if (RH_PS_PRS & portstat)
......@@ -2820,9 +2807,9 @@ static int u132_hub_status_data(struct usb_hcd *hcd, char *buf)
goto done;
}
}
if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC)) {
if (u132->hc_roothub_status & (RH_HS_LPSC | RH_HS_OCIC))
buf[0] = changed = 1;
} else
else
buf[0] = 0;
if (u132->num_ports > 7) {
buf[1] = 0;
......@@ -2833,20 +2820,20 @@ static int u132_hub_status_data(struct usb_hcd *hcd, char *buf)
RH_PS_PESC | RH_PS_PSSC | RH_PS_OCIC |
RH_PS_PRSC)) {
changed = 1;
if (i < 7) {
if (i < 7)
buf[0] |= 1 << (i + 1);
} else
else
buf[1] |= 1 << (i - 7);
continue;
}
if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS)) {
if (!(u132->hc_roothub_portstatus[i] & RH_PS_CCS))
continue;
}
if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS)) {
if ((u132->hc_roothub_portstatus[i] & RH_PS_PSS))
continue;
}
}
done:return changed ? length : 0;
done:
return changed ? length : 0;
}
}
......@@ -2920,10 +2907,12 @@ static int u132_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
}
default:
goto stall;
error:u132_disable(u132);
error:
u132_disable(u132);
u132->going = 1;
break;
stall:retval = -EPIPE;
stall:
retval = -EPIPE;
break;
}
mutex_unlock(&u132->sw_lock);
......@@ -3105,7 +3094,8 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev)
ring->curr_endp = NULL;
INIT_DELAYED_WORK(&ring->scheduler,
u132_hcd_ring_work_scheduler);
} mutex_lock(&u132->sw_lock);
}
mutex_lock(&u132->sw_lock);
INIT_DELAYED_WORK(&u132->monitor, u132_hcd_monitor_work);
while (ports-- > 0) {
struct u132_port *port = &u132->port[ports];
......@@ -3114,10 +3104,12 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev)
port->enable = 0;
port->power = 0;
port->Status = 0;
} while (addrs-- > 0) {
}
while (addrs-- > 0) {
struct u132_addr *addr = &u132->addr[addrs];
addr->address = 0;
} while (udevs-- > 0) {
}
while (udevs-- > 0) {
struct u132_udev *udev = &u132->udev[udevs];
int i = ARRAY_SIZE(udev->endp_number_in);
int o = ARRAY_SIZE(udev->endp_number_out);
......@@ -3125,16 +3117,16 @@ static void u132_initialise(struct u132 *u132, struct platform_device *pdev)
udev->udev_number = 0;
udev->usb_addr = 0;
udev->portnumber = 0;
while (i-- > 0) {
while (i-- > 0)
udev->endp_number_in[i] = 0;
}
while (o-- > 0) {
while (o-- > 0)
udev->endp_number_out[o] = 0;
}
}
while (endps-- > 0) {
while (endps-- > 0)
u132->endp[endps] = NULL;
}
mutex_unlock(&u132->sw_lock);
return;
}
......@@ -3146,10 +3138,11 @@ static int __devinit u132_probe(struct platform_device *pdev)
u32 control;
u32 rh_a = -1;
u32 num_ports;
msleep(100);
if (u132_exiting > 0) {
if (u132_exiting > 0)
return -ENODEV;
}
retval = ftdi_write_pcimem(pdev, intrdisable, OHCI_INTR_MIE);
if (retval)
return retval;
......@@ -3160,9 +3153,9 @@ static int __devinit u132_probe(struct platform_device *pdev)
if (retval)
return retval;
num_ports = rh_a & RH_A_NDP; /* refuse to confuse usbcore */
if (pdev->dev.dma_mask) {
if (pdev->dev.dma_mask)
return -EINVAL;
}
hcd = usb_create_hcd(&u132_hc_driver, &pdev->dev, pdev->dev.bus_id);
if (!hcd) {
printk(KERN_ERR "failed to create the usb hcd struct for U132\n"
......@@ -3301,7 +3294,8 @@ static void __exit u132_hcd_exit(void)
mutex_unlock(&u132_module_lock);
list_for_each_entry_safe(u132, temp, &u132_static_list, u132_list) {
platform_device_unregister(u132->platform_dev);
} platform_driver_unregister(&u132_platform_driver);
}
platform_driver_unregister(&u132_platform_driver);
printk(KERN_INFO "u132-hcd driver deregistered\n");
wait_event(u132_hcd_wait, u132_instances == 0);
flush_workqueue(workqueue);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment