From patchwork Wed May 20 18:03:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joachim Eastwood X-Patchwork-Id: 6448381 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0AF4B9F1CC for ; Wed, 20 May 2015 18:08:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0C0252034F for ; Wed, 20 May 2015 18:08:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14D11201FA for ; Wed, 20 May 2015 18:08:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yv8NS-0006Za-2R; Wed, 20 May 2015 18:05:58 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yv8LV-0004TP-S1 for linux-arm-kernel@bombadil.infradead.org; Wed, 20 May 2015 18:03:58 +0000 Received: from mail-lb0-x230.google.com ([2a00:1450:4010:c04::230]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Yv8LS-0006Lg-Pz for linux-arm-kernel@lists.infradead.org; Wed, 20 May 2015 18:03:55 +0000 Received: by lbcmx3 with SMTP id mx3so536285lbc.1 for ; Wed, 20 May 2015 11:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bZx0ye75V6QfytDjktTpdIMpNwW0/cFiXcO3voZRDBg=; b=AcPlJe1qHEk9snui3V9iTMBlPyLu8kmp2TFasqXQwt5Q/nNC1Ai/cC7AD3XIi5WvIR /ssM6EVI2XhYVpBXawux7f4AgD8yaLjdZTDXiDKZOFvS5xVn3//Ro+VZAJzgYgMBuAO5 jI/lKKgwwebv8XRAabI+9e17oHTafaXZr20D5YlYiyFZCIfG3CVJFSrxkyA5oxY3gt5m ytuuwewkYaWOrsltqAZCFvprv2qZO53+PNRkBEUphiSH+SpU8IZS00U5stTYRLf8tDSN 1odDBtaR5afndySZOsZ9a7z0/47mXLPgRbbIvCmzcVi1xLVDMZ5tCb+zYdYA13llWAmy hSjw== X-Received: by 10.152.239.133 with SMTP id vs5mr17344731lac.75.1432145010874; Wed, 20 May 2015 11:03:30 -0700 (PDT) Received: from localhost.localdomain (183.90-149-48.nextgentel.com. [90.149.48.183]) by mx.google.com with ESMTPSA id si3sm4773856lbb.32.2015.05.20.11.03.29 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 20 May 2015 11:03:30 -0700 (PDT) From: Joachim Eastwood To: peppe.cavallaro@st.com Subject: [PATCH net-next 3/4] stmmac: change the stmmac_dvr_probe return type to int Date: Wed, 20 May 2015 20:03:08 +0200 Message-Id: <1432144989-28283-4-git-send-email-manabian@gmail.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1432144989-28283-1-git-send-email-manabian@gmail.com> References: <1432144989-28283-1-git-send-email-manabian@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150520_190354_993026_2FE922AE X-CRM114-Status: GOOD ( 17.09 ) X-Spam-Score: -2.7 (--) Cc: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, Joachim Eastwood , davem@davemloft.net, arnd@arndb.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since stmmac_dvr_probe takes care of setting driver data and assign resources to the priv structure there is no need to access the priv structure from the other probe functions. This mean that this function can be changed into just return an int and thus simplifying the callers. Signed-off-by: Joachim Eastwood --- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 6 +++--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 15 +++++++-------- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 11 +---------- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 11 +---------- 4 files changed, 12 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index b1687adb8e02..9cbcae203597 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -137,9 +137,9 @@ void stmmac_ptp_unregister(struct stmmac_priv *priv); int stmmac_resume(struct net_device *ndev); int stmmac_suspend(struct net_device *ndev); int stmmac_dvr_remove(struct net_device *ndev); -struct stmmac_priv *stmmac_dvr_probe(struct device *device, - struct plat_stmmacenet_data *plat_dat, - struct stmmac_resources *res); +int stmmac_dvr_probe(struct device *device, + struct plat_stmmacenet_data *plat_dat, + struct stmmac_resources *res); void stmmac_disable_eee_mode(struct stmmac_priv *priv); bool stmmac_eee_init(struct stmmac_priv *priv); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index e8b630a1f1ef..538de1ae4e2d 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -2803,12 +2803,11 @@ static int stmmac_hw_init(struct stmmac_priv *priv) * Description: this is the main probe function used to * call the alloc_etherdev, allocate the priv structure. * Return: - * on success the new private structure is returned, otherwise the error - * pointer. + * returns 0 on success, otherwise errno. */ -struct stmmac_priv *stmmac_dvr_probe(struct device *device, - struct plat_stmmacenet_data *plat_dat, - struct stmmac_resources *res) +int stmmac_dvr_probe(struct device *device, + struct plat_stmmacenet_data *plat_dat, + struct stmmac_resources *res) { int ret = 0; struct net_device *ndev = NULL; @@ -2816,7 +2815,7 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, ndev = alloc_etherdev(sizeof(struct stmmac_priv)); if (!ndev) - return ERR_PTR(-ENOMEM); + return -ENOMEM; SET_NETDEV_DEV(ndev, device); @@ -2952,7 +2951,7 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device, } } - return priv; + return 0; error_mdio_register: unregister_netdev(ndev); @@ -2965,7 +2964,7 @@ error_pclk_get: error_clk_get: free_netdev(ndev); - return ERR_PTR(ret); + return ret; } EXPORT_SYMBOL_GPL(stmmac_dvr_probe); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c index 2c663ec2dfb3..d71a721ea61c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c @@ -164,7 +164,6 @@ static int stmmac_pci_probe(struct pci_dev *pdev, struct stmmac_pci_info *info = (struct stmmac_pci_info *)id->driver_data; struct plat_stmmacenet_data *plat; struct stmmac_resources res; - struct stmmac_priv *priv; int i; int ret; @@ -220,15 +219,7 @@ static int stmmac_pci_probe(struct pci_dev *pdev, res.wol_irq = pdev->irq; res.irq = pdev->irq; - priv = stmmac_dvr_probe(&pdev->dev, plat, &res); - if (IS_ERR(priv)) { - dev_err(&pdev->dev, "%s: main driver probe failed\n", __func__); - return PTR_ERR(priv); - } - - dev_dbg(&pdev->dev, "STMMAC PCI driver registration completed\n"); - - return 0; + return stmmac_dvr_probe(&pdev->dev, plat, &res); } /** diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index 6b7481afbdf7..10de9351a1ec 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -255,7 +255,6 @@ int stmmac_pltfr_probe(struct platform_device *pdev) int ret = 0; struct resource *res; struct device *dev = &pdev->dev; - struct stmmac_priv *priv = NULL; struct plat_stmmacenet_data *plat_dat = NULL; memset(&stmmac_res, 0, sizeof(stmmac_res)); @@ -334,15 +333,7 @@ int stmmac_pltfr_probe(struct platform_device *pdev) return ret; } - priv = stmmac_dvr_probe(&(pdev->dev), plat_dat, &stmmac_res); - if (IS_ERR(priv)) { - pr_err("%s: main driver probe failed", __func__); - return PTR_ERR(priv); - } - - pr_debug("STMMAC platform driver registration completed"); - - return 0; + return stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res); } EXPORT_SYMBOL_GPL(stmmac_pltfr_probe);