diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2020-12-09 22:36:40 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-12-10 16:31:46 +0100 |
commit | ebee0cde1960a41e40840eaa8fe0185aa20e3eb5 (patch) | |
tree | 69b2344fc9e5d626075a4e84f77746b4a1f9e238 | |
parent | feaba5932b6f4bfc875c874a3b7a28c7f05f5a77 (diff) | |
download | linux-stable-ebee0cde1960a41e40840eaa8fe0185aa20e3eb5.tar.gz linux-stable-ebee0cde1960a41e40840eaa8fe0185aa20e3eb5.tar.bz2 linux-stable-ebee0cde1960a41e40840eaa8fe0185aa20e3eb5.zip |
usb: host: sl811: Switch to use platform_get_mem_or_io()
Switch to use new platform_get_mem_or_io() instead of home grown analogue.
Note, the code has been moved upper in the function to allow farther cleanups,
such as resource sanity check.
Cc: linux-usb@vger.kernel.org
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20201209203642.27648-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/usb/host/sl811-hcd.c | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/drivers/usb/host/sl811-hcd.c b/drivers/usb/host/sl811-hcd.c index adaf4063690a..115ced0d93e1 100644 --- a/drivers/usb/host/sl811-hcd.c +++ b/drivers/usb/host/sl811-hcd.c @@ -1614,12 +1614,18 @@ sl811h_probe(struct platform_device *dev) void __iomem *addr_reg; void __iomem *data_reg; int retval; - u8 tmp, ioaddr = 0; + u8 tmp, ioaddr; unsigned long irqflags; if (usb_disabled()) return -ENODEV; + /* the chip may be wired for either kind of addressing */ + addr = platform_get_mem_or_io(dev, 0); + data = platform_get_mem_or_io(dev, 1); + if (!addr || !data || resource_type(addr) != resource_type(data)) + return -ENODEV; + /* basic sanity checks first. board-specific init logic should * have initialized these three resources and probably board * specific platform_data. we don't probe for IRQs, and do only @@ -1632,16 +1638,8 @@ sl811h_probe(struct platform_device *dev) irq = ires->start; irqflags = ires->flags & IRQF_TRIGGER_MASK; - /* the chip may be wired for either kind of addressing */ - addr = platform_get_resource(dev, IORESOURCE_MEM, 0); - data = platform_get_resource(dev, IORESOURCE_MEM, 1); - retval = -EBUSY; - if (!addr || !data) { - addr = platform_get_resource(dev, IORESOURCE_IO, 0); - data = platform_get_resource(dev, IORESOURCE_IO, 1); - if (!addr || !data) - return -ENODEV; - ioaddr = 1; + ioaddr = resource_type(addr) == IORESOURCE_IO; + if (ioaddr) { /* * NOTE: 64-bit resource->start is getting truncated * to avoid compiler warning, assuming that ->start |