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

Configure Feed

Select the types of activity you want to include in your feed.

net: dsa: microchip: lan937x: Add error handling in lan937x_setup

Introduce error handling for lan937x_cfg function calls in lan937x_setup.
This change ensures that if any lan937x_cfg or ksz_rmw32 calls fails, the
function will return the appropriate error code.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
Acked-by: Arun Ramadoss <arun.ramadoss@microchip.com>
Link: https://patch.msgid.link/20240703083820.3152100-1-o.rempel@pengutronix.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Oleksij Rempel and committed by
Paolo Abeni
aa77b112 47c13013

+17 -10
+17 -10
drivers/net/dsa/microchip/lan937x_main.c
··· 374 374 ds->vlan_filtering_is_global = true; 375 375 376 376 /* Enable aggressive back off for half duplex & UNH mode */ 377 - lan937x_cfg(dev, REG_SW_MAC_CTRL_0, 378 - (SW_PAUSE_UNH_MODE | SW_NEW_BACKOFF | SW_AGGR_BACKOFF), 379 - true); 377 + ret = lan937x_cfg(dev, REG_SW_MAC_CTRL_0, (SW_PAUSE_UNH_MODE | 378 + SW_NEW_BACKOFF | 379 + SW_AGGR_BACKOFF), true); 380 + if (ret < 0) 381 + return ret; 380 382 381 383 /* If NO_EXC_COLLISION_DROP bit is set, the switch will not drop 382 384 * packets when 16 or more collisions occur 383 385 */ 384 - lan937x_cfg(dev, REG_SW_MAC_CTRL_1, NO_EXC_COLLISION_DROP, true); 386 + ret = lan937x_cfg(dev, REG_SW_MAC_CTRL_1, NO_EXC_COLLISION_DROP, true); 387 + if (ret < 0) 388 + return ret; 385 389 386 390 /* enable global MIB counter freeze function */ 387 - lan937x_cfg(dev, REG_SW_MAC_CTRL_6, SW_MIB_COUNTER_FREEZE, true); 391 + ret = lan937x_cfg(dev, REG_SW_MAC_CTRL_6, SW_MIB_COUNTER_FREEZE, true); 392 + if (ret < 0) 393 + return ret; 388 394 389 395 /* disable CLK125 & CLK25, 1: disable, 0: enable */ 390 - lan937x_cfg(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1, 391 - (SW_CLK125_ENB | SW_CLK25_ENB), true); 396 + ret = lan937x_cfg(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1, 397 + (SW_CLK125_ENB | SW_CLK25_ENB), true); 398 + if (ret < 0) 399 + return ret; 392 400 393 401 /* Disable global VPHY support. Related to CPU interface only? */ 394 - ksz_rmw32(dev, REG_SW_CFG_STRAP_OVR, SW_VPHY_DISABLE, SW_VPHY_DISABLE); 395 - 396 - return 0; 402 + return ksz_rmw32(dev, REG_SW_CFG_STRAP_OVR, SW_VPHY_DISABLE, 403 + SW_VPHY_DISABLE); 397 404 } 398 405 399 406 void lan937x_teardown(struct dsa_switch *ds)