netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <Jonathan.Cameron@Huawei.com>
To: Yangtao Li <frank.li@vivo.com>
Cc: <clement.leger@bootlin.com>, <andrew@lunn.ch>,
	<f.fainelli@gmail.com>, <olteanv@gmail.com>,
	<davem@davemloft.net>, <edumazet@google.com>, <kuba@kernel.org>,
	<pabeni@redhat.com>, <ulli.kroll@googlemail.com>,
	<linus.walleij@linaro.org>, <marcin.s.wojtas@gmail.com>,
	<linux@armlinux.org.uk>, <alexandre.torgue@foss.st.com>,
	<joabreu@synopsys.com>, <mcoquelin.stm32@gmail.com>,
	<hkallweit1@gmail.com>, <u.kleine-koenig@pengutronix.de>,
	<jacob.e.keller@intel.com>, <justinstitt@google.com>,
	<sd@queasysnail.net>, <horms@kernel.org>,
	<linux-renesas-soc@vger.kernel.org>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	Maxime Chevallier <maxime.chevallier@bootlin.com>
Subject: Re: [net-next v3 3/9] net: ethernet: cortina: Convert to devm_clk_get_enabled()
Date: Tue, 27 Aug 2024 11:53:49 +0100	[thread overview]
Message-ID: <20240827115349.00002f77@Huawei.com> (raw)
In-Reply-To: <20240827095712.2672820-4-frank.li@vivo.com>

On Tue, 27 Aug 2024 03:57:06 -0600
Yangtao Li <frank.li@vivo.com> wrote:

> Convert devm_clk_get(), clk_prepare_enable() to a single
> call to devm_clk_get_enabled(), as this is exactly
> what this function does.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

I don't like the mixing of devm and non devm here.
Maybe better to use a devm_add_action_or_reset()
for geth_cleanup_freeq() as well.


