* [PATCH net-next 0/2] net: phy: stop exporting phy_driver_register
@ 2025-09-20 21:31 Heiner Kallweit
2025-09-20 21:33 ` [PATCH net-next 1/2] net: phy: dp83640: improve phydev and driver removal handling Heiner Kallweit
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Heiner Kallweit @ 2025-09-20 21:31 UTC (permalink / raw)
To: Andrew Lunn, Andrew Lunn, Russell King - ARM Linux, Eric Dumazet,
Paolo Abeni, Jakub Kicinski, David Miller
Cc: netdev@vger.kernel.org
Once the last user of a clock in dp83640 has been removed, the clock should
be removed. So far orphaned clocks are cleaned up in dp83640_free_clocks()
only. Add the logic to remove orphaned clocks in dp83640_remove().
This allows to simplify the code, and use standard macro
module_phy_driver(). dp83640 was the last external user of
phy_driver_register(), so we can stop exporting this function afterwards.
Heiner Kallweit (2):
net: phy: dp83640: improve phydev and driver removal handling
net: phy: stop exporting phy_driver_register
drivers/net/phy/dp83640.c | 58 +++++++++++++-----------------------
drivers/net/phy/phy_device.c | 4 +--
include/linux/phy.h | 1 -
3 files changed, 22 insertions(+), 41 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next 1/2] net: phy: dp83640: improve phydev and driver removal handling
2025-09-20 21:31 [PATCH net-next 0/2] net: phy: stop exporting phy_driver_register Heiner Kallweit
@ 2025-09-20 21:33 ` Heiner Kallweit
2025-09-22 15:47 ` Maxime Chevallier
2025-09-20 21:34 ` [PATCH net-next 2/2] net: phy: stop exporting phy_driver_register Heiner Kallweit
2025-09-24 0:10 ` [PATCH net-next 0/2] " patchwork-bot+netdevbpf
2 siblings, 1 reply; 5+ messages in thread
From: Heiner Kallweit @ 2025-09-20 21:33 UTC (permalink / raw)
To: Andrew Lunn, Andrew Lunn, Russell King - ARM Linux, Eric Dumazet,
Paolo Abeni, Jakub Kicinski, David Miller, Richard Cochran
Cc: netdev@vger.kernel.org
Once the last user of a clock has been removed, the clock should be
removed. So far orphaned clocks are cleaned up in dp83640_free_clocks()
only. Add the logic to remove orphaned clocks in dp83640_remove().
This allows to simplify the code, and use standard macro
module_phy_driver(). dp83640 was the last external user of
phy_driver_register(), so we can stop exporting this function afterwards.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/dp83640.c | 58 ++++++++++++++-------------------------
1 file changed, 20 insertions(+), 38 deletions(-)
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index daab55572..74396453f 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -953,30 +953,6 @@ static void decode_status_frame(struct dp83640_private *dp83640,
}
}
-static void dp83640_free_clocks(void)
-{
- struct dp83640_clock *clock;
- struct list_head *this, *next;
-
- mutex_lock(&phyter_clocks_lock);
-
- list_for_each_safe(this, next, &phyter_clocks) {
- clock = list_entry(this, struct dp83640_clock, list);
- if (!list_empty(&clock->phylist)) {
- pr_warn("phy list non-empty while unloading\n");
- BUG();
- }
- list_del(&clock->list);
- mutex_destroy(&clock->extreg_lock);
- mutex_destroy(&clock->clock_lock);
- put_device(&clock->bus->dev);
- kfree(clock->caps.pin_config);
- kfree(clock);
- }
-
- mutex_unlock(&phyter_clocks_lock);
-}
-
static void dp83640_clock_init(struct dp83640_clock *clock, struct mii_bus *bus)
{
INIT_LIST_HEAD(&clock->list);
@@ -1479,6 +1455,7 @@ static void dp83640_remove(struct phy_device *phydev)
struct dp83640_clock *clock;
struct list_head *this, *next;
struct dp83640_private *tmp, *dp83640 = phydev->priv;
+ bool remove_clock = false;
if (phydev->mdio.addr == BROADCAST_ADDR)
return;
@@ -1506,11 +1483,27 @@ static void dp83640_remove(struct phy_device *phydev)
}
}
+ if (!clock->chosen && list_empty(&clock->phylist))
+ remove_clock = true;
+
dp83640_clock_put(clock);
kfree(dp83640);
+
+ if (remove_clock) {
+ mutex_lock(&phyter_clocks_lock);
+ list_del(&clock->list);
+ mutex_unlock(&phyter_clocks_lock);
+
+ mutex_destroy(&clock->extreg_lock);
+ mutex_destroy(&clock->clock_lock);
+ put_device(&clock->bus->dev);
+ kfree(clock->caps.pin_config);
+ kfree(clock);
+ }
}
-static struct phy_driver dp83640_driver = {
+static struct phy_driver dp83640_driver[] = {
+{
.phy_id = DP83640_PHY_ID,
.phy_id_mask = 0xfffffff0,
.name = "NatSemi DP83640",
@@ -1521,26 +1514,15 @@ static struct phy_driver dp83640_driver = {
.config_init = dp83640_config_init,
.config_intr = dp83640_config_intr,
.handle_interrupt = dp83640_handle_interrupt,
+},
};
-static int __init dp83640_init(void)
-{
- return phy_driver_register(&dp83640_driver, THIS_MODULE);
-}
-
-static void __exit dp83640_exit(void)
-{
- dp83640_free_clocks();
- phy_driver_unregister(&dp83640_driver);
-}
+module_phy_driver(dp83640_driver);
MODULE_DESCRIPTION("National Semiconductor DP83640 PHY driver");
MODULE_AUTHOR("Richard Cochran <richardcochran@gmail.com>");
MODULE_LICENSE("GPL");
-module_init(dp83640_init);
-module_exit(dp83640_exit);
-
static const struct mdio_device_id __maybe_unused dp83640_tbl[] = {
{ DP83640_PHY_ID, 0xfffffff0 },
{ }
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 2/2] net: phy: stop exporting phy_driver_register
2025-09-20 21:31 [PATCH net-next 0/2] net: phy: stop exporting phy_driver_register Heiner Kallweit
2025-09-20 21:33 ` [PATCH net-next 1/2] net: phy: dp83640: improve phydev and driver removal handling Heiner Kallweit
@ 2025-09-20 21:34 ` Heiner Kallweit
2025-09-24 0:10 ` [PATCH net-next 0/2] " patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: Heiner Kallweit @ 2025-09-20 21:34 UTC (permalink / raw)
To: Andrew Lunn, Andrew Lunn, Russell King - ARM Linux, Eric Dumazet,
Paolo Abeni, Jakub Kicinski, David Miller
Cc: netdev@vger.kernel.org
phy_driver_register() isn't used outside phy_device.c any longer,
so we can stop exporting it.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/net/phy/phy_device.c | 4 ++--
include/linux/phy.h | 1 -
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index c82c19971..01269b865 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3544,7 +3544,8 @@ static int phy_remove(struct device *dev)
* @new_driver: new phy_driver to register
* @owner: module owning this PHY
*/
-int phy_driver_register(struct phy_driver *new_driver, struct module *owner)
+static int phy_driver_register(struct phy_driver *new_driver,
+ struct module *owner)
{
int retval;
@@ -3587,7 +3588,6 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner)
return 0;
}
-EXPORT_SYMBOL(phy_driver_register);
int phy_drivers_register(struct phy_driver *new_driver, int n,
struct module *owner)
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 7da9e1947..bae34e7c6 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -2027,7 +2027,6 @@ static inline int phy_read_status(struct phy_device *phydev)
void phy_driver_unregister(struct phy_driver *drv);
void phy_drivers_unregister(struct phy_driver *drv, int n);
-int phy_driver_register(struct phy_driver *new_driver, struct module *owner);
int phy_drivers_register(struct phy_driver *new_driver, int n,
struct module *owner);
void phy_error(struct phy_device *phydev);
--
2.51.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 1/2] net: phy: dp83640: improve phydev and driver removal handling
2025-09-20 21:33 ` [PATCH net-next 1/2] net: phy: dp83640: improve phydev and driver removal handling Heiner Kallweit
@ 2025-09-22 15:47 ` Maxime Chevallier
0 siblings, 0 replies; 5+ messages in thread
From: Maxime Chevallier @ 2025-09-22 15:47 UTC (permalink / raw)
To: Heiner Kallweit, Andrew Lunn, Andrew Lunn,
Russell King - ARM Linux, Eric Dumazet, Paolo Abeni,
Jakub Kicinski, David Miller, Richard Cochran
Cc: netdev@vger.kernel.org
Hi Heiner,
On 21/09/2025 03:03, Heiner Kallweit wrote:
> Once the last user of a clock has been removed, the clock should be
> removed. So far orphaned clocks are cleaned up in dp83640_free_clocks()
> only. Add the logic to remove orphaned clocks in dp83640_remove().
> This allows to simplify the code, and use standard macro
> module_phy_driver(). dp83640 was the last external user of
> phy_driver_register(), so we can stop exporting this function afterwards.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Nice simplification ! I've scratched away the small amount of hair left
on my head reading this, and your changes look correct to me :)
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Maxime
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 0/2] net: phy: stop exporting phy_driver_register
2025-09-20 21:31 [PATCH net-next 0/2] net: phy: stop exporting phy_driver_register Heiner Kallweit
2025-09-20 21:33 ` [PATCH net-next 1/2] net: phy: dp83640: improve phydev and driver removal handling Heiner Kallweit
2025-09-20 21:34 ` [PATCH net-next 2/2] net: phy: stop exporting phy_driver_register Heiner Kallweit
@ 2025-09-24 0:10 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-24 0:10 UTC (permalink / raw)
To: Heiner Kallweit
Cc: andrew, andrew+netdev, linux, edumazet, pabeni, kuba, davem,
netdev
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sat, 20 Sep 2025 23:31:23 +0200 you wrote:
> Once the last user of a clock in dp83640 has been removed, the clock should
> be removed. So far orphaned clocks are cleaned up in dp83640_free_clocks()
> only. Add the logic to remove orphaned clocks in dp83640_remove().
> This allows to simplify the code, and use standard macro
> module_phy_driver(). dp83640 was the last external user of
> phy_driver_register(), so we can stop exporting this function afterwards.
>
> [...]
Here is the summary with links:
- [net-next,1/2] net: phy: dp83640: improve phydev and driver removal handling
https://git.kernel.org/netdev/net-next/c/42e2a9e11a1d
- [net-next,2/2] net: phy: stop exporting phy_driver_register
https://git.kernel.org/netdev/net-next/c/092263a03105
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] 5+ messages in thread
end of thread, other threads:[~2025-09-24 0:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-20 21:31 [PATCH net-next 0/2] net: phy: stop exporting phy_driver_register Heiner Kallweit
2025-09-20 21:33 ` [PATCH net-next 1/2] net: phy: dp83640: improve phydev and driver removal handling Heiner Kallweit
2025-09-22 15:47 ` Maxime Chevallier
2025-09-20 21:34 ` [PATCH net-next 2/2] net: phy: stop exporting phy_driver_register Heiner Kallweit
2025-09-24 0:10 ` [PATCH net-next 0/2] " patchwork-bot+netdevbpf
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.