Skip to content

Commit ff4c65c

Browse files
vinodkoulgregkh
authored andcommitted
usb: hci: add hc_driver as argument for usb_hcd_pci_probe
usb_hcd_pci_probe expects users to call this with driver_data set as hc_driver, that limits the possibility of using the driver_data for driver data. Add hc_driver as argument to usb_hcd_pci_probe and modify the callers ehci/ohci/xhci/uhci to pass hc_driver as argument and freeup the driver_data used Tested xhci driver on Dragon-board RB3, compile tested ehci, ohci and uhci. [For all but the xHCI parts] [For the xhci part] Suggested-by: Mathias Nyman <[email protected]> Acked-by: Alan Stern <[email protected]> Acked-by: Mathias Nyman <[email protected]> Signed-off-by: Vinod Koul <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent c33f4f2 commit ff4c65c

File tree

6 files changed

+25
-22
lines changed

6 files changed

+25
-22
lines changed

drivers/usb/core/hcd-pci.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ static void ehci_wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd,
159159
* usb_hcd_pci_probe - initialize PCI-based HCDs
160160
* @dev: USB Host Controller being probed
161161
* @id: pci hotplug id connecting controller to HCD framework
162+
* @driver: USB HC driver handle
162163
* Context: !in_interrupt()
163164
*
164165
* Allocates basic PCI resources for this USB host controller, and
@@ -169,9 +170,9 @@ static void ehci_wait_for_companions(struct pci_dev *pdev, struct usb_hcd *hcd,
169170
*
170171
* Return: 0 if successful.
171172
*/
172-
int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
173+
int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id,
174+
const struct hc_driver *driver)
173175
{
174-
struct hc_driver *driver;
175176
struct usb_hcd *hcd;
176177
int retval;
177178
int hcd_irq = 0;
@@ -181,7 +182,7 @@ int usb_hcd_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
181182

182183
if (!id)
183184
return -EINVAL;
184-
driver = (struct hc_driver *)id->driver_data;
185+
185186
if (!driver)
186187
return -EINVAL;
187188

drivers/usb/host/ehci-pci.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,23 +360,21 @@ static int ehci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
360360
{
361361
if (is_bypassed_id(pdev))
362362
return -ENODEV;
363-
return usb_hcd_pci_probe(pdev, id);
363+
return usb_hcd_pci_probe(pdev, id, &ehci_pci_hc_driver);
364364
}
365365

366366
static void ehci_pci_remove(struct pci_dev *pdev)
367367
{
368368
pci_clear_mwi(pdev);
369-
usb_hcd_pci_remove(pdev);
369+
usb_hcd_pci_remove(pdev);
370370
}
371371

372372
/* PCI driver selection metadata; PCI hotplugging uses this */
373373
static const struct pci_device_id pci_ids [] = { {
374374
/* handle any USB 2.0 EHCI controller */
375375
PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0),
376-
.driver_data = (unsigned long) &ehci_pci_hc_driver,
377376
}, {
378377
PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_HOST),
379-
.driver_data = (unsigned long) &ehci_pci_hc_driver,
380378
},
381379
{ /* end: all zeroes */ }
382380
};

drivers/usb/host/ohci-pci.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,21 +277,24 @@ static const struct ohci_driver_overrides pci_overrides __initconst = {
277277
static const struct pci_device_id pci_ids[] = { {
278278
/* handle any USB OHCI controller */
279279
PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0),
280-
.driver_data = (unsigned long) &ohci_pci_hc_driver,
281280
}, {
282281
/* The device in the ConneXT I/O hub has no class reg */
283282
PCI_VDEVICE(STMICRO, PCI_DEVICE_ID_STMICRO_USB_OHCI),
284-
.driver_data = (unsigned long) &ohci_pci_hc_driver,
285283
}, { /* end: all zeroes */ }
286284
};
287285
MODULE_DEVICE_TABLE (pci, pci_ids);
288286

