Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp13798180rwl; Wed, 4 Jan 2023 13:16:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXuo9mH22w+syZdDd8DIPjYMpFTj0VwEuS/FUTNaFbiJJf2t7/HShIpc40tsrAru+Ynk7ViI X-Received: by 2002:a17:903:3311:b0:189:9733:59d3 with SMTP id jk17-20020a170903331100b00189973359d3mr51504206plb.29.1672867005022; Wed, 04 Jan 2023 13:16:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672867005; cv=none; d=google.com; s=arc-20160816; b=YjtAh5nYz6wjAeJdkUKqwA0wklgTpssfE8YCorotlZHJ0kXUck2HJVN66HarYGN9wO 2q23vlPwsq4TUl/aiC3ZJCSvF9NRfgGmE6x24CH2gJ4qIAoJjyXULxEyPW1LtHbY7/Ui Md1us6o7xzwyz/RE02UQ7vHmwXKOUK27LfR6dVjBvIW9Nba7G+ahC6kGn4h1Q/YuWeJd dU17NocARvsoXb+qeAGPHGPg0MX657+bZGZbQ+mYLYJNesaj+p58DIeVS2ptvNkd7oIu BIwLTeU/yJGgHZM2gmjB4E3CJk6MOSu1wFhaX+DA9cRHDfJiG1+ouWWQqJDTroSZeDpy z79A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=NOk8FwoRz/XzGggrBt07CoRND5dXo8gXC/b5eEKGq6Y=; b=IkfOmq6AgiS0XcMLmn0UwUpcGF6Enq8zEK83Rp76PAvhZPW/MiGCGTgBJe6qsg7M1f dfouCpdQizjKHYfAohZbyPt5rv7hXH/goK54aLQFoOPP5zgB3iUMsUprlIOyTSsKy47v wN/HoNIwKescKqpCnO/yMvC0isscn3EzPpZCCAPwp0p3RaEnzITUMtgPW3obnnDbwfTr MXaUAyN3qld48EWzc6XdxBmGpn0XuoCqbsP/ne3nit0D6q5cHOtJvZCBzOdThP5Uxmb8 x90XQLrXJcyAE9Hvj510b1opvO2gaMgBh46yAWHm+jbPPMgmcw20VaxLvHNFpRgt2NRK d1qQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m4-20020a170902768400b00189e2b9e630si33890226pll.270.2023.01.04.13.16.34; Wed, 04 Jan 2023 13:16:45 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231171AbjADVGn (ORCPT + 56 others); Wed, 4 Jan 2023 16:06:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240308AbjADVG1 (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 D15DB1CB12 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS 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 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, -- 2.34.1