mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Grygorii Strashko <grygorii.strashko@ti.com>
To: <netdev@vger.kernel.org>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	"David S . Miller" <davem@davemloft.net>,
	Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>, Sekhar Nori <nsekhar@ti.com>,
	<linux-kernel@vger.kernel.org>, <linux-omap@vger.kernel.org>,
	Murali Karicheri <m-karicheri2@ti.com>,
	Grygorii Strashko <grygorii.strashko@ti.com>
Subject: [PATCH net-next 05/19] net: ethernet: ti: cpsw: use local var dev in probe
Date: Tue, 23 Apr 2019 16:08:56 +0300	[thread overview]
Message-ID: <1556024950-20752-6-git-send-email-grygorii.strashko@ti.com> (raw)
In-Reply-To: <1556024950-20752-1-git-send-email-grygorii.strashko@ti.com>

Use local variable struct device *dev in probe to simplify code.

Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/ethernet/ti/cpsw.c | 65 +++++++++++++++++-----------------
 1 file changed, 33 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 13a339c64892..0b8cc4e6d9cd 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -3458,6 +3458,7 @@ static const struct soc_device_attribute cpsw_soc_devices[] = {
 
 static int cpsw_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct clk			*clk;
 	struct cpsw_platform_data	*data;
 	struct net_device		*ndev;
@@ -3474,15 +3475,15 @@ static int cpsw_probe(struct platform_device *pdev)
 	int ret = 0, i, ch;
 	int irq;
 
-	cpsw = devm_kzalloc(&pdev->dev, sizeof(struct cpsw_common), GFP_KERNEL);
+	cpsw = devm_kzalloc(dev, sizeof(struct cpsw_common), GFP_KERNEL);
 	if (!cpsw)
 		return -ENOMEM;
 
-	cpsw->dev = &pdev->dev;
+	cpsw->dev = dev;
 
 	ndev = alloc_etherdev_mq(sizeof(struct cpsw_priv), CPSW_MAX_QUEUES);
 	if (!ndev) {
-		dev_err(&pdev->dev, "error allocating net_device\n");
+		dev_err(dev, "error allocating net_device\n");
 		return -ENOMEM;
 	}
 
@@ -3490,31 +3491,31 @@ static int cpsw_probe(struct platform_device *pdev)
 	priv = netdev_priv(ndev);
 	priv->cpsw = cpsw;
 	priv->ndev = ndev;
-	priv->dev  = &ndev->dev;
+	priv->dev  = dev;
 	priv->msg_enable = netif_msg_init(debug_level, CPSW_DEBUG);
 	cpsw->rx_packet_max = max(rx_packet_max, 128);
 
-	mode = devm_gpiod_get_array_optional(&pdev->dev, "mode", GPIOD_OUT_LOW);
+	mode = devm_gpiod_get_array_optional(dev, "mode", GPIOD_OUT_LOW);
 	if (IS_ERR(mode)) {
 		ret = PTR_ERR(mode);
-		dev_err(&pdev->dev, "gpio request failed, ret %d\n", ret);
+		dev_err(dev, "gpio request failed, ret %d\n", ret);
 		goto clean_ndev_ret;
 	}
 
 	/*
 	 * This may be required here for child devices.
 	 */
-	pm_runtime_enable(&pdev->dev);
+	pm_runtime_enable(dev);
 
 	/* Select default pin state */
-	pinctrl_pm_select_default_state(&pdev->dev);
+	pinctrl_pm_select_default_state(dev);
 
 	/* Need to enable clocks with runtime PM api to access module
 	 * registers
 	 */
-	ret = pm_runtime_get_sync(&pdev->dev);
+	ret = pm_runtime_get_sync(dev);
 	if (ret < 0) {
-		pm_runtime_put_noidle(&pdev->dev);
+		pm_runtime_put_noidle(dev);
 		goto clean_runtime_disable_ret;
 	}
 
@@ -3528,15 +3529,15 @@ static int cpsw_probe(struct platform_device *pdev)
 
 	if (is_valid_ether_addr(data->slave_data[0].mac_addr)) {
 		memcpy(priv->mac_addr, data->slave_data[0].mac_addr, ETH_ALEN);
-		dev_info(&pdev->dev, "Detected MACID = %pM\n", priv->mac_addr);
+		dev_info(dev, "Detected MACID = %pM\n", priv->mac_addr);
 	} else {
 		eth_random_addr(priv->mac_addr);
-		dev_info(&pdev->dev, "Random MACID = %pM\n", priv->mac_addr);
+		dev_info(dev, "Random MACID = %pM\n", priv->mac_addr);
 	}
 
 	memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN);
 
