From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Horatiu Vultur <horatiu.vultur@microchip.com>
Cc: andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
richardcochran@gmail.com, o.rempel@pengutronix.de,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/4] net: phy: micrel: Introduce lanphy_modify_page_reg
Date: Thu, 24 Jul 2025 21:41:08 +0100 [thread overview]
Message-ID: <aIKaZNI3fo85vw1_@shell.armlinux.org.uk> (raw)
In-Reply-To: <20250724200826.2662658-3-horatiu.vultur@microchip.com>
On Thu, Jul 24, 2025 at 10:08:24PM +0200, Horatiu Vultur wrote:
> +static int lanphy_modify_page_reg(struct phy_device *phydev, int page, u16 addr,
> + u16 mask, u16 set)
> +{
> + int new, ret;
> +
> + ret = lanphy_read_page_reg(phydev, page, addr);
> + if (ret < 0)
> + return ret;
> +
> + new = (ret & ~mask) | set;
> + if (new == ret)
> + return 0;
> +
> + ret = lanphy_write_page_reg(phydev, page, addr, new);
Please implement this more safely. Another user could jump in between
the read and the write and change this same register.
phy_lock_mdio_bus(phydev);
__phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL, page);
__phy_write(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA, addr);
__phy_write(phydev, LAN_EXT_PAGE_ACCESS_CONTROL,
(page | LAN_EXT_PAGE_ACCESS_CTRL_EP_FUNC));
ret = __phy_modify_changed(phydev, LAN_EXT_PAGE_ACCESS_ADDRESS_DATA,
mask, set);
if (ret < 0)
phydev_err(phydev, "Error: phy_modify has returned error %d\n",
ret);
unlock:
phy_unlock_mdio_bus(phydev);
return ret;
is all that it'll take (assuming the control/address register doesn't
need to be rewritten.)
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2025-07-24 20:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-24 20:08 [PATCH net-next v2 0/4] net: phy: micrel: Add support for lan8842 Horatiu Vultur
2025-07-24 20:08 ` [PATCH net-next v2 1/4] net: phy: micrel: Start using PHY_ID_MATCH_MODEL Horatiu Vultur
2025-07-24 20:08 ` [PATCH net-next v2 2/4] net: phy: micrel: Introduce lanphy_modify_page_reg Horatiu Vultur
2025-07-24 20:41 ` Russell King (Oracle) [this message]
2025-07-25 6:43 ` Horatiu Vultur
2025-07-24 20:08 ` [PATCH net-next v2 3/4] net: phy: micrel: Replace hardcoded pages with defines Horatiu Vultur
2025-07-24 20:45 ` Russell King (Oracle)
2025-07-25 6:48 ` Horatiu Vultur
2025-07-26 6:21 ` Oleksij Rempel
2025-07-28 6:56 ` Horatiu Vultur
2025-07-24 20:08 ` [PATCH net-next v2 4/4] net: phy: micrel: Add support for lan8842 Horatiu Vultur
2025-07-26 11:53 ` ALOK TIWARI
2025-07-28 6:48 ` Horatiu Vultur
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=aIKaZNI3fo85vw1_@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=horatiu.vultur@microchip.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.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 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.