> ---
> v3:
> -move the local clock variables, keep lines longest to shortest
> 
>  drivers/net/ethernet/cortina/gemini.c | 25 ++++++++-----------------
>  1 file changed, 8 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index 73e1c71c5092..5c86987c6fdf 100644
> --- a/drivers/net/ethernet/cortina/gemini.c
> +++ b/drivers/net/ethernet/cortina/gemini.c
> @@ -109,7 +109,6 @@ struct gemini_ethernet_port {
>  	struct device *dev;
>  	void __iomem *dma_base;
>  	void __iomem *gmac_base;
> -	struct clk *pclk;
>  	struct reset_control *reset;
>  	int irq;
>  	__le32 mac_addr[3];
> @@ -2326,7 +2325,6 @@ static void gemini_port_remove(struct gemini_ethernet_port *port)
>  		phy_disconnect(port->netdev->phydev);
>  		unregister_netdev(port->netdev);
>  	}
> -	clk_disable_unprepare(port->pclk);
>  	geth_cleanup_freeq(port->geth);
>  }
>  
> @@ -2401,6 +2399,7 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
>  	struct gemini_ethernet *geth;
>  	struct net_device *netdev;
>  	struct device *parent;
> +	struct clk *pclk;
>  	u8 mac[ETH_ALEN];
>  	unsigned int id;
>  	int irq;
> @@ -2453,14 +2452,11 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
>  	port->irq = irq;
>  
>  	/* Clock the port */
> -	port->pclk = devm_clk_get(dev, "PCLK");
> -	if (IS_ERR(port->pclk)) {
> +	pclk = devm_clk_get_enabled(dev, "PCLK");
> +	if (IS_ERR(pclk)) {
>  		dev_err(dev, "no PCLK\n");
> -		return PTR_ERR(port->pclk);
> +		return PTR_ERR(pclk);
>  	}
> -	ret = clk_prepare_enable(port->pclk);
> -	if (ret)
> -		return ret;
>  
>  	/* Maybe there is a nice ethernet address we should use */
>  	gemini_port_save_mac_addr(port);
> @@ -2469,8 +2465,7 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
>  	port->reset = devm_reset_control_get_exclusive(dev, NULL);
>  	if (IS_ERR(port->reset)) {
>  		dev_err(dev, "no reset\n");
> -		ret = PTR_ERR(port->reset);
> -		goto unprepare;
> +		return PTR_ERR(port->reset);
>  	}
>  	reset_control_reset(port->reset);
>  	usleep_range(100, 500);
> @@ -2532,24 +2527,20 @@ static int gemini_ethernet_port_probe(struct platform_device *pdev)
>  					port_names[port->id],
>  					port);
>  	if (ret)
> -		goto unprepare;
> +		return ret;
>  
>  	ret = gmac_setup_phy(netdev);
>  	if (ret) {
>  		netdev_err(netdev,
>  			   "PHY init failed\n");
> -		goto unprepare;
> +		return ret;
>  	}
>  
>  	ret = register_netdev(netdev);
>  	if (ret)
> -		goto unprepare;
> +		return ret;
>  
>  	return 0;
> -
> -unprepare:
> -	clk_disable_unprepare(port->pclk);
> -	return ret;
>  }
>  
>  static void gemini_ethernet_port_remove(struct platform_device *pdev)


  reply	other threads:[~2024-08-27 10:53 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-27  9:57 [net-next v3 0/9] net: convert to devm_clk_get_enabled() and devm_clk_get_optional_enabled() Yangtao Li
2024-08-27  9:57 ` [net-next v3 1/9] net: stmmac: dwmac-intel-plat: Convert to devm_clk_get_enabled() Yangtao Li
2024-08-27 11:20   ` Russell King (Oracle)
2024-08-27 14:51   ` Simon Horman
2024-08-27  9:57 ` [net-next v3 2/9] net: stmmac: platform: Convert to devm_clk_get_enabled() and devm_clk_get_optional_enabled() Yangtao Li
2024-08-27 14:53   ` Simon Horman
2024-08-29  7:22   ` Serge Semin
2024-08-27  9:57 ` [net-next v3 3/9] net: ethernet: cortina: Convert to devm_clk_get_enabled() Yangtao Li
2024-08-27 10:53   ` Jonathan Cameron [this message]
2024-08-27 11:25   ` Russell King (Oracle)
2024-08-27  9:57 ` [net-next v3 4/9] net: mdio: hisi-femac: " Yangtao Li
2024-08-27 10:50   ` Jonathan Cameron
2024-08-27  9:57 ` [net-next v3 5/9] net: dsa: rzn1_a5psw: " Yangtao Li
2024-08-27 12:03   ` Geert Uytterhoeven
2024-08-27  9:57 ` [net-next v3 6/9] net: ethernet: broadcom: bcm63xx_enet: " Yangtao Li
2024-08-27 10:57   ` Jonathan Cameron
2024-08-27  9:57 ` [net-next v3 7/9] net: ethernet: marvell: mvneta: " Yangtao Li
2024-08-27 10:58   ` Jonathan Cameron
2024-08-27  9:57 ` [net-next v3 8/9] net: mvpp2: Convert to devm_clk_get_enabled() and devm_clk_get_optional_enabled() Yangtao Li
2024-08-27 11:09   ` Jonathan Cameron
2024-08-28  6:25     ` Marcin Wojtas
2024-08-28  7:12       ` Geert Uytterhoeven
2024-08-28 13:39         ` Marcin Wojtas
2024-08-27 14:55   ` Simon Horman
2024-08-27  9:57 ` [net-next v3 9/9] net: marvell: pxa168_eth: Convert to devm_clk_get_enabled() Yangtao Li
2024-08-27 11:11   ` Jonathan Cameron

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=20240827115349.00002f77@Huawei.com \
    --to=jonathan.cameron@huawei.com \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andrew@lunn.ch \
    --cc=clement.leger@bootlin.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=frank.li@vivo.com \
    --cc=hkallweit1@gmail.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=joabreu@synopsys.com \
    --cc=justinstitt@google.com \
    --cc=kuba@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=linux@armlinux.org.uk \
    --cc=marcin.s.wojtas@gmail.com \
    --cc=maxime.chevallier@bootlin.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=sd@queasysnail.net \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=ulli.kroll@googlemail.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;
as well as URLs for NNTP newsgroup(s).