287+
static int ohci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
288+
{
289+
return usb_hcd_pci_probe(dev, id, &ohci_pci_hc_driver);
290+
}
291+
289292
/* pci driver glue; this is a "new style" PCI driver module */
290293
static struct pci_driver ohci_pci_driver = {
291294
.name = hcd_name,
292295
.id_table = pci_ids,
293296

294-
.probe = usb_hcd_pci_probe,
297+
.probe = ohci_pci_probe,
295298
.remove = usb_hcd_pci_remove,
296299
.shutdown = usb_hcd_pci_shutdown,
297300

drivers/usb/host/uhci-pci.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,21 @@ static const struct hc_driver uhci_driver = {
287287
static const struct pci_device_id uhci_pci_ids[] = { {
288288
/* handle any USB UHCI controller */
289289
PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_UHCI, ~0),
290-
.driver_data = (unsigned long) &uhci_driver,
291290
}, { /* end: all zeroes */ }
292291
};
293292

294293
MODULE_DEVICE_TABLE(pci, uhci_pci_ids);
295294

295+
static int uhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
296+
{
297+
return usb_hcd_pci_probe(dev, id, &uhci_driver);
298+
}
299+
296300
static struct pci_driver uhci_pci_driver = {
297301
.name = hcd_name,
298302
.id_table = uhci_pci_ids,
299303

300-
.probe = usb_hcd_pci_probe,
304+
.probe = uhci_pci_probe,
301305
.remove = usb_hcd_pci_remove,
302306
.shutdown = uhci_shutdown,
303307

drivers/usb/host/xhci-pci.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,8 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
327327
{
328328
int retval;
329329
struct xhci_hcd *xhci;
330-
struct hc_driver *driver;
331330
struct usb_hcd *hcd;
332331

333-
driver = (struct hc_driver *)id->driver_data;
334-
335332
/* Prevent runtime suspending between USB-2 and USB-3 initialization */
336333
pm_runtime_get_noresume(&dev->dev);
337334

@@ -341,16 +338,16 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id)
341338
* to say USB 2.0, but I'm not sure what the implications would be in
342339
* the other parts of the HCD code.
343340
*/
344-
retval = usb_hcd_pci_probe(dev, id);
341+
retval = usb_hcd_pci_probe(dev, id, &xhci_pci_hc_driver);
345342

346343
if (retval)
347344
goto put_runtime_pm;
348345

349346
/* USB 2.0 roothub is stored in the PCI device now. */
350347
hcd = dev_get_drvdata(&dev->dev);
351348
xhci = hcd_to_xhci(hcd);
352-
xhci->shared_hcd = usb_create_shared_hcd(driver, &dev->dev,
353-
pci_name(dev), hcd);
349+
xhci->shared_hcd = usb_create_shared_hcd(&xhci_pci_hc_driver, &dev->dev,
350+
pci_name(dev), hcd);
354351
if (!xhci->shared_hcd) {
355352
retval = -ENOMEM;
356353
goto dealloc_usb2_hcd;
@@ -544,10 +541,9 @@ static void xhci_pci_shutdown(struct usb_hcd *hcd)
544541
/*-------------------------------------------------------------------------*/
545542

546543
/* PCI driver selection metadata; PCI hotplugging uses this */
547-
static const struct pci_device_id pci_ids[] = { {
544+
static const struct pci_device_id pci_ids[] = {
548545
/* handle any USB 3.0 xHCI controller */
549-
PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_XHCI, ~0),
550-
.driver_data = (unsigned long) &xhci_pci_hc_driver,
546+
{ PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_XHCI, ~0),
551547
},
552548
{ /* end: all zeroes */ }
553549
};

include/linux/usb/hcd.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ extern void usb_hcd_platform_shutdown(struct platform_device *dev);
479479
struct pci_dev;
480480
struct pci_device_id;
481481
extern int usb_hcd_pci_probe(struct pci_dev *dev,
482-
const struct pci_device_id *id);
482+
const struct pci_device_id *id,
483+
const struct hc_driver *driver);
483484
extern void usb_hcd_pci_remove(struct pci_dev *dev);
484485
extern void usb_hcd_pci_shutdown(struct pci_dev *dev);
485486

0 commit comments

Comments
 (0)