Commit 89a73d28 authored by Yuyang Du's avatar Yuyang Du Committed by Greg Kroah-Hartman

usbip: vhci-hcd: Move VHCI platform device into vhci struct

Every VHCI is a platform device, so move the platform_device struct
into the VHCI struct.
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 559e9c00
...@@ -90,6 +90,8 @@ struct vhci_unlink { ...@@ -90,6 +90,8 @@ struct vhci_unlink {
struct vhci { struct vhci {
spinlock_t lock; spinlock_t lock;
struct platform_device *pdev;
struct vhci_hcd *vhci_hcd_hs; struct vhci_hcd *vhci_hcd_hs;
struct vhci_hcd *vhci_hcd_ss; struct vhci_hcd *vhci_hcd_ss;
}; };
...@@ -116,7 +118,6 @@ struct vhci_hcd { ...@@ -116,7 +118,6 @@ struct vhci_hcd {
}; };
extern int vhci_num_controllers; extern int vhci_num_controllers;
extern struct platform_device **vhci_pdevs;
extern struct vhci *vhcis; extern struct vhci *vhcis;
extern struct attribute_group vhci_attr_group; extern struct attribute_group vhci_attr_group;
......
...@@ -58,8 +58,7 @@ static const char driver_name[] = "vhci_hcd"; ...@@ -58,8 +58,7 @@ static const char driver_name[] = "vhci_hcd";
static const char driver_desc[] = "USB/IP Virtual Host Controller"; static const char driver_desc[] = "USB/IP Virtual Host Controller";
int vhci_num_controllers = VHCI_NR_HCS; int vhci_num_controllers = VHCI_NR_HCS;
struct vhci *vhcis;
struct platform_device **vhci_pdevs;
static const char * const bit_desc[] = { static const char * const bit_desc[] = {
"CONNECTION", /*0*/ "CONNECTION", /*0*/
...@@ -1193,7 +1192,7 @@ static int add_platform_device(int id) ...@@ -1193,7 +1192,7 @@ static int add_platform_device(int id)
if (IS_ERR(pdev)) if (IS_ERR(pdev))
return PTR_ERR(pdev); return PTR_ERR(pdev);
*(vhci_pdevs + id) = pdev; vhcis[id].pdev = pdev;
return 0; return 0;
} }
...@@ -1203,10 +1202,10 @@ static void del_platform_devices(void) ...@@ -1203,10 +1202,10 @@ static void del_platform_devices(void)
int i; int i;
for (i = 0; i < vhci_num_controllers; i++) { for (i = 0; i < vhci_num_controllers; i++) {
pdev = *(vhci_pdevs + i); pdev = vhcis[i].pdev;
if (pdev != NULL) if (pdev != NULL)
platform_device_unregister(pdev); platform_device_unregister(pdev);
*(vhci_pdevs + i) = NULL; vhcis[i].pdev = NULL;
} }
sysfs_remove_link(&platform_bus.kobj, driver_name); sysfs_remove_link(&platform_bus.kobj, driver_name);
} }
...@@ -1221,8 +1220,8 @@ static int __init vhci_hcd_init(void) ...@@ -1221,8 +1220,8 @@ static int __init vhci_hcd_init(void)
if (vhci_num_controllers < 1) if (vhci_num_controllers < 1)
vhci_num_controllers = 1; vhci_num_controllers = 1;
vhci_pdevs = kcalloc(vhci_num_controllers, sizeof(void *), GFP_KERNEL); vhcis = kcalloc(vhci_num_controllers, sizeof(struct vhci), GFP_KERNEL);
if (vhci_pdevs == NULL) if (vhcis == NULL)
return -ENOMEM; return -ENOMEM;
ret = platform_driver_register(&vhci_driver); ret = platform_driver_register(&vhci_driver);
...@@ -1242,7 +1241,7 @@ static int __init vhci_hcd_init(void) ...@@ -1242,7 +1241,7 @@ static int __init vhci_hcd_init(void)
del_platform_devices(); del_platform_devices();
platform_driver_unregister(&vhci_driver); platform_driver_unregister(&vhci_driver);
err_driver_register: err_driver_register:
kfree(vhci_pdevs); kfree(vhcis);
return ret; return ret;
} }
...@@ -1250,7 +1249,7 @@ static void __exit vhci_hcd_exit(void) ...@@ -1250,7 +1249,7 @@ static void __exit vhci_hcd_exit(void)
{ {
del_platform_devices(); del_platform_devices();
platform_driver_unregister(&vhci_driver); platform_driver_unregister(&vhci_driver);
kfree(vhci_pdevs); kfree(vhcis);
} }
module_init(vhci_hcd_init); module_init(vhci_hcd_init);
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
/* Sysfs entry to show port status */ /* Sysfs entry to show port status */
static ssize_t status_show_vhci(int pdev_nr, char *out) static ssize_t status_show_vhci(int pdev_nr, char *out)
{ {
struct platform_device *pdev = *(vhci_pdevs + pdev_nr); struct platform_device *pdev = vhcis[pdev_nr].pdev;
struct vhci_hcd *vhci; struct vhci_hcd *vhci;
char *s = out; char *s = out;
int i = 0; int i = 0;
...@@ -206,7 +206,7 @@ static ssize_t store_detach(struct device *dev, struct device_attribute *attr, ...@@ -206,7 +206,7 @@ static ssize_t store_detach(struct device *dev, struct device_attribute *attr,
if (!valid_port(pdev_nr, rhport)) if (!valid_port(pdev_nr, rhport))
return -EINVAL; return -EINVAL;
hcd = platform_get_drvdata(*(vhci_pdevs + pdev_nr)); hcd = platform_get_drvdata(vhcis[pdev_nr].pdev);
if (hcd == NULL) { if (hcd == NULL) {
dev_err(dev, "port is not ready %u\n", port); dev_err(dev, "port is not ready %u\n", port);
return -EAGAIN; return -EAGAIN;
...@@ -287,7 +287,7 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr, ...@@ -287,7 +287,7 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
if (!valid_args(pdev_nr, rhport, speed)) if (!valid_args(pdev_nr, rhport, speed))
return -EINVAL; return -EINVAL;
hcd = platform_get_drvdata(*(vhci_pdevs + pdev_nr)); hcd = platform_get_drvdata(vhcis[pdev_nr].pdev);
if (hcd == NULL) { if (hcd == NULL) {
dev_err(dev, "port %d is not ready\n", port); dev_err(dev, "port %d is not ready\n", port);
return -EAGAIN; return -EAGAIN;
......
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