pxa2xx_udc: cleanups, use platform_get_irq
Make the pxa2xx_udc driver fetch its IRQ from platform resources rather than using compile-time constants, so that it works properly on IXP4xx systems not just PXA21x/25x/26x. Other updates: - Do that using platform_get_irq() - Switch to platform_driver_probe() - Handle device_add() errors - Remove "function" sysfs attribute and its potential errors - Whitespace cleanups Signed-off-by: Milan Svoboda <msvoboda@ra.rockwell.com> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>hifive-unleashed-5.1
parent
c51e9749ab
commit
34ebcd2823
|
@ -1464,20 +1464,6 @@ done:
|
|||
|
||||
#endif /* CONFIG_USB_GADGET_DEBUG_FILES */
|
||||
|
||||
/* "function" sysfs attribute */
|
||||
static ssize_t
|
||||
show_function (struct device *_dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct pxa2xx_udc *dev = dev_get_drvdata (_dev);
|
||||
|
||||
if (!dev->driver
|
||||
|| !dev->driver->function
|
||||
|| strlen (dev->driver->function) > PAGE_SIZE)
|
||||
return 0;
|
||||
return scnprintf (buf, PAGE_SIZE, "%s\n", dev->driver->function);
|
||||
}
|
||||
static DEVICE_ATTR (function, S_IRUGO, show_function, NULL);
|
||||
|
||||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
|
@ -1635,18 +1621,20 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver)
|
|||
dev->gadget.dev.driver = &driver->driver;
|
||||
dev->pullup = 1;
|
||||
|
||||
device_add (&dev->gadget.dev);
|
||||
retval = device_add (&dev->gadget.dev);
|
||||
if (retval) {
|
||||
fail:
|
||||
dev->driver = NULL;
|
||||
dev->gadget.dev.driver = NULL;
|
||||
return retval;
|
||||
}
|
||||
retval = driver->bind(&dev->gadget);
|
||||
if (retval) {
|
||||
DMSG("bind to driver %s --> error %d\n",
|
||||
driver->driver.name, retval);
|
||||
device_del (&dev->gadget.dev);
|
||||
|
||||
dev->driver = NULL;
|
||||
dev->gadget.dev.driver = NULL;
|
||||
return retval;
|
||||
goto fail;
|
||||
}
|
||||
device_create_file(dev->dev, &dev_attr_function);
|
||||
|
||||
/* ... then enable host detection and ep0; and we're ready
|
||||
* for set_configuration as well as eventual disconnect.
|
||||
|
@ -1704,7 +1692,6 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver)
|
|||
dev->driver = NULL;
|
||||
|
||||
device_del (&dev->gadget.dev);
|
||||
device_remove_file(dev->dev, &dev_attr_function);
|
||||
|
||||
DMSG("unregistered gadget driver '%s'\n", driver->driver.name);
|
||||
dump_state(dev);
|
||||
|
@ -2479,7 +2466,7 @@ static struct pxa2xx_udc memory = {
|
|||
static int __init pxa2xx_udc_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct pxa2xx_udc *dev = &memory;
|
||||
int retval, out_dma = 1, vbus_irq;
|
||||
int retval, out_dma = 1, vbus_irq, irq;
|
||||
u32 chiprev;
|
||||
|
||||
/* insist on Intel/ARM/XScale */
|
||||
|
@ -2522,7 +2509,11 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
pr_debug("%s: IRQ %d%s%s%s\n", driver_name, IRQ_USB,
|
||||
irq = platform_get_irq(pdev, 0);
|
||||
if (irq < 0)
|
||||
return -ENODEV;
|
||||
|
||||
pr_debug("%s: IRQ %d%s%s%s\n", driver_name, irq,
|
||||
dev->has_cfr ? "" : " (!cfr)",
|
||||
out_dma ? "" : " (broken dma-out)",
|
||||
SIZE_STR DMASTR
|
||||
|
@ -2570,11 +2561,11 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
|
|||
dev->vbus = is_vbus_present();
|
||||
|
||||
/* irq setup after old hardware state is cleaned up */
|
||||
retval = request_irq(IRQ_USB, pxa2xx_udc_irq,
|
||||
retval = request_irq(irq, pxa2xx_udc_irq,
|
||||
IRQF_DISABLED, driver_name, dev);
|
||||
if (retval != 0) {
|
||||
printk(KERN_ERR "%s: can't get irq %i, err %d\n",
|
||||
driver_name, IRQ_USB, retval);
|
||||
printk(KERN_ERR "%s: can't get irq %d, err %d\n",
|
||||
driver_name, irq, retval);
|
||||
return -EBUSY;
|
||||
}
|
||||
dev->got_irq = 1;
|
||||
|
@ -2589,7 +2580,7 @@ static int __init pxa2xx_udc_probe(struct platform_device *pdev)
|
|||
printk(KERN_ERR "%s: can't get irq %i, err %d\n",
|
||||
driver_name, LUBBOCK_USB_DISC_IRQ, retval);
|
||||
lubbock_fail0:
|
||||
free_irq(IRQ_USB, dev);
|
||||
free_irq(irq, dev);
|
||||
return -EBUSY;
|
||||
}
|
||||
retval = request_irq(LUBBOCK_USB_IRQ,
|
||||
|
@ -2641,7 +2632,7 @@ static int __exit pxa2xx_udc_remove(struct platform_device *pdev)
|
|||
remove_proc_files();
|
||||
|
||||
if (dev->got_irq) {
|
||||
free_irq(IRQ_USB, dev);
|
||||
free_irq(platform_get_irq(pdev, 0), dev);
|
||||
dev->got_irq = 0;
|
||||
}
|
||||
#ifdef CONFIG_ARCH_LUBBOCK
|
||||
|
@ -2701,7 +2692,6 @@ static int pxa2xx_udc_resume(struct platform_device *dev)
|
|||
/*-------------------------------------------------------------------------*/
|
||||
|
||||
static struct platform_driver udc_driver = {
|
||||
.probe = pxa2xx_udc_probe,
|
||||
.shutdown = pxa2xx_udc_shutdown,
|
||||
.remove = __exit_p(pxa2xx_udc_remove),
|
||||
.suspend = pxa2xx_udc_suspend,
|
||||
|
@ -2715,7 +2705,7 @@ static struct platform_driver udc_driver = {
|
|||
static int __init udc_init(void)
|
||||
{
|
||||
printk(KERN_INFO "%s: version %s\n", driver_name, DRIVER_VERSION);
|
||||
return platform_driver_register(&udc_driver);
|
||||
return platform_driver_probe(&udc_driver, pxa2xx_udc_probe);
|
||||
}
|
||||
module_init(udc_init);
|
||||
|
||||
|
|
Loading…
Reference in New Issue