Skip to content

Commit

Permalink
usb: host: sl811: Switch to use platform_get_mem_or_io()
Browse files Browse the repository at this point in the history
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: [email protected]
Signed-off-by: Andy Shevchenko <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
andy-shev authored and gregkh committed Dec 10, 2020
1 parent feaba59 commit ebee0cd
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions drivers/usb/host/sl811-hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ebee0cd

Please sign in to comment.