Commit 87352760 authored by matt mooney's avatar matt mooney Committed by Greg Kroah-Hartman

staging: usbip: remove unnecessary lines and extra return statements

Also, fix a few alignment issues that were originally missed.
Signed-off-by: default avatarmatt mooney <mfm@muteddisk.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 00d760b0
...@@ -77,6 +77,7 @@ struct stub_unlink { ...@@ -77,6 +77,7 @@ struct stub_unlink {
}; };
#define BUSID_SIZE 20 #define BUSID_SIZE 20
struct bus_id_priv { struct bus_id_priv {
char name[BUSID_SIZE]; char name[BUSID_SIZE];
char status; char status;
......
...@@ -207,10 +207,11 @@ static void stub_shutdown_connection(struct usbip_device *ud) ...@@ -207,10 +207,11 @@ static void stub_shutdown_connection(struct usbip_device *ud)
if (ud->tcp_tx && !task_is_dead(ud->tcp_tx)) if (ud->tcp_tx && !task_is_dead(ud->tcp_tx))
kthread_stop(ud->tcp_tx); kthread_stop(ud->tcp_tx);
/* 2. close the socket */
/* /*
* tcp_socket is freed after threads are killed. * 2. close the socket
* So usbip_xmit do not touch NULL socket. *
* tcp_socket is freed after threads are killed so that usbip_xmit does
* not touch NULL socket.
*/ */
if (ud->tcp_socket) { if (ud->tcp_socket) {
sock_release(ud->tcp_socket); sock_release(ud->tcp_socket);
...@@ -230,8 +231,8 @@ static void stub_shutdown_connection(struct usbip_device *ud) ...@@ -230,8 +231,8 @@ static void stub_shutdown_connection(struct usbip_device *ud)
list_del(&unlink->list); list_del(&unlink->list);
kfree(unlink); kfree(unlink);
} }
list_for_each_entry_safe(unlink, tmp, list_for_each_entry_safe(unlink, tmp, &sdev->unlink_free,
&sdev->unlink_free, list) { list) {
list_del(&unlink->list); list_del(&unlink->list);
kfree(unlink); kfree(unlink);
} }
...@@ -258,22 +259,17 @@ static void stub_device_reset(struct usbip_device *ud) ...@@ -258,22 +259,17 @@ static void stub_device_reset(struct usbip_device *ud)
/* try to reset the device */ /* try to reset the device */
ret = usb_reset_device(udev); ret = usb_reset_device(udev);
usb_unlock_device(udev); usb_unlock_device(udev);
spin_lock(&ud->lock); spin_lock(&ud->lock);
if (ret) { if (ret) {
dev_err(&udev->dev, "device reset\n"); dev_err(&udev->dev, "device reset\n");
ud->status = SDEV_ST_ERROR; ud->status = SDEV_ST_ERROR;
} else { } else {
dev_info(&udev->dev, "device reset\n"); dev_info(&udev->dev, "device reset\n");
ud->status = SDEV_ST_AVAILABLE; ud->status = SDEV_ST_AVAILABLE;
} }
spin_unlock(&ud->lock); spin_unlock(&ud->lock);
return;
} }
static void stub_device_unusable(struct usbip_device *ud) static void stub_device_unusable(struct usbip_device *ud)
...@@ -420,7 +416,6 @@ static int stub_probe(struct usb_interface *interface, ...@@ -420,7 +416,6 @@ static int stub_probe(struct usb_interface *interface,
udev_busid); udev_busid);
usb_set_intfdata(interface, NULL); usb_set_intfdata(interface, NULL);
busid_priv->interf_count--; busid_priv->interf_count--;
return err; return err;
} }
...@@ -443,7 +438,6 @@ static int stub_probe(struct usb_interface *interface, ...@@ -443,7 +438,6 @@ static int stub_probe(struct usb_interface *interface,
/* set private data to usb_interface */ /* set private data to usb_interface */
usb_set_intfdata(interface, sdev); usb_set_intfdata(interface, sdev);
busid_priv->interf_count++; busid_priv->interf_count++;
busid_priv->sdev = sdev; busid_priv->sdev = sdev;
err = stub_add_files(&interface->dev); err = stub_add_files(&interface->dev);
...@@ -453,7 +447,6 @@ static int stub_probe(struct usb_interface *interface, ...@@ -453,7 +447,6 @@ static int stub_probe(struct usb_interface *interface,
usb_put_intf(interface); usb_put_intf(interface);
busid_priv->interf_count = 0; busid_priv->interf_count = 0;
busid_priv->sdev = NULL; busid_priv->sdev = NULL;
stub_device_free(sdev); stub_device_free(sdev);
return err; return err;
......
...@@ -25,9 +25,7 @@ ...@@ -25,9 +25,7 @@
#define DRIVER_AUTHOR "Takahiro Hirofuchi" #define DRIVER_AUTHOR "Takahiro Hirofuchi"
#define DRIVER_DESC "USB/IP Host Driver" #define DRIVER_DESC "USB/IP Host Driver"
/* stub_priv is allocated from stub_priv_cache */
struct kmem_cache *stub_priv_cache; struct kmem_cache *stub_priv_cache;
/* /*
* busid_tables defines matching busids that usbip can grab. A user can change * busid_tables defines matching busids that usbip can grab. A user can change
* dynamically what device is locally used and what device is exported to a * dynamically what device is locally used and what device is exported to a
...@@ -42,7 +40,6 @@ int match_busid(const char *busid) ...@@ -42,7 +40,6 @@ int match_busid(const char *busid)
int i; int i;
spin_lock(&busid_table_lock); spin_lock(&busid_table_lock);
for (i = 0; i < MAX_BUSID; i++) for (i = 0; i < MAX_BUSID; i++)
if (busid_table[i].name[0]) if (busid_table[i].name[0])
if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) {
...@@ -50,7 +47,6 @@ int match_busid(const char *busid) ...@@ -50,7 +47,6 @@ int match_busid(const char *busid)
spin_unlock(&busid_table_lock); spin_unlock(&busid_table_lock);
return 0; return 0;
} }
spin_unlock(&busid_table_lock); spin_unlock(&busid_table_lock);
return 1; return 1;
...@@ -61,7 +57,6 @@ struct bus_id_priv *get_busid_priv(const char *busid) ...@@ -61,7 +57,6 @@ struct bus_id_priv *get_busid_priv(const char *busid)
int i; int i;
spin_lock(&busid_table_lock); spin_lock(&busid_table_lock);
for (i = 0; i < MAX_BUSID; i++) for (i = 0; i < MAX_BUSID; i++)
if (busid_table[i].name[0]) if (busid_table[i].name[0])
if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) {
...@@ -69,7 +64,6 @@ struct bus_id_priv *get_busid_priv(const char *busid) ...@@ -69,7 +64,6 @@ struct bus_id_priv *get_busid_priv(const char *busid)
spin_unlock(&busid_table_lock); spin_unlock(&busid_table_lock);
return &(busid_table[i]); return &(busid_table[i]);
} }
spin_unlock(&busid_table_lock); spin_unlock(&busid_table_lock);
return NULL; return NULL;
...@@ -81,15 +75,12 @@ static ssize_t show_match_busid(struct device_driver *drv, char *buf) ...@@ -81,15 +75,12 @@ static ssize_t show_match_busid(struct device_driver *drv, char *buf)
char *out = buf; char *out = buf;
spin_lock(&busid_table_lock); spin_lock(&busid_table_lock);
for (i = 0; i < MAX_BUSID; i++) for (i = 0; i < MAX_BUSID; i++)
if (busid_table[i].name[0]) if (busid_table[i].name[0])
out += sprintf(out, "%s ", busid_table[i].name); out += sprintf(out, "%s ", busid_table[i].name);
spin_unlock(&busid_table_lock); spin_unlock(&busid_table_lock);
out += sprintf(out, "\n"); out += sprintf(out, "\n");
return out - buf; return out - buf;
} }
...@@ -101,7 +92,6 @@ static int add_match_busid(char *busid) ...@@ -101,7 +92,6 @@ static int add_match_busid(char *busid)
return 0; return 0;
spin_lock(&busid_table_lock); spin_lock(&busid_table_lock);
for (i = 0; i < MAX_BUSID; i++) for (i = 0; i < MAX_BUSID; i++)
if (!busid_table[i].name[0]) { if (!busid_table[i].name[0]) {
strncpy(busid_table[i].name, busid, BUSID_SIZE); strncpy(busid_table[i].name, busid, BUSID_SIZE);
...@@ -111,7 +101,6 @@ static int add_match_busid(char *busid) ...@@ -111,7 +101,6 @@ static int add_match_busid(char *busid)
spin_unlock(&busid_table_lock); spin_unlock(&busid_table_lock);
return 0; return 0;
} }
spin_unlock(&busid_table_lock); spin_unlock(&busid_table_lock);
return -1; return -1;
...@@ -122,7 +111,6 @@ int del_match_busid(char *busid) ...@@ -122,7 +111,6 @@ int del_match_busid(char *busid)
int i; int i;
spin_lock(&busid_table_lock); spin_lock(&busid_table_lock);
for (i = 0; i < MAX_BUSID; i++) for (i = 0; i < MAX_BUSID; i++)
if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) { if (!strncmp(busid_table[i].name, busid, BUSID_SIZE)) {
/* found */ /* found */
...@@ -135,7 +123,6 @@ int del_match_busid(char *busid) ...@@ -135,7 +123,6 @@ int del_match_busid(char *busid)
spin_unlock(&busid_table_lock); spin_unlock(&busid_table_lock);
return 0; return 0;
} }
spin_unlock(&busid_table_lock); spin_unlock(&busid_table_lock);
return -1; return -1;
......
...@@ -97,13 +97,12 @@ void stub_complete(struct urb *urb) ...@@ -97,13 +97,12 @@ void stub_complete(struct urb *urb)
/* link a urb to the queue of tx. */ /* link a urb to the queue of tx. */
spin_lock_irqsave(&sdev->priv_lock, flags); spin_lock_irqsave(&sdev->priv_lock, flags);
if (priv->unlinking) { if (priv->unlinking) {
stub_enqueue_ret_unlink(sdev, priv->seqnum, urb->status); stub_enqueue_ret_unlink(sdev, priv->seqnum, urb->status);
stub_free_priv_and_urb(priv); stub_free_priv_and_urb(priv);
} else } else {
list_move_tail(&priv->list, &sdev->priv_tx); list_move_tail(&priv->list, &sdev->priv_tx);
}
spin_unlock_irqrestore(&sdev->priv_lock, flags); spin_unlock_irqrestore(&sdev->priv_lock, flags);
/* wake up tx_thread */ /* wake up tx_thread */
......
...@@ -334,8 +334,8 @@ void usbip_dump_header(struct usbip_header *pdu) ...@@ -334,8 +334,8 @@ void usbip_dump_header(struct usbip_header *pdu)
EXPORT_SYMBOL_GPL(usbip_dump_header); EXPORT_SYMBOL_GPL(usbip_dump_header);
/* Send/receive messages over TCP/IP. I refer drivers/block/nbd.c */ /* Send/receive messages over TCP/IP. I refer drivers/block/nbd.c */
int usbip_xmit(int send, struct socket *sock, char *buf, int usbip_xmit(int send, struct socket *sock, char *buf, int size,
int size, int msg_flags) int msg_flags)
{ {
int result; int result;
struct msghdr msg; struct msghdr msg;
...@@ -628,8 +628,7 @@ void usbip_header_correct_endian(struct usbip_header *pdu, int send) ...@@ -628,8 +628,7 @@ void usbip_header_correct_endian(struct usbip_header *pdu, int send)
EXPORT_SYMBOL_GPL(usbip_header_correct_endian); EXPORT_SYMBOL_GPL(usbip_header_correct_endian);
static void usbip_iso_pakcet_correct_endian( static void usbip_iso_pakcet_correct_endian(
struct usbip_iso_packet_descriptor *iso, struct usbip_iso_packet_descriptor *iso, int send)
int send)
{ {
/* does not need all members. but copy all simply. */ /* does not need all members. but copy all simply. */
if (send) { if (send) {
......
...@@ -639,9 +639,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, ...@@ -639,9 +639,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
usb_hcd_unlink_urb_from_ep(hcd, urb); usb_hcd_unlink_urb_from_ep(hcd, urb);
no_need_unlink: no_need_unlink:
spin_unlock_irqrestore(&the_controller->lock, flags); spin_unlock_irqrestore(&the_controller->lock, flags);
usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status); usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);
return ret; return ret;
} }
...@@ -1033,9 +1031,8 @@ static int vhci_bus_resume(struct usb_hcd *hcd) ...@@ -1033,9 +1031,8 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
hcd->state = HC_STATE_RUNNING; hcd->state = HC_STATE_RUNNING;
} }
spin_unlock_irq(&vhci->lock); spin_unlock_irq(&vhci->lock);
return rc;
return 0; return rc;
} }
#else #else
......
...@@ -179,8 +179,6 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev, ...@@ -179,8 +179,6 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
} }
kfree(unlink); kfree(unlink);
return;
} }
static int vhci_priv_tx_empty(struct vhci_device *vdev) static int vhci_priv_tx_empty(struct vhci_device *vdev)
......
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