Skip to content

Commit 89a73d2

Browse files
ydu19gregkh
authored andcommitted
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: Yuyang Du <yuyang.du@intel.com> Acked-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 559e9c0 commit 89a73d2

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎drivers/usb/usbip/vhci.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ struct vhci_unlink {
9090
struct vhci {
9191
spinlock_t lock;
9292

93+
struct platform_device *pdev;
94+
9395
struct vhci_hcd *vhci_hcd_hs;
9496
struct vhci_hcd *vhci_hcd_ss;
9597
};
@@ -116,7 +118,6 @@ struct vhci_hcd {
116118
};
117119

118120
extern int vhci_num_controllers;
119-
extern struct platform_device **vhci_pdevs;
120121
extern struct vhci *vhcis;
121122
extern struct attribute_group vhci_attr_group;
122123

‎drivers/usb/usbip/vhci_hcd.c‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ static const char driver_name[] = "vhci_hcd";
5858
static const char driver_desc[] = "USB/IP Virtual Host Controller";
5959

6060
int vhci_num_controllers = VHCI_NR_HCS;
61-
62-
struct platform_device **vhci_pdevs;
61+
struct vhci *vhcis;
6362

6463
static const char * const bit_desc[] = {
6564
"CONNECTION", /*0*/
@@ -1193,7 +1192,7 @@ static int add_platform_device(int id)
11931192
if (IS_ERR(pdev))
11941193
return PTR_ERR(pdev);
11951194

1196-
*(vhci_pdevs + id) = pdev;
1195+
vhcis[id].pdev = pdev;
11971196
return 0;
11981197
}
11991198

@@ -1203,10 +1202,10 @@ static void del_platform_devices(void)
12031202
int i;
12041203

12051204
for (i = 0; i < vhci_num_controllers; i++) {
1206-
pdev = *(vhci_pdevs + i);
1205+
pdev = vhcis[i].pdev;
12071206
if (pdev != NULL)
12081207
platform_device_unregister(pdev);
1209-
*(vhci_pdevs + i) = NULL;
1208+
vhcis[i].pdev = NULL;
12101209
}
12111210
sysfs_remove_link(&platform_bus.kobj, driver_name);
12121211
}
@@ -1221,8 +1220,8 @@ static int __init vhci_hcd_init(void)
12211220
if (vhci_num_controllers < 1)
12221221
vhci_num_controllers = 1;
12231222

1224-
vhci_pdevs = kcalloc(vhci_num_controllers, sizeof(void *), GFP_KERNEL);
1225-
if (vhci_pdevs == NULL)
1223+
vhcis = kcalloc(vhci_num_controllers, sizeof(struct vhci), GFP_KERNEL);
1224+
if (vhcis == NULL)
12261225
return -ENOMEM;
12271226

12281227
ret = platform_driver_register(&vhci_driver);
@@ -1242,15 +1241,15 @@ static int __init vhci_hcd_init(void)
12421241
del_platform_devices();
12431242
platform_driver_unregister(&vhci_driver);
12441243
err_driver_register:
1245-
kfree(vhci_pdevs);
1244+
kfree(vhcis);
12461245
return ret;
12471246
}
12481247

12491248
static void __exit vhci_hcd_exit(void)
12501249
{
12511250
del_platform_devices();
12521251
platform_driver_unregister(&vhci_driver);
1253-
kfree(vhci_pdevs);
1252+
kfree(vhcis);
12541253
}
12551254

12561255
module_init(vhci_hcd_init);

‎drivers/usb/usbip/vhci_sysfs.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
/* Sysfs entry to show port status */
3333
static ssize_t status_show_vhci(int pdev_nr, char *out)
3434
{
35-
struct platform_device *pdev = *(vhci_pdevs + pdev_nr);
35+
struct platform_device *pdev = vhcis[pdev_nr].pdev;
3636
struct vhci_hcd *vhci;
3737
char *s = out;
3838
int i = 0;
@@ -206,7 +206,7 @@ static ssize_t store_detach(struct device *dev, struct device_attribute *attr,
206206
if (!valid_port(pdev_nr, rhport))
207207
return -EINVAL;
208208

209-
hcd = platform_get_drvdata(*(vhci_pdevs + pdev_nr));
209+
hcd = platform_get_drvdata(vhcis[pdev_nr].pdev);
210210
if (hcd == NULL) {
211211
dev_err(dev, "port is not ready %u\n", port);
212212
return -EAGAIN;
@@ -287,7 +287,7 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
287287
if (!valid_args(pdev_nr, rhport, speed))
288288
return -EINVAL;
289289

290-
hcd = platform_get_drvdata(*(vhci_pdevs + pdev_nr));
290+
hcd = platform_get_drvdata(vhcis[pdev_nr].pdev);
291291
if (hcd == NULL) {
292292
dev_err(dev, "port %d is not ready\n", port);
293293
return -EAGAIN;

0 commit comments

Comments
 (0)