* [PATCH net-next] net: phy: fix up const issues in to_mdio_device() and to_phy_device()
@ 2025-05-22 11:21 Greg Kroah-Hartman
2025-05-28 1:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Greg Kroah-Hartman @ 2025-05-22 11:21 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, Greg Kroah-Hartman, Alexander Lobakin, Andrew Lunn,
Heiner Kallweit, Russell King
Both to_mdio_device() and to_phy_device() "throw away" the const pointer
attribute passed to them and return a non-const pointer, which generally
is not a good thing overall. Fix this up by using container_of_const()
which was designed for this very problem.
Cc: Alexander Lobakin <alobakin@pm.me>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Russell King <linux@armlinux.org.uk>
Fixes: 7eab14de73a8 ("mdio, phy: fix -Wshadow warnings triggered by nested container_of()")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
include/linux/mdio.h | 5 +----
include/linux/phy.h | 5 +----
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index 3c3deac57894..e43ff9f980a4 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -45,10 +45,7 @@ struct mdio_device {
unsigned int reset_deassert_delay;
};
-static inline struct mdio_device *to_mdio_device(const struct device *dev)
-{
- return container_of(dev, struct mdio_device, dev);
-}
+#define to_mdio_device(__dev) container_of_const(__dev, struct mdio_device, dev)
/* struct mdio_driver_common: Common to all MDIO drivers */
struct mdio_driver_common {
diff --git a/include/linux/phy.h b/include/linux/phy.h
index a2bfae80c449..bef68f6af99a 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -744,10 +744,7 @@ struct phy_device {
#define PHY_F_NO_IRQ 0x80000000
#define PHY_F_RXC_ALWAYS_ON 0x40000000
-static inline struct phy_device *to_phy_device(const struct device *dev)
-{
- return container_of(to_mdio_device(dev), struct phy_device, mdio);
-}
+#define to_phy_device(__dev) container_of_const(to_mdio_device(__dev), struct phy_device, mdio)
/**
* struct phy_tdr_config - Configuration of a TDR raw test
--
2.49.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net-next] net: phy: fix up const issues in to_mdio_device() and to_phy_device()
2025-05-22 11:21 [PATCH net-next] net: phy: fix up const issues in to_mdio_device() and to_phy_device() Greg Kroah-Hartman
@ 2025-05-28 1:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-05-28 1:20 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: netdev, linux-kernel, alobakin, andrew, hkallweit1, linux
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 22 May 2025 13:21:47 +0200 you wrote:
> Both to_mdio_device() and to_phy_device() "throw away" the const pointer
> attribute passed to them and return a non-const pointer, which generally
> is not a good thing overall. Fix this up by using container_of_const()
> which was designed for this very problem.
>
> Cc: Alexander Lobakin <alobakin@pm.me>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Heiner Kallweit <hkallweit1@gmail.com>
> Cc: Russell King <linux@armlinux.org.uk>
> Fixes: 7eab14de73a8 ("mdio, phy: fix -Wshadow warnings triggered by nested container_of()")
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> [...]
Here is the summary with links:
- [net-next] net: phy: fix up const issues in to_mdio_device() and to_phy_device()
https://git.kernel.org/netdev/net-next/c/e9cb929670a1
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-05-28 1:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-22 11:21 [PATCH net-next] net: phy: fix up const issues in to_mdio_device() and to_phy_device() Greg Kroah-Hartman
2025-05-28 1:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox