Skip to contentSkip to conversation

net: phy: improve mdio-boardinfo handling

PATCH Applied Heiner Kallweit 3 participants 10 messages Jun 11, 2025 – Jun 14, 2025

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

cover net: phy: improve mdio-boardinfo handling

This series includes smaller improvements to mdio-boardinfo handling.

Heiner Kallweit (4):
net: phy: simplify mdiobus_setup_mdiodev_from_board_info
net: phy: move definition of struct mdio_board_entry to
mdio-boardinfo.c
net: phy: improve mdio-boardinfo.h
net: phy: directly copy struct mdio_board_info in
mdiobus_register_board_info

 drivers/net/phy/mdio-boardinfo.c | 29 ++++++++++++++---------------
 drivers/net/phy/mdio-boardinfo.h |  9 ++-------
 2 files changed, 16 insertions(+), 22 deletions(-)
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH 1/4 net: phy: simplify mdiobus_setup_mdiodev_from_board_info

- Move declaration of variable bi into list_for_each_entry_safe()
- The return value of cb() effectively isn't used, this allows to simplify the code.

---
 drivers/net/phy/mdio-boardinfo.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/net/phy/mdio-boardinfo.c +3 -9
index 2de679a68..0360c0d08 100644
@@ -26,24 +26,18 @@ void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus,
 					   (struct mii_bus *bus,
 					    struct mdio_board_info *bi))
 {
-	struct mdio_board_entry *be;
-	struct mdio_board_entry *tmp;
-	struct mdio_board_info *bi;
-	int ret;
+	struct mdio_board_entry *be, *tmp;
 
 	mutex_lock(&mdio_board_lock);
 	list_for_each_entry_safe(be, tmp, &mdio_board_list, list) {
-		bi = &be->board_info;
+		struct mdio_board_info *bi = &be->board_info;
 
 		if (strcmp(bus->id, bi->bus_id))
 			continue;
 
 		mutex_unlock(&mdio_board_lock);
-		ret = cb(bus, bi);
+		cb(bus, bi);
 		mutex_lock(&mdio_board_lock);
-		if (ret)
-			continue;
-
 	}
 	mutex_unlock(&mdio_board_lock);
 }
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH net-next 1/4] net: phy: simplify mdiobus_setup_mdiodev_from_board_info

Quoted 5 lines · Heiner Kallweit

- Move declaration of variable bi into list_for_each_entry_safe()
- The return value of cb() effectively isn't used, this allows to simplify the code.

Andrew

author maintainer
#3 lore raw

PATCH 2/4 net: phy: move definition of struct mdio_board_entry to mdio-boardinfo.c

In reply to Heiner Kallweit

Struct mdio_board_entry isn't used outside mdio-boardinfo.c, so remove the definition from the header file.

---
 drivers/net/phy/mdio-boardinfo.c | 5 +++++
 drivers/net/phy/mdio-boardinfo.h | 5 -----
 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/net/phy/mdio-boardinfo.c +5 -0
index 0360c0d08..2b2728b68 100644
@@ -14,6 +14,11 @@
 static LIST_HEAD(mdio_board_list);
 static DEFINE_MUTEX(mdio_board_lock);
 
+struct mdio_board_entry {
+	struct list_head	list;
+	struct mdio_board_info	board_info;
+};
+
 /**
  * mdiobus_setup_mdiodev_from_board_info - create and setup MDIO devices
  * from pre-collected board specific MDIO information
drivers/net/phy/mdio-boardinfo.h +0 -5
index 773bb5139..765c64713 100644
@@ -10,11 +10,6 @@
 #include <linux/phy.h>
 #include <linux/mutex.h>
 
-struct mdio_board_entry {
-	struct list_head	list;
-	struct mdio_board_info	board_info;
-};
-
 void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus,
 					   int (*cb)
 					   (struct mii_bus *bus,
Signature · 1 line
2.49.0
author maintainer
#5 lore raw

PATCH 3/4 net: phy: improve mdio-boardinfo.h

In reply to Heiner Kallweit

There's no need to include phy.h and mutex.h in mdio-boardinfo.h. However mdio-boardinfo.c included phy.h indirectly this way so far, include it explicitly instead. Whilst at it, sort the included headers properly.

---
 drivers/net/phy/mdio-boardinfo.c | 7 ++++---
 drivers/net/phy/mdio-boardinfo.h | 4 ++--
 2 files changed, 6 insertions(+), 5 deletions(-)
drivers/net/phy/mdio-boardinfo.c +4 -3
index 2b2728b68..b1e7a5920 100644
@@ -3,11 +3,12 @@
  * mdio-boardinfo - Collect pre-declarations for MDIO devices
  */
 
