All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
To: hkallweit1@gmail.com
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	netdev@vger.kernel.org, nic_swsd@realtek.com, pabeni@redhat.com,
	linux-sh@vger.kernel.org,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Rich Felker <dalias@libc.org>
Subject: Re: [PATCH net-next] r8169: use devm_clk_get_optional_enabled() to simplify the code
Date: Thu, 02 Feb 2023 14:59:31 +0100	[thread overview]
Message-ID: <585c4b48790d71ca43b66fc24ea8d84917c4a0e1.camel@physik.fu-berlin.de> (raw)
In-Reply-To: <68bd1e34-4251-4306-cc7d-e5ccc578acd9@gmail.com>

Hello Heiner!

> Now that we have devm_clk_get_optional_enabled(), we don't have to
> open-code it.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>  drivers/net/ethernet/realtek/r8169_main.c | 37 ++---------------------
>  1 file changed, 3 insertions(+), 34 deletions(-)
> 
> diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c
> index a8b0070bb..e6fb6f223 100644
> --- a/drivers/net/ethernet/realtek/r8169_main.c
> +++ b/drivers/net/ethernet/realtek/r8169_main.c
> @@ -5122,37 +5122,6 @@ static int rtl_jumbo_max(struct rtl8169_private *tp)
>  	}
>  }
>  
> -static void rtl_disable_clk(void *data)
> -{
> -	clk_disable_unprepare(data);
> -}
> -
> -static int rtl_get_ether_clk(struct rtl8169_private *tp)
> -{
> -	struct device *d = tp_to_dev(tp);
> -	struct clk *clk;
> -	int rc;
> -
> -	clk = devm_clk_get(d, "ether_clk");
> -	if (IS_ERR(clk)) {
> -		rc = PTR_ERR(clk);
> -		if (rc == -ENOENT)
> -			/* clk-core allows NULL (for suspend / resume) */
> -			rc = 0;
> -		else
> -			dev_err_probe(d, rc, "failed to get clk\n");
> -	} else {
> -		tp->clk = clk;
> -		rc = clk_prepare_enable(clk);
> -		if (rc)
> -			dev_err(d, "failed to enable clk: %d\n", rc);
> -		else
> -			rc = devm_add_action_or_reset(d, rtl_disable_clk, clk);
> -	}
> -
> -	return rc;
> -}
> -
>  static void rtl_init_mac_address(struct rtl8169_private *tp)
>  {
>  	u8 mac_addr[ETH_ALEN] __aligned(2) = {};
> @@ -5216,9 +5185,9 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		return -ENOMEM;
>  
>  	/* Get the *optional* external "ether_clk" used on some boards */
> -	rc = rtl_get_ether_clk(tp);
> -	if (rc)
> -		return rc;
> +	tp->clk = devm_clk_get_optional_enabled(&pdev->dev, "ether_clk");
> +	if (IS_ERR(tp->clk))
> +		return dev_err_probe(&pdev->dev, PTR_ERR(tp->clk), "failed to get ether_clk\n");
>  
>  	/* enable device (incl. PCI PM wakeup and hotplug setup) */
>  	rc = pcim_enable_device(pdev);
> -- 
> 2.37.3

This change broke the r8169 driver on my SH7785LCR SuperH Evaluation Board.

With your patch, the driver initialization fails with:

[    1.648000] r8169 0000:00:00.0: error -EINVAL: failed to get ether_clk
[    1.676000] r8169: probe of 0000:00:00.0 failed with error -22

Any idea what could be the problem?

Thanks,
Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

  parent reply	other threads:[~2023-02-02 13:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-02 20:52 [PATCH net-next] r8169: use devm_clk_get_optional_enabled() to simplify the code Heiner Kallweit
2022-09-05 11:50 ` patchwork-bot+netdevbpf
2023-02-02 13:59 ` John Paul Adrian Glaubitz [this message]
2023-02-02 16:09   ` Geert Uytterhoeven
2023-02-02 16:18     ` John Paul Adrian Glaubitz
2023-02-02 16:22     ` Geert Uytterhoeven

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=585c4b48790d71ca43b66fc24ea8d84917c4a0e1.camel@physik.fu-berlin.de \
    --to=glaubitz@physik.fu-berlin.de \
    --cc=dalias@libc.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.com \
    --cc=pabeni@redhat.com \
    --cc=ysato@users.sourceforge.jp \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.