aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authormatt mooney <mfm@muteddisk.com>2011-05-20 00:36:56 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-06-07 16:51:22 -0400
commit87352760173082c2a774f83dc6fe826fdbf219c0 (patch)
treebd44db21d3191a72b481250db875140caee6e61f /drivers
parent00d760b057e0fb1e5fb515071af2cc87d15439f8 (diff)
staging: usbip: remove unnecessary lines and extra return statements
Also, fix a few alignment issues that were originally missed. Signed-off-by: matt mooney <mfm@muteddisk.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/usbip/stub.h1
-rw-r--r--drivers/staging/usbip/stub_dev.c21
-rw-r--r--drivers/staging/usbip/stub_main.c13
-rw-r--r--drivers/staging/usbip/stub_tx.c13
-rw-r--r--drivers/staging/usbip/usbip_common.c13
-rw-r--r--drivers/staging/usbip/usbip_common.h2
-rw-r--r--drivers/staging/usbip/vhci_hcd.c9
-rw-r--r--drivers/staging/usbip/vhci_rx.c2
8 files changed, 24 insertions, 50 deletions
diff --git a/drivers/staging/usbip/stub.h b/drivers/staging/usbip/stub.h
index 6592aa2ad15..2cc596e8162 100644
--- a/drivers/staging/usbip/stub.h
+++ b/drivers/staging/usbip/stub.h
@@ -77,6 +77,7 @@ struct stub_unlink {
77}; 77};
78 78
79#define BUSID_SIZE 20 79#define BUSID_SIZE 20
80
80struct bus_id_priv { 81struct bus_id_priv {
81 char name[BUSID_SIZE]; 82 char name[BUSID_SIZE];
82 char status; 83 char status;
diff --git a/drivers/staging/usbip/stub_dev.c b/drivers/staging/usbip/stub_dev.c
index 6e99ec87fee..e35d62c79af 100644
--- a/drivers/staging/usbip/stub_dev.c
+++ b/drivers/staging/usbip/stub_dev.c
@@ -207,10 +207,11 @@ static void stub_shutdown_connection(struct usbip_device *ud)
207 if (ud->tcp_tx && !task_is_dead(ud->tcp_tx)) 207 if (ud->tcp_tx && !task_is_dead(ud->tcp_tx))
208 kthread_stop(ud->tcp_tx); 208 kthread_stop(ud->tcp_tx);
209 209
210 /* 2. close the socket */
211 /* 210 /*
212 * tcp_socket is freed after threads are killed. 211 * 2. close the socket
213 * So usbip_xmit do not touch NULL socket. 212 *
213 * tcp_socket is freed after threads are killed so that usbip_xmit does
214 * not touch NULL socket.
214 */ 215 */
215 if (ud->tcp_socket) { 216 if (ud->tcp_socket) {
216 sock_release(ud->tcp_socket); 217 sock_release(ud->tcp_socket);
@@ -230,8 +231,8 @@ static void stub_shutdown_connection(struct usbip_device *ud)
230 list_del(&unlink->list); 231 list_del(&unlink->list);
231 kfree(unlink); 232 kfree(unlink);
232 } 233 }
233 list_for_each_entry_safe(unlink, tmp, 234 list_for_each_entry_safe(unlink, tmp, &sdev->unlink_free,
234 &sdev->unlink_free, list) { 235 list) {
235 list_del(&unlink->list); 236 list_del(&unlink->list);
236 kfree(unlink); 237 kfree(unlink);
237 } 238 }
@@ -258,22 +259,17 @@ static void stub_device_reset(struct usbip_device *ud)
258 259
259 /* try to reset the device */ 260 /* try to reset the device */
260 ret = usb_reset_device(udev); 261 ret = usb_reset_device(udev);
261
262 usb_unlock_device(udev); 262 usb_unlock_device(udev);
263 263
264 spin_lock(&ud->lock); 264 spin_lock(&ud->lock);
265 if (ret) { 265 if (ret) {
266 dev_err(&udev->dev, "device reset\n"); 266 dev_err(&udev->dev, "device reset\n");
267 ud->status = SDEV_ST_ERROR; 267 ud->status = SDEV_ST_ERROR;
268
269 } else { 268 } else {
270 dev_info(&udev->dev, "device reset\n"); 269 dev_info(&udev->dev, "device reset\n");
271 ud->status = SDEV_ST_AVAILABLE; 270 ud->status = SDEV_ST_AVAILABLE;
272
273 } 271 }
274 spin_unlock(&ud->lock); 272 spin_unlock(&ud->lock);
275
276 return;
277} 273}
278 274
279static void stub_device_unusable(struct usbip_device *ud) 275static void stub_device_unusable(struct usbip_device *ud)
@@ -375,7 +371,7 @@ static int stub_probe(struct usb_interface *interface,
375 371
376 /* check we should claim or not by busid_table */ 372 /* check we should claim or not by busid_table */
377 busid_priv = get_busid_priv(udev_busid); 373 busid_priv = get_busid_priv(udev_busid);
378 if (!busid_priv || (busid_priv->status == STUB_BUSID_REMOV) || 374 if (!busid_priv || (busid_priv->status == STUB_BUSID_REMOV) ||
379 (busid_priv->status == STUB_BUSID_OTHER)) { 375 (busid_priv->status == STUB_BUSID_OTHER)) {
380 dev_info(&interface->dev, "%s is not in match_busid table... " 376 dev_info(&interface->dev, "%s is not in match_busid table... "
381 "skip!\n", udev_busid); 377 "skip!\n", udev_busid);
@@ -420,7 +416,6 @@ static int stub_probe(struct usb_interface *interface,
420 udev_busid); 416 udev_busid);
421 usb_set_intfdata(interface, NULL); 417 usb_set_intfdata(interface, NULL);
422 busid_priv->interf_count--; 418 busid_priv->interf_count--;
423
424 return err; 419 return err;
425 } 420 }
426 421
@@ -443,7 +438,6 @@ static int stub_probe(struct usb_interface *interface,
443 /* set private data to usb_interface */ 438 /* set private data to usb_interface */
444 usb_set_intfdata(interface, sdev); 439 usb_set_intfdata(interface, sdev);
445 busid_priv->interf_count++; 440 busid_priv->interf_count++;
446
447 busid_priv->sdev = sdev; 441 busid_priv->sdev = sdev;
448 442
449 err = stub_add_files(&interface->dev); 443 err = stub_add_files(&interface->dev);
@@ -453,7 +447,6 @@ static int stub_probe(struct usb_interface *interface,
453 usb_put_intf(interface); 447 usb_put_intf(interface);
454 448
455 busid_priv->interf_count = 0; 449 busid_priv->interf_count = 0;
456
457 busid_priv->sdev = NULL; 450 busid_priv->sdev = NULL;
458 stub_device_free(sdev); 451 stub_device_free(sdev);
459 return err; 452 return err;
diff --git a/drivers/staging/usbip/stub_main.c b/drivers/staging/usbip/stub_main.c
index e9085d66394..44671ee1b99 100644
--- a/drivers/staging/usbip/stub_main.c
+++ b/drivers/staging/usbip/stub_main.c
@@ -25,9 +25,7 @@
25#define DRIVER_AUTHOR "Takahiro Hirofuchi" 25#define DRIVER_AUTHOR "Takahiro Hirofuchi"
26#define DRIVER_DESC "USB/IP Host Driver" 26#define DRIVER_DESC "USB/IP Host Driver"
27 27
28/* stub_priv is allocated from stub_priv_cache */
29struct kmem_cache *stub_priv_cache; 28struct kmem_cache *stub_priv_cache;
30
31/* 29/*
32 * busid_tables defines matching busids that usbip can grab. A user can change 30 * busid_tables defines matching busids that usbip can grab. A user can change
33 * dynamically what device is locally used and what device is exported to a 31 * dynamically what device is locally used and what device is exported to a
@@ -42,7 +40,6 @@ int match_busid(const char *busid)
42 int i; 40 int i;
43 41
44 spin_lock(&busid_table_lock); 42 spin_lock(&busid_table_lock);
45
46 for (i = 0; i < MAX_BUSID; i++) 43 for (i = 0; i < MAX_BUSID; i++)
47 if (busid_table[i].name[0]) 44 if (busid_table[i].name[0])
48 if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { 45 if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) {
@@ -50,7 +47,6 @@ int match_busid(const char *busid)
50 spin_unlock(&busid_table_lock); 47 spin_unlock(&busid_table_lock);
51 return 0; 48 return 0;
52 } 49 }
53
54 spin_unlock(&busid_table_lock); 50 spin_unlock(&busid_table_lock);
55 51
56 return 1; 52 return 1;
@@ -61,7 +57,6 @@ struct bus_id_priv *get_busid_priv(const char *busid)
61 int i; 57 int i;
62 58
63 spin_lock(&busid_table_lock); 59 spin_lock(&busid_table_lock);
64
65 for (i = 0; i < MAX_BUSID; i++) 60 for (i = 0; i < MAX_BUSID; i++)
66 if (busid_table[i].name[0]) 61 if (busid_table[i].name[0])
67 if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { 62 if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) {
@@ -69,7 +64,6 @@ struct bus_id_priv *get_busid_priv(const char *busid)
69 spin_unlock(&busid_table_lock); 64 spin_unlock(&busid_table_lock);
70 return &(busid_table[i]); 65 return &(busid_table[i]);
71 } 66 }
72
73 spin_unlock(&busid_table_lock); 67 spin_unlock(&busid_table_lock);
74 68
75 return NULL; 69 return NULL;
@@ -81,15 +75,12 @@ static ssize_t show_match_busid(struct device_driver *drv, char *buf)
81 char *out = buf; 75 char *out = buf;
82 76
83 spin_lock(&busid_table_lock); 77 spin_lock(&busid_table_lock);
84
85 for (i = 0; i < MAX_BUSID; i++) 78 for (i = 0; i < MAX_BUSID; i++)
86 if (busid_table[i].name[0]) 79 if (busid_table[i].name[0])
87 out += sprintf(out, "%s ", busid_table[i].name); 80 out += sprintf(out, "%s ", busid_table[i].name);
88
89 spin_unlock(&busid_table_lock); 81 spin_unlock(&busid_table_lock);
90 82
91 out += sprintf(out, "\n"); 83 out += sprintf(out, "\n");
92
93 return out - buf; 84 return out - buf;
94} 85}
95 86
@@ -101,7 +92,6 @@ static int add_match_busid(char *busid)
101 return 0; 92 return 0;
102 93
103 spin_lock(&busid_table_lock); 94 spin_lock(&busid_table_lock);
104
105 for (i = 0; i < MAX_BUSID; i++) 95 for (i = 0; i < MAX_BUSID; i++)
106 if (!busid_table[i].name[0]) { 96 if (!busid_table[i].name[0]) {
107 strncpy(busid_table[i].name, busid, BUSID_SIZE); 97 strncpy(busid_table[i].name, busid, BUSID_SIZE);
@@ -111,7 +101,6 @@ static int add_match_busid(char *busid)
111 spin_unlock(&busid_table_lock); 101 spin_unlock(&busid_table_lock);
112 return 0; 102 return 0;
113 } 103 }
114
115 spin_unlock(&busid_table_lock); 104 spin_unlock(&busid_table_lock);
116 105
117 return -1; 106 return -1;
@@ -122,7 +111,6 @@ int del_match_busid(char *busid)
122 int i; 111 int i;
123 112
124 spin_lock(&busid_table_lock); 113 spin_lock(&busid_table_lock);
125
126 for (i = 0; i < MAX_BUSID; i++) 114 for (i = 0; i < MAX_BUSID; i++)
127 if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { 115 if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) {
128 /* found */ 116 /* found */
@@ -135,7 +123,6 @@ int del_match_busid(char *busid)
135 spin_unlock(&busid_table_lock); 123 spin_unlock(&busid_table_lock);
136 return 0; 124 return 0;
137 } 125 }
138
139 spin_unlock(&busid_table_lock); 126 spin_unlock(&busid_table_lock);
140 127
141 return -1; 128 return -1;
diff --git a/drivers/staging/usbip/stub_tx.c b/drivers/staging/usbip/stub_tx.c
index fda2bc95e85..1cbae44ba0d 100644
--- a/drivers/staging/usbip/stub_tx.c
+++ b/drivers/staging/usbip/stub_tx.c
@@ -97,13 +97,12 @@ void stub_complete(struct urb *urb)
97 97
98 /* link a urb to the queue of tx. */ 98 /* link a urb to the queue of tx. */
99 spin_lock_irqsave(&sdev->priv_lock, flags); 99 spin_lock_irqsave(&sdev->priv_lock, flags);
100
101 if (priv->unlinking) { 100 if (priv->unlinking) {
102 stub_enqueue_ret_unlink(sdev, priv->seqnum, urb->status); 101 stub_enqueue_ret_unlink(sdev, priv->seqnum, urb->status);
103 stub_free_priv_and_urb(priv); 102 stub_free_priv_and_urb(priv);
104 } else 103 } else {
105 list_move_tail(&priv->list, &sdev->priv_tx); 104 list_move_tail(&priv->list, &sdev->priv_tx);
106 105 }
107 spin_unlock_irqrestore(&sdev->priv_lock, flags); 106 spin_unlock_irqrestore(&sdev->priv_lock, flags);
108 107
109 /* wake up tx_thread */ 108 /* wake up tx_thread */
@@ -113,10 +112,10 @@ void stub_complete(struct urb *urb)
113static inline void setup_base_pdu(struct usbip_header_basic *base, 112static inline void setup_base_pdu(struct usbip_header_basic *base,
114 __u32 command, __u32 seqnum) 113 __u32 command, __u32 seqnum)
115{ 114{
116 base->command = command; 115 base->command = command;
117 base->seqnum = seqnum; 116 base->seqnum = seqnum;
118 base->devid = 0; 117 base->devid = 0;
119 base->ep = 0; 118 base->ep = 0;
120 base->direction = 0; 119 base->direction = 0;
121} 120}
122 121
diff --git a/drivers/staging/usbip/usbip_common.c b/drivers/staging/usbip/usbip_common.c
index 433a3b6207d..954d90d659d 100644
--- a/drivers/staging/usbip/usbip_common.c
+++ b/drivers/staging/usbip/usbip_common.c
@@ -63,9 +63,9 @@ static void usbip_dump_buffer(char *buff, int bufflen)
63static void usbip_dump_pipe(unsigned int p) 63static void usbip_dump_pipe(unsigned int p)
64{ 64{
65 unsigned char type = usb_pipetype(p); 65 unsigned char type = usb_pipetype(p);
66 unsigned char ep = usb_pipeendpoint(p); 66 unsigned char ep = usb_pipeendpoint(p);
67 unsigned char dev = usb_pipedevice(p); 67 unsigned char dev = usb_pipedevice(p);
68 unsigned char dir = usb_pipein(p); 68 unsigned char dir = usb_pipein(p);
69 69
70 pr_debug("dev(%d) ep(%d) [%s] ", dev, ep, dir ? "IN" : "OUT"); 70 pr_debug("dev(%d) ep(%d) [%s] ", dev, ep, dir ? "IN" : "OUT");
71 71
@@ -334,8 +334,8 @@ void usbip_dump_header(struct usbip_header *pdu)
334EXPORT_SYMBOL_GPL(usbip_dump_header); 334EXPORT_SYMBOL_GPL(usbip_dump_header);
335 335
336/* Send/receive messages over TCP/IP. I refer drivers/block/nbd.c */ 336/* Send/receive messages over TCP/IP. I refer drivers/block/nbd.c */
337int usbip_xmit(int send, struct socket *sock, char *buf, 337int usbip_xmit(int send, struct socket *sock, char *buf, int size,
338 int size, int msg_flags) 338 int msg_flags)
339{ 339{
340 int result; 340 int result;
341 struct msghdr msg; 341 struct msghdr msg;
@@ -628,8 +628,7 @@ void usbip_header_correct_endian(struct usbip_header *pdu, int send)
628EXPORT_SYMBOL_GPL(usbip_header_correct_endian); 628EXPORT_SYMBOL_GPL(usbip_header_correct_endian);
629 629
630static void usbip_iso_pakcet_correct_endian( 630static void usbip_iso_pakcet_correct_endian(
631 struct usbip_iso_packet_descriptor *iso, 631 struct usbip_iso_packet_descriptor *iso, int send)
632 int send)
633{ 632{
634 /* does not need all members. but copy all simply. */ 633 /* does not need all members. but copy all simply. */
635 if (send) { 634 if (send) {
diff --git a/drivers/staging/usbip/usbip_common.h b/drivers/staging/usbip/usbip_common.h
index 4a641c552b7..83f8c1ed5a4 100644
--- a/drivers/staging/usbip/usbip_common.h
+++ b/drivers/staging/usbip/usbip_common.h
@@ -65,7 +65,7 @@ enum {
65#define usbip_dbg_flag_vhci_tx (usbip_debug_flag & usbip_debug_vhci_tx) 65#define usbip_dbg_flag_vhci_tx (usbip_debug_flag & usbip_debug_vhci_tx)
66#define usbip_dbg_flag_stub_rx (usbip_debug_flag & usbip_debug_stub_rx) 66#define usbip_dbg_flag_stub_rx (usbip_debug_flag & usbip_debug_stub_rx)
67#define usbip_dbg_flag_stub_tx (usbip_debug_flag & usbip_debug_stub_tx) 67#define usbip_dbg_flag_stub_tx (usbip_debug_flag & usbip_debug_stub_tx)
68#define usbip_dbg_flag_vhci_sysfs (usbip_debug_flag & usbip_debug_vhci_sysfs) 68#define usbip_dbg_flag_vhci_sysfs (usbip_debug_flag & usbip_debug_vhci_sysfs)
69 69
70extern unsigned long usbip_debug_flag; 70extern unsigned long usbip_debug_flag;
71extern struct device_attribute dev_attr_usbip_debug; 71extern struct device_attribute dev_attr_usbip_debug;
diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
index a76e8fa69b6..5b94b8037c5 100644
--- a/drivers/staging/usbip/vhci_hcd.c
+++ b/drivers/staging/usbip/vhci_hcd.c
@@ -344,9 +344,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
344 * */ 344 * */
345 if (dum->resuming && time_after(jiffies, dum->re_timeout)) { 345 if (dum->resuming && time_after(jiffies, dum->re_timeout)) {
346 dum->port_status[rhport] |= 346 dum->port_status[rhport] |=
347 (1 << USB_PORT_FEAT_C_SUSPEND); 347 (1 << USB_PORT_FEAT_C_SUSPEND);
348 dum->port_status[rhport] &= 348 dum->port_status[rhport] &=
349 ~(1 << USB_PORT_FEAT_SUSPEND); 349 ~(1 << USB_PORT_FEAT_SUSPEND);
350 dum->resuming = 0; 350 dum->resuming = 0;
351 dum->re_timeout = 0; 351 dum->re_timeout = 0;
352 /* if (dum->driver && dum->driver->resume) { 352 /* if (dum->driver && dum->driver->resume) {
@@ -639,9 +639,7 @@ no_need_xmit:
639 usb_hcd_unlink_urb_from_ep(hcd, urb); 639 usb_hcd_unlink_urb_from_ep(hcd, urb);
640no_need_unlink: 640no_need_unlink:
641 spin_unlock_irqrestore(&the_controller->lock, flags); 641 spin_unlock_irqrestore(&the_controller->lock, flags);
642
643 usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status); 642 usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);
644
645 return ret; 643 return ret;
646} 644}
647 645
@@ -1033,9 +1031,8 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
1033 hcd->state = HC_STATE_RUNNING; 1031 hcd->state = HC_STATE_RUNNING;
1034 } 1032 }
1035 spin_unlock_irq(&vhci->lock); 1033 spin_unlock_irq(&vhci->lock);
1036 return rc;
1037 1034
1038 return 0; 1035 return rc;
1039} 1036}
1040 1037
1041#else 1038#else
diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
index e42ce9dab7a..09c44abb89e 100644
--- a/drivers/staging/usbip/vhci_rx.c
+++ b/drivers/staging/usbip/vhci_rx.c
@@ -179,8 +179,6 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
179 } 179 }
180 180
181 kfree(unlink); 181 kfree(unlink);
182
183 return;
184} 182}
185 183
186static int vhci_priv_tx_empty(struct vhci_device *vdev) 184static int vhci_priv_tx_empty(struct vhci_device *vdev)