Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: dsa: microchip: move REG_SW_MAC_ADDR to dev->info->regs[]

Defining macros which have the same name but different values is bad
practice, because it makes it hard to avoid code duplication. The same
code does different things, depending on the file it's placed in.
Case in point, we want to access REG_SW_MAC_ADDR from ksz_common.c, but
currently we can't, because we don't know which kszXXXX_reg.h to include
from the common code.

Remove the REG_SW_MAC_ADDR_{0..5} macros from ksz8795_reg.h and
ksz9477_reg.h, and re-add this register offset to the dev->info->regs[]
array.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Vladimir Oltean and committed by
Paolo Abeni
e5de2ad1 5e5db71a

+3 -14
-7
drivers/net/dsa/microchip/ksz8795_reg.h
··· 323 323 ((addr) + REG_PORT_1_CTRL_0 + (port) * \ 324 324 (REG_PORT_2_CTRL_0 - REG_PORT_1_CTRL_0)) 325 325 326 - #define REG_SW_MAC_ADDR_0 0x68 327 - #define REG_SW_MAC_ADDR_1 0x69 328 - #define REG_SW_MAC_ADDR_2 0x6A 329 - #define REG_SW_MAC_ADDR_3 0x6B 330 - #define REG_SW_MAC_ADDR_4 0x6C 331 - #define REG_SW_MAC_ADDR_5 0x6D 332 - 333 326 #define TABLE_EXT_SELECT_S 5 334 327 #define TABLE_EEE_V 1 335 328 #define TABLE_ACL_V 2
-7
drivers/net/dsa/microchip/ksz9477_reg.h
··· 153 153 #define SW_DOUBLE_TAG BIT(7) 154 154 #define SW_RESET BIT(1) 155 155 156 - #define REG_SW_MAC_ADDR_0 0x0302 157 - #define REG_SW_MAC_ADDR_1 0x0303 158 - #define REG_SW_MAC_ADDR_2 0x0304 159 - #define REG_SW_MAC_ADDR_3 0x0305 160 - #define REG_SW_MAC_ADDR_4 0x0306 161 - #define REG_SW_MAC_ADDR_5 0x0307 162 - 163 156 #define REG_SW_MTU__2 0x0308 164 157 #define REG_SW_MTU_MASK GENMASK(13, 0) 165 158
+2
drivers/net/dsa/microchip/ksz_common.c
··· 364 364 }; 365 365 366 366 static const u16 ksz8795_regs[] = { 367 + [REG_SW_MAC_ADDR] = 0x68, 367 368 [REG_IND_CTRL_0] = 0x6E, 368 369 [REG_IND_DATA_8] = 0x70, 369 370 [REG_IND_DATA_CHECK] = 0x72, ··· 493 492 }; 494 493 495 494 static const u16 ksz9477_regs[] = { 495 + [REG_SW_MAC_ADDR] = 0x0302, 496 496 [P_STP_CTRL] = 0x0B04, 497 497 [S_START_CTRL] = 0x0300, 498 498 [S_BROADCAST_CTRL] = 0x0332,
+1
drivers/net/dsa/microchip/ksz_common.h
··· 212 212 }; 213 213 214 214 enum ksz_regs { 215 + REG_SW_MAC_ADDR, 215 216 REG_IND_CTRL_0, 216 217 REG_IND_DATA_8, 217 218 REG_IND_DATA_CHECK,