Skip to content

Commit aa77b11

Browse files
oleremPaolo Abeni
authored andcommitted
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 <[email protected]> Acked-by: Arun Ramadoss <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 47c1301 commit aa77b11

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

drivers/net/dsa/microchip/lan937x_main.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,26 +374,33 @@ int lan937x_setup(struct dsa_switch *ds)
374374
ds->vlan_filtering_is_global = true;
375375

376376
/* 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;
380382

381383
/* If NO_EXC_COLLISION_DROP bit is set, the switch will not drop
382384
* packets when 16 or more collisions occur
383385
*/
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;
385389

386390
/* 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;
388394

389395
/* 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;
392400

393401
/* 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);
397404
}
398405

399406
void lan937x_teardown(struct dsa_switch *ds)

0 commit comments

Comments
 (0)