Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1475103pxp; Thu, 10 Mar 2022 06:14:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJwBFavk+oUzwTFARkFg2QiOiJ2TGYDQyqwD1NsQ9k1x0rUhBYWVOYHnwSuejmvPwXUNGOSC X-Received: by 2002:a05:6402:518a:b0:416:b50e:3c7d with SMTP id q10-20020a056402518a00b00416b50e3c7dmr2762624edd.177.1646921656457; Thu, 10 Mar 2022 06:14:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646921656; cv=none; d=google.com; s=arc-20160816; b=NkhmU8YkicXfQglMtXmnvRdeLFbIQyxZWc4H4AYFiOwLSMLvD/Pl09VfK8h5xKqlSN khC1eiyWBTFc++w7X67RBZJdEV0XW5Oy+mxAt2k7kQZRvsgTGOT0arj0nuQJpjg26hu6 nyZjKtVbPhQ7glLWP0KIEGAZ00iDwresUxSgiyZSeO/6IK+asQOKyoQ9SArSFx2QOr6q R3QFdvDEJ8uhiGyGYqTqvOP4K097O15hoFdHCQhlTWCC6K18aLjNyZ/Uu3LsPJSGiKhM ozNH8Scj3nryTMnjcPmw3cXbYEVZzMLxizqYSw/ysN/0x1hpG9INrBIBE0oN1wcd6I6l sqcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=d/m4pyKhgJdBFz5kPXeFjPECCjfYpCkFdqPMeEkL+Rs=; b=TQeDUO3vmRB54fncm+6p3V+6CnE2dTxsSS/rY7LC3yyW8ZLXHbUxKE4zFX0AEY2o0p 8XmzgTiZlbVSN9aVdBjmFLCLb4eFmAw+C/2Sye/IvmptQuqucCm4bGkrsk6YdrH6FgfE sQScmGVJkRta7iMkf4A1gZf4gYDWzyeWHm1lLJx7XIyzZ6xgj/oyU49Dm2zWfxTIQRrm BTjeJ0POQAyG+MHNvc7/ZaaAFxmbpsni8uN2apcqXrZsTRGPbGZOTFEVdOrfnQ/kXu38 G4RVJdIqDXnPJ6w54TOoo73Mj4prUKOA6zvYWmaJOD5ZdcEIZA/3iC1MvdE6tMLgDN/p kmYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a056402524d00b004166306f239si3178700edd.198.2022.03.10.06.13.49; Thu, 10 Mar 2022 06:14:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=renesas.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235786AbiCJB1N (ORCPT + 99 others); Wed, 9 Mar 2022 20:27:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230496AbiCJB1M (ORCPT ); Wed, 9 Mar 2022 20:27:12 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 27B8DE02C1; Wed, 9 Mar 2022 17:26:12 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.90,169,1643641200"; d="scan'208";a="113893486" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 10 Mar 2022 10:26:11 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 80410413CE90; Thu, 10 Mar 2022 10:26:09 +0900 (JST) From: Lad Prabhakar To: Grygorii Strashko , "David S. Miller" , Jakub Kicinski , linux-omap@vger.kernel.org, netdev@vger.kernel.org Cc: Andy Shevchenko , linux-kernel@vger.kernel.org, Prabhakar , Lad Prabhakar Subject: [PATCH] net: ethernet: ti: davinci_emac: Use platform_get_irq() to get the interrupt Date: Thu, 10 Mar 2022 01:26:06 +0000 Message-Id: <20220310012606.20217-1-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static allocation of IRQ resources in DT core code, this causes an issue when using hierarchical interrupt domains using "interrupts" property in the node as this bypasses the hierarchical setup and messes up the irq chaining. In preparation for removal of static setup of IRQ resource from DT core code use platform_get_irq() for DT users only. While at it propagate error code in emac_dev_stop() in case platform_get_irq_optional() fails. Signed-off-by: Lad Prabhakar --- drivers/net/ethernet/ti/davinci_emac.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 31df3267a01a..4b6aed78d392 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1604,6 +1604,7 @@ static int emac_dev_stop(struct net_device *ndev) int irq_num; struct emac_priv *priv = netdev_priv(ndev); struct device *emac_dev = &ndev->dev; + int ret = 0; /* inform the upper layers. */ netif_stop_queue(ndev); @@ -1618,17 +1619,31 @@ static int emac_dev_stop(struct net_device *ndev) phy_disconnect(ndev->phydev); /* Free IRQ */ - while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, i))) { - for (irq_num = res->start; irq_num <= res->end; irq_num++) - free_irq(irq_num, priv->ndev); - i++; + if (dev_of_node(&priv->pdev->dev)) { + do { + ret = platform_get_irq_optional(priv->pdev, i); + if (ret < 0 && ret != -ENXIO) + break; + if (ret > 0) { + free_irq(ret, priv->ndev); + } else { + ret = 0; + break; + } + } while (++i); + } else { + while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, i))) { + for (irq_num = res->start; irq_num <= res->end; irq_num++) + free_irq(irq_num, priv->ndev); + i++; + } } if (netif_msg_drv(priv)) dev_notice(emac_dev, "DaVinci EMAC: %s stopped\n", ndev->name); pm_runtime_put(&priv->pdev->dev); - return 0; + return ret; } /** -- 2.17.1