Skip to content

Commit fb5f183

Browse files
Boris BREZILLONgregkh
authored andcommitted
usb: ohci-at91: fix irq and iomem resource retrieval
When using dt resources retrieval (interrupts and reg properties) there is no predefined order for these resources in the platform dev resources table. Retrieve resources using platform_get_resource and platform_get_irq functions instead of direct resource table entries to avoid resource type mismatch. Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com> Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com> Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Reviewed-by: Tomasz Figa <tomasz.figa@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7cd0c29 commit fb5f183

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

drivers/usb/host/ohci-at91.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,27 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
136136
struct ohci_hcd *ohci;
137137
int retval;
138138
struct usb_hcd *hcd = NULL;
139-
140-
if (pdev->num_resources != 2) {
141-
pr_debug("hcd probe: invalid num_resources");
142-
return -ENODEV;
139+
struct device *dev = &pdev->dev;
140+
struct resource *res;
141+
int irq;
142+
143+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
144+
if (!res) {
145+
dev_dbg(dev, "hcd probe: missing memory resource\n");
146+
return -ENXIO;
143147
}
144148

145-
if ((pdev->resource[0].flags != IORESOURCE_MEM)
146-
|| (pdev->resource[1].flags != IORESOURCE_IRQ)) {
147-
pr_debug("hcd probe: invalid resource type\n");
148-
return -ENODEV;
149+
irq = platform_get_irq(pdev, 0);
150+
if (irq < 0) {
151+
dev_dbg(dev, "hcd probe: missing irq resource\n");
152+
return irq;
149153
}
150154

151155
hcd = usb_create_hcd(driver, &pdev->dev, "at91");
152156
if (!hcd)
153157
return -ENOMEM;
154-
hcd->rsrc_start = pdev->resource[0].start;
155-
hcd->rsrc_len = resource_size(&pdev->resource[0]);
158+
hcd->rsrc_start = res->start;
159+
hcd->rsrc_len = resource_size(res);
156160

157161
if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
158162
pr_debug("request_mem_region failed\n");
@@ -199,7 +203,7 @@ static int usb_hcd_at91_probe(const struct hc_driver *driver,
199203
ohci->num_ports = board->ports;
200204
at91_start_hc(pdev);
201205

202-
retval = usb_add_hcd(hcd, pdev->resource[1].start, IRQF_SHARED);
206+
retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
203207
if (retval == 0)
204208
return retval;
205209

0 commit comments

Comments
 (0)