]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
net: phy: directly copy struct mdio_board_info in mdiobus_register_board_info
authorHeiner Kallweit <hkallweit1@gmail.com>
Wed, 11 Jun 2025 20:13:02 +0000 (22:13 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 13 Jun 2025 23:37:23 +0000 (16:37 -0700)
Using a direct assignment instead of memcpy reduces the text segment
size from 0x273 bytes to 0x19b bytes in my case.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/af371f2a-42f3-4d94-80b9-3420380a3f6f@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/mdio-boardinfo.c

index b1e7a59202f6ea3f154b1664f8b89a34927023a7..d3184e8f12ecd39060d3e4b204b5ba69a022a1e6 100644 (file)
@@ -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);