Commit 77c819cb authored by Oleksij Rempel's avatar Oleksij Rempel Committed by Jakub Kicinski
Browse files

net: dsa: microchip: Refactor switch shutdown routine for WoL preparation



Centralize the switch shutdown routine in a dedicated function,
ksz_switch_shutdown(), to enhance code maintainability and reduce
redundancy. This change abstracts the common shutdown operations
previously duplicated in ksz9477_i2c_shutdown() and ksz_spi_shutdown().

This refactoring is a preparatory step for an upcoming patch to avoid
reset on shutdown if Wake-on-LAN (WoL) is enabled.

Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20231026051051.2316937-5-o.rempel@pengutronix.de


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 818cdb0f
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -66,10 +66,7 @@ static void ksz9477_i2c_shutdown(struct i2c_client *i2c)
	if (!dev)
		return;

	if (dev->dev_ops->reset)
		dev->dev_ops->reset(dev);

	dsa_switch_shutdown(dev->ds);
	ksz_switch_shutdown(dev);

	i2c_set_clientdata(i2c, NULL);
}
+19 −0
Original line number Diff line number Diff line
@@ -3845,6 +3845,25 @@ struct ksz_device *ksz_switch_alloc(struct device *base, void *priv)
}
EXPORT_SYMBOL(ksz_switch_alloc);

/**
 * ksz_switch_shutdown - Shutdown routine for the switch device.
 * @dev: The switch device structure.
 *
 * This function is responsible for initiating a shutdown sequence for the
 * switch device. It invokes the reset operation defined in the device
 * operations, if available, to reset the switch. Subsequently, it calls the
 * DSA framework's shutdown function to ensure a proper shutdown of the DSA
 * switch.
 */
void ksz_switch_shutdown(struct ksz_device *dev)
{
	if (dev->dev_ops->reset)
		dev->dev_ops->reset(dev);

	dsa_switch_shutdown(dev->ds);
}
EXPORT_SYMBOL(ksz_switch_shutdown);

static void ksz_parse_rgmii_delay(struct ksz_device *dev, int port_num,
				  struct device_node *port_dn)
{
+1 −0
Original line number Diff line number Diff line
@@ -400,6 +400,7 @@ extern const struct ksz_chip_data ksz_switch_chips[];
int ksz_switch_macaddr_get(struct dsa_switch *ds, int port,
			   struct netlink_ext_ack *extack);
void ksz_switch_macaddr_put(struct dsa_switch *ds);
void ksz_switch_shutdown(struct ksz_device *dev);

/* Common register access functions */
static inline struct regmap *ksz_regmap_8(struct ksz_device *dev)
+1 −4
Original line number Diff line number Diff line
@@ -114,10 +114,7 @@ static void ksz_spi_shutdown(struct spi_device *spi)
	if (!dev)
		return;

	if (dev->dev_ops->reset)
		dev->dev_ops->reset(dev);

	dsa_switch_shutdown(dev->ds);
	ksz_switch_shutdown(dev);

	spi_set_drvdata(spi, NULL);
}