Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304241
b: refs/heads/master
c: ba46ce3
h: refs/heads/master
i:
  304239: b72ac01
v: v3
  • Loading branch information
Oleg Nesterov authored and Greg Kroah-Hartman committed Apr 10, 2012
1 parent d532a97 commit 9398eb2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 96ddcd439871658b797289dde8fcead8bde73b68
refs/heads/master: ba46ce30f13a13bb24d05e21df2571ad724f1a1e
12 changes: 6 additions & 6 deletions trunk/drivers/staging/usbip/stub_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,

spin_unlock(&sdev->ud.lock);

sdev->ud.tcp_rx = kthread_run(stub_rx_loop, &sdev->ud, "stub_rx");
sdev->ud.tcp_tx = kthread_run(stub_tx_loop, &sdev->ud, "stub_tx");
sdev->ud.tcp_rx = kthread_get_run(stub_rx_loop, &sdev->ud, "stub_rx");
sdev->ud.tcp_tx = kthread_get_run(stub_tx_loop, &sdev->ud, "stub_tx");

spin_lock(&sdev->ud.lock);
sdev->ud.status = SDEV_ST_USED;
Expand Down Expand Up @@ -187,10 +187,10 @@ static void stub_shutdown_connection(struct usbip_device *ud)
}

/* 1. stop threads */
if (ud->tcp_rx && !task_is_dead(ud->tcp_rx))
kthread_stop(ud->tcp_rx);
if (ud->tcp_tx && !task_is_dead(ud->tcp_tx))
kthread_stop(ud->tcp_tx);
if (ud->tcp_rx)
kthread_stop_put(ud->tcp_rx);
if (ud->tcp_tx)
kthread_stop_put(ud->tcp_tx);

/*
* 2. close the socket
Expand Down
17 changes: 17 additions & 0 deletions trunk/drivers/staging/usbip/usbip_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,23 @@ struct usbip_device {
} eh_ops;
};

#define kthread_get_run(threadfn, data, namefmt, ...) \
({ \
struct task_struct *__k \
= kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
if (!IS_ERR(__k)) { \
get_task_struct(__k); \
wake_up_process(__k); \
} \
__k; \
})

#define kthread_stop_put(k) \
do { \
kthread_stop(k); \
put_task_struct(k); \
} while (0)

/* usbip_common.c */
void usbip_dump_urb(struct urb *purb);
void usbip_dump_header(struct usbip_header *pdu);
Expand Down
8 changes: 4 additions & 4 deletions trunk/drivers/staging/usbip/vhci_hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,10 +821,10 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
}

/* kill threads related to this sdev, if v.c. exists */
if (vdev->ud.tcp_rx && !task_is_dead(vdev->ud.tcp_rx))
kthread_stop(vdev->ud.tcp_rx);
if (vdev->ud.tcp_tx && !task_is_dead(vdev->ud.tcp_tx))
kthread_stop(vdev->ud.tcp_tx);
if (vdev->ud.tcp_rx)
kthread_stop_put(vdev->ud.tcp_rx);
if (vdev->ud.tcp_tx)
kthread_stop_put(vdev->ud.tcp_tx);

pr_info("stop threads\n");

Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/staging/usbip/vhci_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
spin_unlock(&the_controller->lock);
/* end the lock */

vdev->ud.tcp_rx = kthread_run(vhci_rx_loop, &vdev->ud, "vhci_rx");
vdev->ud.tcp_tx = kthread_run(vhci_tx_loop, &vdev->ud, "vhci_tx");
vdev->ud.tcp_rx = kthread_get_run(vhci_rx_loop, &vdev->ud, "vhci_rx");
vdev->ud.tcp_tx = kthread_get_run(vhci_tx_loop, &vdev->ud, "vhci_tx");

rh_port_connect(rhport, speed);

Expand Down

0 comments on commit 9398eb2

Please sign in to comment.