net: phy: improve mdio-boardinfo handling
Subsystems (3)
Heiner Kallweit
maintainercover 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
Heiner Kallweit
maintainerPATCH 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
@@ -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
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 ofcb()effectively isn't used, this allows to simplify the code.Signed-off-by Heiner Kallweit <[email protected]>
Andrew
Heiner Kallweit
maintainerPATCH 2/4 net: phy: move definition of struct mdio_board_entry to mdio-boardinfo.c
In reply to Heiner KallweitStruct 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
@@ -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
@@ -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
Re: [PATCH net-next 2/4] net: phy: move definition of struct mdio_board_entry to mdio-boardinfo.c
Quoted 4 lines · Heiner Kallweit
Struct
mdio_board_entryisn't used outsidemdio-boardinfo.c, so remove the definition from the header file.Signed-off-by Heiner Kallweit <[email protected]>
Andrew
Heiner Kallweit
maintainerPATCH 3/4 net: phy: improve mdio-boardinfo.h
In reply to Heiner KallweitThere'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
@@ -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
@@ -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
Re: [PATCH net-next 3/4] net: phy: improve mdio-boardinfo.h
Quoted 6 lines · Heiner Kallweit
There's no need to include
phy.handmutex.hinmdio-boardinfo.h. Howevermdio-boardinfo.cincludedphy.hindirectly this way so far, include it explicitly instead. Whilst at it, sort the included headers properly.Signed-off-by Heiner Kallweit <[email protected]>
Andrew
Heiner Kallweit
maintainerPATCH 4/4 net: phy: directly copy struct mdio_board_info in mdiobus_register_board_info
In reply to Heiner KallweitUsing 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
@@ -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
Re: [PATCH net-next 4/4] net: phy: directly copy struct mdio_board_info in mdiobus_register_board_info
Quoted 4 lines · Heiner Kallweit
Using a direct assignment instead of memcpy reduces the text segment size from
0x273bytes to0x19bbytes in my case.Signed-off-by Heiner Kallweit <[email protected]>
Andrew
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: simplifymdiobus_setup_mdiodev_from_board_info
net: phy: move definition of structmdio_board_entryto
mdio-boardinfo.c
net: phy: improvemdio-boardinfo.h
net: phy: directly copy structmdio_board_infoin
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