-#include <linux/kernel.h>
-#include <linux/slab.h>
 #include <linux/export.h>
-#include <linux/mutex.h>
+#include <linux/kernel.h>
 #include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/phy.h>
+#include <linux/slab.h>
 
 #include "mdio-boardinfo.h"
 
drivers/net/phy/mdio-boardinfo.h +2 -2
index 765c64713..0878b7787 100644
@@ -7,8 +7,8 @@
 #ifndef __MDIO_BOARD_INFO_H
 #define __MDIO_BOARD_INFO_H
 
-#include <linux/phy.h>
-#include <linux/mutex.h>
+struct mii_bus;
+struct mdio_board_info;
 
 void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus,
 					   int (*cb)
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 3/4
#6 lore raw

Re: [PATCH net-next 3/4] net: phy: improve mdio-boardinfo.h

Quoted 6 lines · Heiner Kallweit

There's no need to include phy.h and mutex.h in mdio-boardinfo.h. However mdio-boardinfo.c included phy.h indirectly this way so far, include it explicitly instead. Whilst at it, sort the included headers properly.

Andrew

author maintainer
#7 lore raw

PATCH 4/4 net: phy: directly copy struct mdio_board_info in mdiobus_register_board_info

In reply to Heiner Kallweit

Using a direct assignment instead of memcpy reduces the text segment size from 0x273 bytes to 0x19b bytes in my case.

---
 drivers/net/phy/mdio-boardinfo.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/phy/mdio-boardinfo.c +2 -3
index b1e7a5920..d3184e8f1 100644
@@ -62,14 +62,13 @@ int mdiobus_register_board_info(const struct mdio_board_info *info,
 				unsigned int n)
 {
 	struct mdio_board_entry *be;
-	unsigned int i;
 
 	be = kcalloc(n, sizeof(*be), GFP_KERNEL);
 	if (!be)
 		return -ENOMEM;
 
-	for (i = 0; i < n; i++, be++, info++) {
-		memcpy(&be->board_info, info, sizeof(*info));
+	for (int i = 0; i < n; i++, be++) {
+		be->board_info = info[i];
 		mutex_lock(&mdio_board_lock);
 		list_add_tail(&be->list, &mdio_board_list);
 		mutex_unlock(&mdio_board_lock);
Signature · 1 line
2.49.0
#9 lore raw
In reply to Heiner Kallweit
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Wed, 11 Jun 2025 22:08:47 +0200 you wrote:

This series includes smaller improvements to mdio-boardinfo handling.

Heiner Kallweit (4):
net: phy: simplify mdiobus_setup_mdiodev_from_board_info
net: phy: move definition of struct mdio_board_entry to
mdio-boardinfo.c
net: phy: improve mdio-boardinfo.h
net: phy: directly copy struct mdio_board_info in
mdiobus_register_board_info

[...]

Here is the summary with links:
- [net-next,1/4] net: phy: simplify mdiobus_setup_mdiodev_from_board_info

    https://git.kernel.org/netdev/net-next/c/0893bf6bb414
  - [net-next,2/4] net: phy: move definition of struct mdio_board_entry to mdio-boardinfo.c
    https://git.kernel.org/netdev/net-next/c/db4920604a3f
  - [net-next,3/4] net: phy: improve mdio-boardinfo.h
    https://git.kernel.org/netdev/net-next/c/11d40db27155
  - [net-next,4/4] net: phy: directly copy struct mdio_board_info in mdiobus_register_board_info
    https://git.kernel.org/netdev/net-next/c/f59fdcef3a58

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html