9544de7cb07416e20b9d98d9510ea147b6358670
[openwrt/openwrt.git] / target / linux / gemini / patches-6.1 / 0011-fotg210-udc-Get-IRQ-using-platform_get_irq.patch
1 From eda686d41e298a9d16708d2ec8d12d8e682dd7ca Mon Sep 17 00:00:00 2001
2 From: Linus Walleij <linus.walleij@linaro.org>
3 Date: Mon, 14 Nov 2022 12:52:01 +0100
4 Subject: [PATCH 11/29] fotg210-udc: Get IRQ using platform_get_irq()
5
6 The platform_get_irq() is necessary to use to get dynamic
7 IRQ resolution when instantiating the device from the
8 device tree. IRQs are not passed as resources in that
9 case.
10
11 Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
12 Link: https://lore.kernel.org/r/20221114115201.302887-4-linus.walleij@linaro.org
13 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
14 ---
15 --- a/drivers/usb/fotg210/fotg210-udc.c
16 +++ b/drivers/usb/fotg210/fotg210-udc.c
17 @@ -1157,10 +1157,11 @@ int fotg210_udc_remove(struct platform_d
18
19 int fotg210_udc_probe(struct platform_device *pdev)
20 {
21 - struct resource *res, *ires;
22 + struct resource *res;
23 struct fotg210_udc *fotg210 = NULL;
24 struct fotg210_ep *_ep[FOTG210_MAX_NUM_EP];
25 struct device *dev = &pdev->dev;
26 + int irq;
27 int ret = 0;
28 int i;
29
30 @@ -1170,9 +1171,9 @@ int fotg210_udc_probe(struct platform_de
31 return -ENODEV;
32 }
33
34 - ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
35 - if (!ires) {
36 - pr_err("platform_get_resource IORESOURCE_IRQ error.\n");
37 + irq = platform_get_irq(pdev, 0);
38 + if (irq < 0) {
39 + pr_err("could not get irq\n");
40 return -ENODEV;
41 }
42
43 @@ -1202,7 +1203,7 @@ int fotg210_udc_probe(struct platform_de
44 goto err;
45 }
46
47 - fotg210->phy = devm_usb_get_phy_by_phandle(dev->parent, "usb-phy", 0);
48 + fotg210->phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0);
49 if (IS_ERR(fotg210->phy)) {
50 ret = PTR_ERR(fotg210->phy);
51 if (ret == -EPROBE_DEFER)
52 @@ -1282,7 +1283,7 @@ int fotg210_udc_probe(struct platform_de
53
54 fotg210_disable_unplug(fotg210);
55
56 - ret = request_irq(ires->start, fotg210_irq, IRQF_SHARED,
57 + ret = request_irq(irq, fotg210_irq, IRQF_SHARED,
58 udc_name, fotg210);
59 if (ret < 0) {
60 dev_err(dev, "request_irq error (%d)\n", ret);
61 @@ -1303,7 +1304,7 @@ int fotg210_udc_probe(struct platform_de
62 err_add_udc:
63 if (!IS_ERR_OR_NULL(fotg210->phy))
64 usb_unregister_notifier(fotg210->phy, &fotg210_phy_notifier);
65 - free_irq(ires->start, fotg210);
66 + free_irq(irq, fotg210);
67
68 err_req:
69 fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req);