-	cpsw->slaves = devm_kcalloc(&pdev->dev,
+	cpsw->slaves = devm_kcalloc(dev,
 				    data->slaves, sizeof(struct cpsw_slave),
 				    GFP_KERNEL);
 	if (!cpsw->slaves) {
@@ -3549,16 +3550,16 @@ static int cpsw_probe(struct platform_device *pdev)
 	cpsw->slaves[0].ndev = ndev;
 	priv->emac_port = 0;
 
-	clk = devm_clk_get(&pdev->dev, "fck");
+	clk = devm_clk_get(dev, "fck");
 	if (IS_ERR(clk)) {
-		dev_err(priv->dev, "fck is not found\n");
+		dev_err(dev, "fck is not found\n");
 		ret = -ENODEV;
 		goto clean_dt_ret;
 	}
 	cpsw->bus_freq_mhz = clk_get_rate(clk) / 1000000;
 
 	ss_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	ss_regs = devm_ioremap_resource(&pdev->dev, ss_res);
+	ss_regs = devm_ioremap_resource(dev, ss_res);
 	if (IS_ERR(ss_regs)) {
 		ret = PTR_ERR(ss_regs);
 		goto clean_dt_ret;
@@ -3568,7 +3569,7 @@ static int cpsw_probe(struct platform_device *pdev)
 	cpsw->version = readl(&cpsw->regs->id_ver);
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	cpsw->wr_regs = devm_ioremap_resource(&pdev->dev, res);
+	cpsw->wr_regs = devm_ioremap_resource(dev, res);
 	if (IS_ERR(cpsw->wr_regs)) {
 		ret = PTR_ERR(cpsw->wr_regs);
 		goto clean_dt_ret;
@@ -3606,7 +3607,7 @@ static int cpsw_probe(struct platform_device *pdev)
 			(u32 __force) ss_res->start + CPSW2_BD_OFFSET;
 		break;
 	default:
-		dev_err(priv->dev, "unknown version 0x%08x\n", cpsw->version);
+		dev_err(dev, "unknown version 0x%08x\n", cpsw->version);
 		ret = -ENODEV;
 		goto clean_dt_ret;
 	}
@@ -3618,7 +3619,7 @@ static int cpsw_probe(struct platform_device *pdev)
 		sliver_offset += SLIVER_SIZE;
 	}
 
-	dma_params.dev		= &pdev->dev;
+	dma_params.dev		= dev;
 	dma_params.rxthresh	= dma_params.dmaregs + CPDMA_RXTHRESH;
 	dma_params.rxfree	= dma_params.dmaregs + CPDMA_RXFREE;
 	dma_params.rxhdp	= dma_params.txhdp + CPDMA_RXHDP;
@@ -3637,7 +3638,7 @@ static int cpsw_probe(struct platform_device *pdev)
 
 	cpsw->dma = cpdma_ctlr_create(&dma_params);
 	if (!cpsw->dma) {
-		dev_err(priv->dev, "error initializing dma\n");
+		dev_err(dev, "error initializing dma\n");
 		ret = -ENOMEM;
 		goto clean_dt_ret;
 	}
@@ -3649,26 +3650,26 @@ static int cpsw_probe(struct platform_device *pdev)
 	ch = cpsw->quirk_irq ? 0 : 7;
 	cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, ch, cpsw_tx_handler, 0);
 	if (IS_ERR(cpsw->txv[0].ch)) {
-		dev_err(priv->dev, "error initializing tx dma channel\n");
+		dev_err(dev, "error initializing tx dma channel\n");
 		ret = PTR_ERR(cpsw->txv[0].ch);
 		goto clean_dma_ret;
 	}
 
 	cpsw->rxv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_rx_handler, 1);
 	if (IS_ERR(cpsw->rxv[0].ch)) {
-		dev_err(priv->dev, "error initializing rx dma channel\n");
+		dev_err(dev, "error initializing rx dma channel\n");
 		ret = PTR_ERR(cpsw->rxv[0].ch);
 		goto clean_dma_ret;
 	}
 
