netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Claudiu Beznea <claudiu.beznea@microchip.com>
Cc: davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org,
	nicolas.ferre@microchip.com, linux@armlinux.org.uk,
	paul.walmsley@sifive.com, palmer@dabbelt.com,
	yash.shah@sifive.com, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-riscv@lists.infradead.org
Subject: Re: [PATCH v2 3/8] net: macb: add function to disable all macb clocks
Date: Tue, 8 Dec 2020 19:48:56 +0100	[thread overview]
Message-ID: <20201208184856.GM2475764@lunn.ch> (raw)
In-Reply-To: <1607343333-26552-4-git-send-email-claudiu.beznea@microchip.com>

Hi Claudiu

>  static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
>  			 struct clk **hclk, struct clk **tx_clk,
>  			 struct clk **rx_clk, struct clk **tsu_clk)
> @@ -3743,40 +3753,37 @@ static int macb_clk_init(struct platform_device *pdev, struct clk **pclk,
>  	err = clk_prepare_enable(*hclk);
>  	if (err) {
>  		dev_err(&pdev->dev, "failed to enable hclk (%d)\n", err);
> -		goto err_disable_pclk;
> +		hclk = NULL;
> +		tx_clk = NULL;
> +		rx_clk = NULL;
> +		goto err_disable_clks;
>  	}
>  
>  	err = clk_prepare_enable(*tx_clk);
>  	if (err) {
>  		dev_err(&pdev->dev, "failed to enable tx_clk (%d)\n", err);
> -		goto err_disable_hclk;
> +		tx_clk = NULL;
> +		rx_clk = NULL;
> +		goto err_disable_clks;
>  	}
>  
>  	err = clk_prepare_enable(*rx_clk);
>  	if (err) {
>  		dev_err(&pdev->dev, "failed to enable rx_clk (%d)\n", err);
> -		goto err_disable_txclk;
> +		rx_clk = NULL;
> +		goto err_disable_clks;
>  	}
>  
>  	err = clk_prepare_enable(*tsu_clk);
>  	if (err) {
>  		dev_err(&pdev->dev, "failed to enable tsu_clk (%d)\n", err);
> -		goto err_disable_rxclk;
> +		goto err_disable_clks;
>  	}
>  
>  	return 0;
>  
> -err_disable_rxclk:
> -	clk_disable_unprepare(*rx_clk);
> -
> -err_disable_txclk:
> -	clk_disable_unprepare(*tx_clk);
> -
> -err_disable_hclk:
> -	clk_disable_unprepare(*hclk);
> -
> -err_disable_pclk:
> -	clk_disable_unprepare(*pclk);
> +err_disable_clks:
> +	macb_clks_disable(*pclk, *hclk, *tx_clk, *rx_clk, NULL);

Personal taste, but i would of not changed this.

>  
>  	return err;
>  }
> @@ -4755,11 +4762,7 @@ static int macb_probe(struct platform_device *pdev)
>  	free_netdev(dev);
>  
>  err_disable_clocks:
> -	clk_disable_unprepare(tx_clk);
> -	clk_disable_unprepare(hclk);
> -	clk_disable_unprepare(pclk);
> -	clk_disable_unprepare(rx_clk);
> -	clk_disable_unprepare(tsu_clk);
> +	macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk, bp->rx_clk, bp->tsu_clk);
>  	pm_runtime_disable(&pdev->dev);
>  	pm_runtime_set_suspended(&pdev->dev);
>  	pm_runtime_dont_use_autosuspend(&pdev->dev);
> @@ -4784,11 +4787,8 @@ static int macb_remove(struct platform_device *pdev)
>  		pm_runtime_disable(&pdev->dev);
>  		pm_runtime_dont_use_autosuspend(&pdev->dev);
>  		if (!pm_runtime_suspended(&pdev->dev)) {
> -			clk_disable_unprepare(bp->tx_clk);
> -			clk_disable_unprepare(bp->hclk);
> -			clk_disable_unprepare(bp->pclk);
> -			clk_disable_unprepare(bp->rx_clk);
> -			clk_disable_unprepare(bp->tsu_clk);
> +			macb_clks_disable(bp->pclk, bp->hclk, bp->tx_clk,
> +					  bp->rx_clk, bp->tsu_clk);
>  			pm_runtime_set_suspended(&pdev->dev);
>  		}
>  		phylink_destroy(bp->phylink);
> @@ -4966,14 +4966,16 @@ static int __maybe_unused macb_runtime_suspend(struct device *dev)
>  {
>  	struct net_device *netdev = dev_get_drvdata(dev);
>  	struct macb *bp = netdev_priv(netdev);
> +	struct clk *pclk = NULL, *hclk = NULL, *tx_clk = NULL, *rx_clk = NULL;
>  
>  	if (!(device_may_wakeup(dev))) {
> -		clk_disable_unprepare(bp->tx_clk);
> -		clk_disable_unprepare(bp->hclk);
> -		clk_disable_unprepare(bp->pclk);
> -		clk_disable_unprepare(bp->rx_clk);
> +		pclk = bp->pclk;
> +		hclk = bp->hclk;
> +		tx_clk = bp->tx_clk;
> +		rx_clk = bp->rx_clk;
>  	}
> -	clk_disable_unprepare(bp->tsu_clk);
> +
> +	macb_clks_disable(pclk, hclk, tx_clk, rx_clk, bp->tsu_clk);

Maybe

  	if (!(device_may_wakeup(dev)))
		macb_clks_disable(bp->pclk, bp->hclk, pb->tx_clk, bp->rx_clk, bp->tsu_clk);
	else
		macb_clks_disable(NULL, NULL, NULL, NULL, bp->tsu_clk);

is more readable?

   Andrew

  reply	other threads:[~2020-12-08 20:23 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 12:15 [PATCH v2 0/8] net: macb: add support for sama7g5 Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 1/8] net: macb: add userio bits as platform configuration Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 2/8] net: macb: add capability to not set the clock rate Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 3/8] net: macb: add function to disable all macb clocks Claudiu Beznea
2020-12-08 18:48   ` Andrew Lunn [this message]
2020-12-09  0:22     ` Jakub Kicinski
2020-12-09  0:29   ` Florian Fainelli
2020-12-09  8:43   ` kernel test robot
2020-12-07 12:15 ` [PATCH v2 4/8] net: macb: unprepare clocks in case of failure Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 5/8] dt-bindings: add documentation for sama7g5 ethernet interface Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 6/8] dt-bindings: add documentation for sama7g5 gigabit " Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 7/8] net: macb: add support for sama7g5 gem interface Claudiu Beznea
2020-12-07 12:15 ` [PATCH v2 8/8] net: macb: add support for sama7g5 emac interface Claudiu Beznea

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=20201208184856.GM2475764@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=claudiu.beznea@microchip.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=robh+dt@kernel.org \
    --cc=yash.shah@sifive.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).