mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Roland Hieber <rhi@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 1/2] net: phy: add phy_modify_mmd_indirect convenience function
Date: Tue, 6 Jun 2023 11:54:02 +0200	[thread overview]
Message-ID: <20230606095402.GB18491@pengutronix.de> (raw)
In-Reply-To: <20230605125748.3665121-1-rhi@pengutronix.de>

On Mon, Jun 05, 2023 at 02:57:47PM +0200, Roland Hieber wrote:
> Add a read-modify-write convenience helper similar to phy_modify() for
> setting single bits in MMD registers.
> 
> Signed-off-by: Roland Hieber <rhi@pengutronix.de>
> ---
> PATCH v1 -> v2: new in v2
> 
>  drivers/net/phy/phy.c | 23 +++++++++++++++++++++++
>  include/linux/phy.h   |  2 ++
>  2 files changed, 25 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index 54dbbca7255a..cbdd5bbfb607 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -882,6 +882,29 @@ void phy_write_mmd_indirect(struct phy_device *phydev, int prtad, int devad,
>  	phy_write(phydev, MII_MMD_DATA, data);
>  }
>  
> +/**
> + * phy_modify_mmd_indirect - Convenience function for modifying a MMD register
> + * @phydev: phy device
> + * @prtad: MMD Address
> + * @devad: MMD DEVAD
> + * @mask: bit mask of bits to clear
> + * @set: new value of bits set in @mask
> + *
> + */
> +int phy_modify_mmd_indirect(struct phy_device *phydev, int prtad, int devad,
> +				   u16 mask, u16 set)
> +{
> +	int ret;
> +
> +	ret = phy_read_mmd_indirect(phydev, prtad, devad);
> +	if (ret < 0)
> +		return ret;
> +
> +	phy_write_mmd_indirect(phydev, prtad, devad, (ret & ~mask) | set);
> +
> +	return 0;
> +}
> +
>  int genphy_config_init(struct phy_device *phydev)
>  {
>  	int val;
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 5c3ad91d5ecc..509bf72de918 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -409,6 +409,8 @@ int phy_scan_fixups(struct phy_device *phydev);
>  int phy_read_mmd_indirect(struct phy_device *phydev, int prtad, int devad);
>  void phy_write_mmd_indirect(struct phy_device *phydev, int prtad, int devad,
>  				   u16 data);
> +int phy_modify_mmd_indirect(struct phy_device *phydev, int prtad, int devad,
> +				    u16 mask, u16 set);
>  
>  static inline bool phy_acquired(struct phy_device *phydev)
>  {
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      parent reply	other threads:[~2023-06-06  9:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-05 12:57 Roland Hieber
2023-06-05 12:57 ` [PATCH v2 2/2] net: phy: dp83867: respect ti,clk-output-sel DT property Roland Hieber
2023-06-06  9:54 ` Sascha Hauer [this message]

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=20230606095402.GB18491@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=rhi@pengutronix.de \
    /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