-	ale_params.dev			= &pdev->dev;
+	ale_params.dev			= dev;
 	ale_params.ale_ageout		= ale_ageout;
 	ale_params.ale_entries		= data->ale_entries;
 	ale_params.ale_ports		= CPSW_ALE_PORTS_NUM;
 
 	cpsw->ale = cpsw_ale_create(&ale_params);
 	if (!cpsw->ale) {
-		dev_err(priv->dev, "error initializing ale engine\n");
+		dev_err(dev, "error initializing ale engine\n");
 		ret = -ENODEV;
 		goto clean_dma_ret;
 	}
@@ -3681,7 +3682,7 @@ static int cpsw_probe(struct platform_device *pdev)
 
 	ndev->irq = platform_get_irq(pdev, 1);
 	if (ndev->irq < 0) {
-		dev_err(priv->dev, "error getting irq resource\n");
+		dev_err(dev, "error getting irq resource\n");
 		ret = ndev->irq;
 		goto clean_dma_ret;
 	}
@@ -3699,10 +3700,10 @@ static int cpsw_probe(struct platform_device *pdev)
 	cpsw_split_res(cpsw);
 
 	/* register the network device */
-	SET_NETDEV_DEV(ndev, &pdev->dev);
+	SET_NETDEV_DEV(ndev, dev);
 	ret = register_netdev(ndev);
 	if (ret) {
-		dev_err(priv->dev, "error registering net device\n");
+		dev_err(dev, "error registering net device\n");
 		ret = -ENODEV;
 		goto clean_dma_ret;
 	}
@@ -3731,10 +3732,10 @@ static int cpsw_probe(struct platform_device *pdev)
 	}
 
 	cpsw->irqs_table[0] = irq;
-	ret = devm_request_irq(&pdev->dev, irq, cpsw_rx_interrupt,
-			       0, dev_name(&pdev->dev), cpsw);
+	ret = devm_request_irq(dev, irq, cpsw_rx_interrupt,
+			       0, dev_name(dev), cpsw);
 	if (ret < 0) {
-		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
+		dev_err(dev, "error attaching irq (%d)\n", ret);
 		goto clean_dma_ret;
 	}
 
@@ -3746,10 +3747,10 @@ static int cpsw_probe(struct platform_device *pdev)
 	}
 
 	cpsw->irqs_table[1] = irq;
