From: netdev-bot+sashiko@kernel.org
To: markus.stockhausen@gmx.de
Cc: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, netdev@vger.kernel.org,
chris.packham@alliedtelesis.co.nz, daniel@makrotopia.org,
robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [net-next,v15,05/13] net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus
Date: Wed, 02 Sep 2026 05:36:37 +0000 [thread overview]
Message-ID: <178832739788.3394541.12957364785529278050@kernel.org> (raw)
In-Reply-To: <20260831143439.2404484-6-markus.stockhausen@gmx.de>
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider:
Critical: 0 · High: 0 · Medium: 0 · Low: 1
- [Low] New struct mii_bus callbacks (notify_phy_attach /
notify_phy_detach) and their core call sites in phy_attach_direct() /…
--
net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus
This adds two optional callbacks to struct mii_bus so an MDIO bus driver
can be told when a PHY is attached or detached. notify_phy_attach() is
invoked in phy_attach_direct() after phy_init_hw() and before
phy_resume(), and notify_phy_detach() is invoked from phy_detach() right
after phy_suspend(). phy_detach_internal() gains a notify_bus argument so
the attach error path does not emit a detach notification.
References from the commit message:
[1] https://github.com/openwrt/openwrt/pull/21515#discussion_r2714069716
[2] https://lore.kernel.org/netdev/cover.1769053496.git.daniel@makrotopia.org/
[3] https://lore.kernel.org/netdev/9e40f50b-357a-4a93-9f59-94847850835d@lunn.ch/#t
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 69b04a92b7766..41d1b20cde2c0 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
[ ... ]
> @@ -1997,6 +2003,12 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
> if (err)
> goto error;
>
> + if (phydev->mdio.bus->notify_phy_attach) {
> + err = phydev->mdio.bus->notify_phy_attach(phydev);
> + if (err)
> + goto error;
> + }
> +
> phy_resume(phydev);
[ ... ]
> diff --git a/include/linux/phy.h b/include/linux/phy.h
> index 5f8d65868e0ff..3d8afe6b7f1c5 100644
> --- a/include/linux/phy.h
> +++ b/include/linux/phy.h
> @@ -376,6 +376,24 @@ struct mii_bus {
> int regnum, u16 val);
> /** @reset: Perform a reset of the bus */
> int (*reset)(struct mii_bus *bus);
> + /**
> + * @notify_phy_attach: Perform post-attach handling for MDIO bus
> + * drivers. Optional and independent of @notify_phy_detach. Called
> + * in phy_attach_direct() right before phy_resume(). Runs in process
> + * context, may sleep and may be called with RTNL held. Must not
> + * acquire or rely on RTNL. Returns 0 on success or negative errno
> + * on failure. Must unwind its own state on error as attachment is
> + * aborted.
> + */
> + int (*notify_phy_attach)(struct phy_device *phydev);
> + /**
> + * @notify_phy_detach: Perform pre-detach handling for MDIO bus
> + * drivers. Optional and independent of @notify_phy_attach. Called
> + * in phy_detach() right after phy_suspend(). Runs in process context,
> + * may sleep and may be called with RTNL held. Must not acquire or
> + * rely on RTNL.
> + */
> + void (*notify_phy_detach)(struct phy_device *phydev);
[Severity: Low]
This isn't a bug, but at this commit nothing in the tree assigns
mii_bus::notify_phy_attach or mii_bus::notify_phy_detach, so both new
members and the two call sites in phy_attach_direct() and
phy_detach_internal() are inert here. Both call sites are NULL-checked, so
there is no misbehaviour.
Checking the rest of the series, the first user does arrive later:
drivers/net/mdio/mdio-realtek-rtl9300.c adds
otto_emdio_notify_phy_attach()/otto_emdio_notify_phy_detach() and wires
them up in otto_emdio_probe_one():
bus->notify_phy_attach = otto_emdio_notify_phy_attach;
bus->notify_phy_detach = otto_emdio_notify_phy_detach;
Would it be worth mentioning in the changelog that the first consumer of
these hooks is added by the following patch in the same series ("net: mdio:
realtek-rtl9300: Configure hardware polling during probing"), so readers of
this commit alone know the API is not left without a user?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260831143439.2404484-1-markus.stockhausen%40gmx.de
next prev parent reply other threads:[~2026-09-02 5:36 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 14:34 [PATCH net-next v15 00/13] net: mdio: realtek-rtl9300: Add RTL83xx support Markus Stockhausen
2026-08-31 14:34 ` [PATCH net-next v15 01/13] dt-bindings: net: realtek,rtl9301-mdio: Add RTL83xx series Markus Stockhausen
2026-08-31 14:34 ` [PATCH net-next v15 02/13] net: mdio: realtek-rtl9300: Add polling documentation Markus Stockhausen
2026-08-31 14:34 ` [PATCH net-next v15 03/13] net: mdio: realtek-rtl9300: deny C45 over C22 access Markus Stockhausen
2026-09-02 0:08 ` Andrew Lunn
2026-09-02 5:36 ` [net-next,v15,03/13] " netdev-bot+sashiko
2026-08-31 14:34 ` [PATCH net-next v15 04/13] net: phy: add phy_detach_internal() helper Markus Stockhausen
2026-09-01 14:35 ` sashiko-bot
2026-09-02 0:09 ` Andrew Lunn
2026-08-31 14:34 ` [PATCH net-next v15 05/13] net: phy: add (*notify_phy_attach/detach)() hooks to struct mii_bus Markus Stockhausen
2026-09-02 0:10 ` Andrew Lunn
2026-09-02 5:36 ` netdev-bot+sashiko [this message]
2026-08-31 14:34 ` [PATCH net-next v15 06/13] net: mdio: realtek-rtl9300: suppress sysfs bind/unbind attributes Markus Stockhausen
2026-09-01 14:35 ` sashiko-bot
2026-09-02 0:12 ` Andrew Lunn
2026-09-02 5:36 ` [net-next,v15,06/13] " netdev-bot+sashiko
2026-08-31 14:34 ` [PATCH net-next v15 07/13] net: mdio: realtek-rtl9300: Configure hardware polling during probing Markus Stockhausen
2026-09-01 14:35 ` sashiko-bot
2026-09-02 0:14 ` Andrew Lunn
2026-09-02 5:36 ` [net-next,v15,07/13] " netdev-bot+sashiko
2026-08-31 14:34 ` [PATCH net-next v15 08/13] net: mdio: realtek-rtl9300: Add page tracking Markus Stockhausen
2026-09-02 0:16 ` Andrew Lunn
2026-09-02 5:36 ` [net-next,v15,08/13] " netdev-bot+sashiko
2026-08-31 14:34 ` [PATCH net-next v15 09/13] net: mdio: realtek-rtl9300: Increase MDIO timeout Markus Stockhausen
2026-08-31 14:34 ` [PATCH net-next v15 10/13] net: mdio: realtek-rtl9300: Open up C22 and C45 space in parallel Markus Stockhausen
2026-09-01 14:35 ` sashiko-bot
2026-09-02 0:16 ` Andrew Lunn
2026-09-02 5:36 ` [net-next,v15,10/13] " netdev-bot+sashiko
2026-08-31 14:34 ` [PATCH net-next v15 11/13] net: mdio: realtek-rtl9300: Add support for RTL838x Markus Stockhausen
2026-09-02 0:17 ` Andrew Lunn
2026-09-02 5:36 ` [net-next,v15,11/13] " netdev-bot+sashiko
2026-08-31 14:34 ` [PATCH net-next v15 12/13] net: mdio: realtek-rtl9300: Add support for RTL839x Markus Stockhausen
2026-09-02 0:18 ` Andrew Lunn
2026-09-02 5:32 ` AW: " Markus Stockhausen
2026-09-02 5:36 ` [net-next,v15,12/13] " netdev-bot+sashiko
2026-08-31 14:34 ` [PATCH net-next v15 13/13] net: mdio: realtek-rtl9300: reword Kconfig and module description Markus Stockhausen
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=178832739788.3394541.12957364785529278050@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew@lunn.ch \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=conor+dt@kernel.org \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux@armlinux.org.uk \
--cc=markus.stockhausen@gmx.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
/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