Commit 03cd00d5 authored by Yuyang Du's avatar Yuyang Du Committed by Greg Kroah-Hartman

usbip: vhci-hcd: Set the vhci structure up to work

This patch enables the new vhci structure. Its lock protects
both the USB2 hub and the shared USB3 hub.
Signed-off-by: default avatarYuyang Du <yuyang.du@intel.com>
Acked-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dff3565b
......@@ -100,8 +100,6 @@ struct vhci {
struct vhci_hcd {
struct vhci *vhci;
spinlock_t lock;
u32 port_status[VHCI_HC_PORTS];
unsigned resuming:1;
......
This diff is collapsed.
......@@ -70,7 +70,8 @@ struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum)
static void vhci_recv_ret_submit(struct vhci_device *vdev,
struct usbip_header *pdu)
{
struct vhci_hcd *vhci = vdev_to_vhci_hcd(vdev);
struct vhci_hcd *vhci_hcd = vdev_to_vhci_hcd(vdev);
struct vhci *vhci = vhci_hcd->vhci;
struct usbip_device *ud = &vdev->ud;
struct urb *urb;
unsigned long flags;
......@@ -82,7 +83,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
if (!urb) {
pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
pr_info("max seqnum %d\n",
atomic_read(&vhci->seqnum));
atomic_read(&vhci_hcd->seqnum));
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
return;
}
......@@ -107,10 +108,10 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
usbip_dbg_vhci_rx("now giveback urb %p\n", urb);
spin_lock_irqsave(&vhci->lock, flags);
usb_hcd_unlink_urb_from_ep(vhci_hcd_to_hcd(vhci), urb);
usb_hcd_unlink_urb_from_ep(vhci_hcd_to_hcd(vhci_hcd), urb);
spin_unlock_irqrestore(&vhci->lock, flags);
usb_hcd_giveback_urb(vhci_hcd_to_hcd(vhci), urb, urb->status);
usb_hcd_giveback_urb(vhci_hcd_to_hcd(vhci_hcd), urb, urb->status);
usbip_dbg_vhci_rx("Leave\n");
}
......@@ -143,7 +144,8 @@ static struct vhci_unlink *dequeue_pending_unlink(struct vhci_device *vdev,
static void vhci_recv_ret_unlink(struct vhci_device *vdev,
struct usbip_header *pdu)
{
struct vhci_hcd *vhci = vdev_to_vhci_hcd(vdev);
struct vhci_hcd *vhci_hcd = vdev_to_vhci_hcd(vdev);
struct vhci *vhci = vhci_hcd->vhci;
struct vhci_unlink *unlink;
struct urb *urb;
unsigned long flags;
......@@ -177,10 +179,10 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
pr_info("urb->status %d\n", urb->status);
spin_lock_irqsave(&vhci->lock, flags);
usb_hcd_unlink_urb_from_ep(vhci_hcd_to_hcd(vhci), urb);
usb_hcd_unlink_urb_from_ep(vhci_hcd_to_hcd(vhci_hcd), urb);
spin_unlock_irqrestore(&vhci->lock, flags);
usb_hcd_giveback_urb(vhci_hcd_to_hcd(vhci), urb, urb->status);
usb_hcd_giveback_urb(vhci_hcd_to_hcd(vhci_hcd), urb, urb->status);
}
kfree(unlink);
......
......@@ -33,9 +33,11 @@
static ssize_t status_show_vhci(int pdev_nr, char *out)
{
struct platform_device *pdev = vhcis[pdev_nr].pdev;
struct vhci_hcd *vhci;
struct vhci *vhci;
struct usb_hcd *hcd;
struct vhci_hcd *vhci_hcd;
char *s = out;
int i = 0;
int i;
unsigned long flags;
if (!pdev || !out) {
......@@ -43,7 +45,9 @@ static ssize_t status_show_vhci(int pdev_nr, char *out)
return 0;
}
vhci = hcd_to_vhci_hcd(platform_get_drvdata(pdev));
hcd = platform_get_drvdata(pdev);
vhci_hcd = hcd_to_vhci_hcd(hcd);
vhci = vhci_hcd->vhci;
spin_lock_irqsave(&vhci->lock, flags);
......@@ -58,7 +62,7 @@ static ssize_t status_show_vhci(int pdev_nr, char *out)
* port number and its peer IP address.
*/
for (i = 0; i < VHCI_HC_PORTS; i++) {
struct vhci_device *vdev = &vhci->vdev[i];
struct vhci_device *vdev = &vhci_hcd->vdev[i];
spin_lock(&vdev->ud.lock);
out += sprintf(out, "%04u %03u ",
......@@ -147,9 +151,10 @@ static ssize_t nports_show(struct device *dev, struct device_attribute *attr,
static DEVICE_ATTR_RO(nports);
/* Sysfs entry to shutdown a virtual connection */
static int vhci_port_disconnect(struct vhci_hcd *vhci, __u32 rhport)
static int vhci_port_disconnect(struct vhci_hcd *vhci_hcd, __u32 rhport)
{
struct vhci_device *vdev = &vhci->vdev[rhport];
struct vhci_device *vdev = &vhci_hcd->vdev[rhport];
struct vhci *vhci = vhci_hcd->vhci;
unsigned long flags;
usbip_dbg_vhci_sysfs("enter\n");
......@@ -262,8 +267,9 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
int sockfd = 0;
__u32 port = 0, pdev_nr = 0, rhport = 0, devid = 0, speed = 0;
struct usb_hcd *hcd;
struct vhci_hcd *vhci;
struct vhci_hcd *vhci_hcd;
struct vhci_device *vdev;
struct vhci *vhci;
int err;
unsigned long flags;
......@@ -292,8 +298,10 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
dev_err(dev, "port %d is not ready\n", port);
return -EAGAIN;
}
vhci = hcd_to_vhci_hcd(hcd);
vdev = &vhci->vdev[rhport];
vhci_hcd = hcd_to_vhci_hcd(hcd);
vhci = vhci_hcd->vhci;
vdev = &vhci_hcd->vdev[rhport];
/* Extract socket from fd. */
socket = sockfd_lookup(sockfd, &err);
......
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