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: Oleksij Rempel <o.rempel@pengutronix.de> Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://lore.kernel.org/r/20231026051051.2316937-5-o.rempel@pengutronix.de Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
818cdb0f4b
commit
77c819cb49
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue