diff mbox series

[4/4] fotg210-udc: Get IRQ using platform_get_irq()

Message ID 20221114115201.302887-4-linus.walleij@linaro.org
State New
Headers show
Series [1/4] fotg210-udc: Use dev pointer in probe and dev_messages | expand

Commit Message

Linus Walleij Nov. 14, 2022, 11:52 a.m. UTC
The platform_get_irq() is necessary to use to get dynamic
IRQ resolution when instantiating the device from the
device tree. IRQs are not passed as resources in that
case.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 drivers/usb/fotg210/fotg210-udc.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

Sergey Shtylyov Nov. 16, 2022, 12:50 p.m. UTC | #1
Hello!

On 11/14/22 2:52 PM, Linus Walleij wrote:

> The platform_get_irq() is necessary to use to get dynamic
> IRQ resolution when instantiating the device from the
> device tree. IRQs are not passed as resources in that
> case.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
[...]
> diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg210-udc.c
> index de0f72ca103c..44dfe66e189c 100644
> --- a/drivers/usb/fotg210/fotg210-udc.c
> +++ b/drivers/usb/fotg210/fotg210-udc.c
[...]
> @@ -1157,9 +1158,9 @@ int fotg210_udc_probe(struct platform_device *pdev)
>  		return -ENODEV;
>  	}
>  
> -	ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
> -	if (!ires) {
> -		pr_err("platform_get_resource IORESOURCE_IRQ error.\n");
> +	irq = platform_get_irq(pdev, 0);
> +	if (irq < 0) {
> +		pr_err("could not get irq\n");

   platform_get_irq() already curses on irq < 0...

[...]

MBR, Sergey
diff mbox series

Patch

diff --git a/drivers/usb/fotg210/fotg210-udc.c b/drivers/usb/fotg210/fotg210-udc.c
index de0f72ca103c..44dfe66e189c 100644
--- a/drivers/usb/fotg210/fotg210-udc.c
+++ b/drivers/usb/fotg210/fotg210-udc.c
@@ -1144,10 +1144,11 @@  int fotg210_udc_remove(struct platform_device *pdev)
 
 int fotg210_udc_probe(struct platform_device *pdev)
 {
-	struct resource *res, *ires;
+	struct resource *res;
 	struct fotg210_udc *fotg210 = NULL;
 	struct fotg210_ep *_ep[FOTG210_MAX_NUM_EP];
 	struct device *dev = &pdev->dev;
+	int irq;
 	int ret = 0;
 	int i;
 
@@ -1157,9 +1158,9 @@  int fotg210_udc_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	ires = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-	if (!ires) {
-		pr_err("platform_get_resource IORESOURCE_IRQ error.\n");
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		pr_err("could not get irq\n");
 		return -ENODEV;
 	}
 
@@ -1189,7 +1190,7 @@  int fotg210_udc_probe(struct platform_device *pdev)
 		goto err;
 	}
 
-	fotg210->phy = devm_usb_get_phy_by_phandle(dev->parent, "usb-phy", 0);
+	fotg210->phy = devm_usb_get_phy_by_phandle(dev, "usb-phy", 0);
 	if (IS_ERR(fotg210->phy)) {
 		ret = PTR_ERR(fotg210->phy);
 		if (ret == -EPROBE_DEFER)
@@ -1267,7 +1268,7 @@  int fotg210_udc_probe(struct platform_device *pdev)
 
 	fotg210_disable_unplug(fotg210);
 
-	ret = request_irq(ires->start, fotg210_irq, IRQF_SHARED,
+	ret = request_irq(irq, fotg210_irq, IRQF_SHARED,
 			  udc_name, fotg210);
 	if (ret < 0) {
 		dev_err(dev, "request_irq error (%d)\n", ret);
@@ -1288,7 +1289,7 @@  int fotg210_udc_probe(struct platform_device *pdev)
 err_add_udc:
 	if (!IS_ERR_OR_NULL(fotg210->phy))
 		usb_unregister_notifier(fotg210->phy, &fotg210_phy_notifier);
-	free_irq(ires->start, fotg210);
+	free_irq(irq, fotg210);
 
 err_req:
 	fotg210_ep_free_request(&fotg210->ep[0]->ep, fotg210->ep0_req);