From patchwork Wed Jan 4 21:05:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13088909 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8B28C54E76 for ; Wed, 4 Jan 2023 21:06:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240230AbjADVGe (ORCPT ); Wed, 4 Jan 2023 16:06:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240305AbjADVGU (ORCPT ); Wed, 4 Jan 2023 16:06:20 -0500 Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50C4F1CB13 for ; Wed, 4 Jan 2023 13:06:19 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id DAxcpwWwVxN58DAxlpFlJL; Wed, 04 Jan 2023 22:06:17 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 04 Jan 2023 22:06:17 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, netdev@vger.kernel.org, Christophe JAILLET Subject: [PATCH net-next 1/3] ezchip: Remove some redundant clean-up functions Date: Wed, 4 Jan 2023 22:05:32 +0100 Message-Id: <43e9d047a036cd8a84aad8e9fffdfdcb17a1cf2a.1672865629.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org free_netdev() already calls netif_napi_del(), no need to call it explicitly. It's harmless, but useless. Remove the call in the error handling path of the probe and in the remove function. Signed-off-by: Christophe JAILLET --- drivers/net/ethernet/ezchip/nps_enet.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c index f1eb660aaee2..6389c6b5005c 100644 --- a/drivers/net/ethernet/ezchip/nps_enet.c +++ b/drivers/net/ethernet/ezchip/nps_enet.c @@ -627,7 +627,6 @@ static s32 nps_enet_probe(struct platform_device *pdev) return 0; out_netif_api: - netif_napi_del(&priv->napi); out_netdev: free_netdev(ndev); @@ -640,7 +639,6 @@ static s32 nps_enet_remove(struct platform_device *pdev) struct nps_enet_priv *priv = netdev_priv(ndev); unregister_netdev(ndev); - netif_napi_del(&priv->napi); free_netdev(ndev); return 0; From patchwork Wed Jan 4 21:05:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13088910 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9FC3C53210 for ; Wed, 4 Jan 2023 21:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240260AbjADVGg (ORCPT ); Wed, 4 Jan 2023 16:06:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240309AbjADVG1 (ORCPT ); Wed, 4 Jan 2023 16:06:27 -0500 Received: from smtp.smtpout.orange.fr (smtp-13.smtpout.orange.fr [80.12.242.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C732CAE47 for ; Wed, 4 Jan 2023 13:06:26 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id DAxcpwWwVxN58DAxtpFlJp; Wed, 04 Jan 2023 22:06:25 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 04 Jan 2023 22:06:25 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, netdev@vger.kernel.org, Christophe JAILLET Subject: [PATCH net-next 2/3] ezchip: Switch to some devm_ function to simplify code Date: Wed, 4 Jan 2023 22:05:33 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org devm_alloc_etherdev() and devm_register_netdev() can be used to simplify code. Now the error handling path of the probe and the remove function are useless and can be removed completely. Signed-off-by: Christophe JAILLET --- drivers/net/ethernet/ezchip/nps_enet.c | 42 ++++++-------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c index 6389c6b5005c..21e230150104 100644 --- a/drivers/net/ethernet/ezchip/nps_enet.c +++ b/drivers/net/ethernet/ezchip/nps_enet.c @@ -579,7 +579,7 @@ static s32 nps_enet_probe(struct platform_device *pdev) if (!dev->of_node) return -ENODEV; - ndev = alloc_etherdev(sizeof(struct nps_enet_priv)); + ndev = devm_alloc_etherdev(dev, sizeof(struct nps_enet_priv)); if (!ndev) return -ENOMEM; @@ -594,10 +594,8 @@ static s32 nps_enet_probe(struct platform_device *pdev) ndev->flags &= ~IFF_MULTICAST; priv->regs_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(priv->regs_base)) { - err = PTR_ERR(priv->regs_base); - goto out_netdev; - } + if (IS_ERR(priv->regs_base)) + return PTR_ERR(priv->regs_base); dev_dbg(dev, "Registers base address is 0x%p\n", priv->regs_base); /* set kernel MAC address to dev */ @@ -607,41 +605,20 @@ static s32 nps_enet_probe(struct platform_device *pdev) /* Get IRQ number */ priv->irq = platform_get_irq(pdev, 0); - if (priv->irq < 0) { - err = -ENODEV; - goto out_netdev; - } + if (priv->irq < 0) + return -ENODEV; netif_napi_add_weight(ndev, &priv->napi, nps_enet_poll, NPS_ENET_NAPI_POLL_WEIGHT); /* Register the driver. Should be the last thing in probe */ - err = register_netdev(ndev); - if (err) { - dev_err(dev, "Failed to register ndev for %s, err = 0x%08x\n", - ndev->name, (s32)err); - goto out_netif_api; - } + err = devm_register_netdev(dev, ndev); + if (err) + return dev_err_probe(dev, err, "Failed to register ndev for %s\n", + ndev->name); dev_info(dev, "(rx/tx=%d)\n", priv->irq); return 0; - -out_netif_api: -out_netdev: - free_netdev(ndev); - - return err; -} - -static s32 nps_enet_remove(struct platform_device *pdev) -{ - struct net_device *ndev = platform_get_drvdata(pdev); - struct nps_enet_priv *priv = netdev_priv(ndev); - - unregister_netdev(ndev); - free_netdev(ndev); - - return 0; } static const struct of_device_id nps_enet_dt_ids[] = { @@ -652,7 +629,6 @@ MODULE_DEVICE_TABLE(of, nps_enet_dt_ids); static struct platform_driver nps_enet_driver = { .probe = nps_enet_probe, - .remove = nps_enet_remove, .driver = { .name = DRV_NAME, .of_match_table = nps_enet_dt_ids, From patchwork Wed Jan 4 21:05:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13088911 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB6E3C54EBE for ; Wed, 4 Jan 2023 21:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240289AbjADVGk (ORCPT ); Wed, 4 Jan 2023 16:06:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240314AbjADVGa (ORCPT ); Wed, 4 Jan 2023 16:06:30 -0500 Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 839CA1CB13 for ; Wed, 4 Jan 2023 13:06:29 -0800 (PST) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id DAxcpwWwVxN58DAxvpFlKB; Wed, 04 Jan 2023 22:06:27 +0100 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Wed, 04 Jan 2023 22:06:27 +0100 X-ME-IP: 86.243.100.34 From: Christophe JAILLET To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, netdev@vger.kernel.org, Christophe JAILLET Subject: [PATCH net-next 3/3] ezchip: Further clean-up Date: Wed, 4 Jan 2023 22:05:34 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Now that is only call to platform_get_drvdata() is removed, calling platform_set_drvdata() looks useless. Remove it. While at it, remove a useless 'err' initialization and change its type to a more common 'int' Signed-off-by: Christophe JAILLET --- drivers/net/ethernet/ezchip/nps_enet.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c index 21e230150104..139510d9669f 100644 --- a/drivers/net/ethernet/ezchip/nps_enet.c +++ b/drivers/net/ethernet/ezchip/nps_enet.c @@ -574,7 +574,7 @@ static s32 nps_enet_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct net_device *ndev; struct nps_enet_priv *priv; - s32 err = 0; + int err; if (!dev->of_node) return -ENODEV; @@ -583,7 +583,6 @@ static s32 nps_enet_probe(struct platform_device *pdev) if (!ndev) return -ENOMEM; - platform_set_drvdata(pdev, ndev); SET_NETDEV_DEV(ndev, dev); priv = netdev_priv(ndev);