-	ret = devm_request_irq(&pdev->dev, irq, cpsw_tx_interrupt,
+	ret = devm_request_irq(dev, irq, cpsw_tx_interrupt,
 			       0, dev_name(&pdev->dev), cpsw);
 	if (ret < 0) {
-		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
+		dev_err(dev, "error attaching irq (%d)\n", ret);
 		goto clean_dma_ret;
 	}
 
-- 
2.17.1


  parent reply	other threads:[~2019-04-23 13:11 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23 13:08 [PATCH net-next 00/19] net: ethernet: ti: clean up and optimizations Grygorii Strashko
2019-04-23 13:08 ` [PATCH net-next 01/19] net: ethernet: ti: convert to SPDX license identifiers Grygorii Strashko
2019-04-23 13:58   ` Andrew Lunn
2019-04-24  9:31     ` Grygorii Strashko
2019-04-23 13:08 ` [PATCH net-next 02/19] net: ethernet: ti: cpsw: drop TI_DAVINCI_CPDMA config option Grygorii Strashko
2019-04-24  0:27   ` Jakub Kicinski
2019-04-24  9:31     ` Grygorii Strashko
2019-04-25 13:44     ` Murali Karicheri
2019-04-23 13:08 ` [PATCH net-next 03/19] net: ethernet: ti: cpsw: drop CONFIG_TI_CPSW_ALE " Grygorii Strashko
2019-04-23 18:37   ` Andrew Lunn
2019-04-23 13:08 ` [PATCH net-next 04/19] net: ethernet: ti: cpsw: update cpsw_split_res() to accept cpsw_common Grygorii Strashko
2019-04-23 13:08 ` Grygorii Strashko [this message]
2019-04-23 18:40   ` [PATCH net-next 05/19] net: ethernet: ti: cpsw: use local var dev in probe Andrew Lunn
2019-04-24  9:20     ` Grygorii Strashko
2019-04-23 13:08 ` [PATCH net-next 06/19] net: ethernet: ti: cpsw: drop pinctrl_pm_select_default_state call Grygorii Strashko
2019-04-23 18:40   ` Andrew Lunn
2019-04-23 13:08 ` [PATCH net-next 07/19] net: ethernet: ti: cpsw: use devm_alloc_etherdev_mqs() Grygorii Strashko
2019-04-23 18:41   ` Andrew Lunn
2019-04-23 13:08 ` [PATCH net-next 08/19] net: ethernet: ti: cpsw: drop cpsw_tx_packet_submit() Grygorii Strashko
2019-04-23 18:42   ` Andrew Lunn
2019-04-23 13:09 ` [PATCH net-next 09/19] net: ethernet: ti: ale: fix mcast super setting Grygorii Strashko
2019-04-23 13:09 ` [PATCH net-next 10/19] net: ethernet: ti: ale: use define for host port in cpsw_ale_set_allmulti() Grygorii Strashko
2019-04-23 18:43   ` Andrew Lunn
2019-04-23 13:09 ` [PATCH net-next 11/19] net: ethernet: ti: cpsw: fix allmulti cfg in dual_mac mode Grygorii Strashko
2019-04-24 11:00   ` Ivan Khoronzhuk
2019-04-24 12:22   ` Ivan Khoronzhuk
2019-04-24 14:55     ` Grygorii Strashko
2019-04-23 13:09 ` [PATCH net-next 12/19] net: ethernet: ti: ale: do not auto delete mcast super entries Grygorii Strashko
2019-04-23 13:09 ` [PATCH net-next 13/19] net: ethernet: ti: davinci_mdio: use devm_ioremap() Grygorii Strashko
2019-04-23 13:09 ` [PATCH net-next 14/19] net: ethernet: ti: cpsw: refactor probe to group common hw initialization Grygorii Strashko
2019-04-23 13:09 ` [PATCH net-next 15/19] net: ethernet: ti: cpsw: move cpsw definitions in priv header Grygorii Strashko
2019-04-23 13:09 ` [PATCH net-next 16/19] net: ethernet: ti: cpsw: move common hw init code in separate func Grygorii Strashko
2019-04-23 18:53   ` Andrew Lunn
2019-04-25 13:38   ` Murali Karicheri
2019-04-25 14:14     ` Grygorii Strashko
2019-04-23 13:09 ` [PATCH net-next 17/19] net: ethernet: ti: cpsw: introduce mac sl module api Grygorii Strashko
2019-04-23 19:01   ` Andrew Lunn
2019-04-23 13:09 ` [PATCH net-next 18/19] net: ethernet: ti: cpsw: switch to use mac sl api Grygorii Strashko
2019-04-23 13:09 ` [PATCH net-next 19/19] net: ethernet: ti: cpsw: move ethtool func in separate file Grygorii Strashko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1556024950-20752-6-git-send-email-grygorii.strashko@ti.com \
    --to=grygorii.strashko@ti.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=ivan.khoronzhuk@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=m-karicheri2@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=nsekhar@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®