mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-29 15:43:59 +08:00
Merge branch 'dsa-shutdown'
Vladimir Oltean says:
====================
Make DSA switch drivers compatible with masters which unregister on shutdown
Changes in v2:
- fix build for b53_mmap
- use unregister_netdevice_many
It was reported by Lino here:
https://lore.kernel.org/netdev/20210909095324.12978-1-LinoSanfilippo@gmx.de/
that when the DSA master attempts to unregister its net_device on
shutdown, DSA should prevent that operation from succeeding because it
holds a reference to it. This hangs the shutdown process.
This issue was essentially introduced in commit 2f1e8ea726
("net: dsa:
link interfaces with the DSA master to get rid of lockdep warnings").
The present series patches all DSA drivers to handle that case,
depending on whether those drivers were introduced before or after the
offending commit, a different Fixes: tag is specified for them.
The approach taken by this series solves the issue in essentially the
same way as Lino's patches, except for three key differences:
- this series takes a more minimal approach in what is done on shutdown,
we do not attempt a full tree teardown as that is not strictly
necessary. I might revisit this if there are compelling reasons to do
otherwise
- this series fixes the issues for all DSA drivers, not just KSZ9897
- this series works even if the ->remove driver method gets called for
the same device too, not just ->shutdown. This is really possible to
happen for SPI device drivers, and potentially possible for other bus
device drivers too.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
564df7ab10
@ -351,9 +351,25 @@ static int b53_mdio_probe(struct mdio_device *mdiodev)
|
|||||||
static void b53_mdio_remove(struct mdio_device *mdiodev)
|
static void b53_mdio_remove(struct mdio_device *mdiodev)
|
||||||
{
|
{
|
||||||
struct b53_device *dev = dev_get_drvdata(&mdiodev->dev);
|
struct b53_device *dev = dev_get_drvdata(&mdiodev->dev);
|
||||||
struct dsa_switch *ds = dev->ds;
|
|
||||||
|
|
||||||
dsa_unregister_switch(ds);
|
if (!dev)
|
||||||
|
return;
|
||||||
|
|
||||||
|
b53_switch_remove(dev);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void b53_mdio_shutdown(struct mdio_device *mdiodev)
|
||||||
|
{
|
||||||
|
struct b53_device *dev = dev_get_drvdata(&mdiodev->dev);
|
||||||
|
|
||||||
|
if (!dev)
|
||||||
|
return;
|
||||||
|
|
||||||
|
b53_switch_shutdown(dev);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id b53_of_match[] = {
|
static const struct of_device_id b53_of_match[] = {
|
||||||
@ -373,6 +389,7 @@ MODULE_DEVICE_TABLE(of, b53_of_match);
|
|||||||
static struct mdio_driver b53_mdio_driver = {
|
static struct mdio_driver b53_mdio_driver = {
|
||||||
.probe = b53_mdio_probe,
|
.probe = b53_mdio_probe,
|
||||||
.remove = b53_mdio_remove,
|
.remove = b53_mdio_remove,
|
||||||
|
.shutdown = b53_mdio_shutdown,
|
||||||
.mdiodrv.driver = {
|
.mdiodrv.driver = {
|
||||||
.name = "bcm53xx",
|
.name = "bcm53xx",
|
||||||
.of_match_table = b53_of_match,
|
.of_match_table = b53_of_match,
|
||||||
|
@ -316,9 +316,21 @@ static int b53_mmap_remove(struct platform_device *pdev)
|
|||||||
if (dev)
|
if (dev)
|
||||||
b53_switch_remove(dev);
|
b53_switch_remove(dev);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void b53_mmap_shutdown(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
struct b53_device *dev = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
if (dev)
|
||||||
|
b53_switch_shutdown(dev);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct of_device_id b53_mmap_of_table[] = {
|
static const struct of_device_id b53_mmap_of_table[] = {
|
||||||
{ .compatible = "brcm,bcm3384-switch" },
|
{ .compatible = "brcm,bcm3384-switch" },
|
||||||
{ .compatible = "brcm,bcm6328-switch" },
|
{ .compatible = "brcm,bcm6328-switch" },
|
||||||
@ -331,6 +343,7 @@ MODULE_DEVICE_TABLE(of, b53_mmap_of_table);
|
|||||||
static struct platform_driver b53_mmap_driver = {
|
static struct platform_driver b53_mmap_driver = {
|
||||||
.probe = b53_mmap_probe,
|
.probe = b53_mmap_probe,
|
||||||
.remove = b53_mmap_remove,
|
.remove = b53_mmap_remove,
|
||||||
|
.shutdown = b53_mmap_shutdown,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "b53-switch",
|
.name = "b53-switch",
|
||||||
.of_match_table = b53_mmap_of_table,
|
.of_match_table = b53_mmap_of_table,
|
||||||
|
@ -228,6 +228,11 @@ static inline void b53_switch_remove(struct b53_device *dev)
|
|||||||
dsa_unregister_switch(dev->ds);
|
dsa_unregister_switch(dev->ds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void b53_switch_shutdown(struct b53_device *dev)
|
||||||
|
{
|
||||||
|
dsa_switch_shutdown(dev->ds);
|
||||||
|
}
|
||||||
|
|
||||||
#define b53_build_op(type_op_size, val_type) \
|
#define b53_build_op(type_op_size, val_type) \
|
||||||
static inline int b53_##type_op_size(struct b53_device *dev, u8 page, \
|
static inline int b53_##type_op_size(struct b53_device *dev, u8 page, \
|
||||||
u8 reg, val_type val) \
|
u8 reg, val_type val) \
|
||||||
|
@ -321,9 +321,21 @@ static int b53_spi_remove(struct spi_device *spi)
|
|||||||
if (dev)
|
if (dev)
|
||||||
b53_switch_remove(dev);
|
b53_switch_remove(dev);
|
||||||
|
|
||||||
|
spi_set_drvdata(spi, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void b53_spi_shutdown(struct spi_device *spi)
|
||||||
|
{
|
||||||
|
struct b53_device *dev = spi_get_drvdata(spi);
|
||||||
|
|
||||||
|
if (dev)
|
||||||
|
b53_switch_shutdown(dev);
|
||||||
|
|
||||||
|
spi_set_drvdata(spi, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct of_device_id b53_spi_of_match[] = {
|
static const struct of_device_id b53_spi_of_match[] = {
|
||||||
{ .compatible = "brcm,bcm5325" },
|
{ .compatible = "brcm,bcm5325" },
|
||||||
{ .compatible = "brcm,bcm5365" },
|
{ .compatible = "brcm,bcm5365" },
|
||||||
@ -344,6 +356,7 @@ static struct spi_driver b53_spi_driver = {
|
|||||||
},
|
},
|
||||||
.probe = b53_spi_probe,
|
.probe = b53_spi_probe,
|
||||||
.remove = b53_spi_remove,
|
.remove = b53_spi_remove,
|
||||||
|
.shutdown = b53_spi_shutdown,
|
||||||
};
|
};
|
||||||
|
|
||||||
module_spi_driver(b53_spi_driver);
|
module_spi_driver(b53_spi_driver);
|
||||||
|
@ -629,17 +629,34 @@ static int b53_srab_probe(struct platform_device *pdev)
|
|||||||
static int b53_srab_remove(struct platform_device *pdev)
|
static int b53_srab_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct b53_device *dev = platform_get_drvdata(pdev);
|
struct b53_device *dev = platform_get_drvdata(pdev);
|
||||||
struct b53_srab_priv *priv = dev->priv;
|
|
||||||
|
|
||||||
b53_srab_intr_set(priv, false);
|
if (!dev)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
b53_srab_intr_set(dev->priv, false);
|
||||||
b53_switch_remove(dev);
|
b53_switch_remove(dev);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void b53_srab_shutdown(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
struct b53_device *dev = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
if (!dev)
|
||||||
|
return;
|
||||||
|
|
||||||
|
b53_switch_shutdown(dev);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static struct platform_driver b53_srab_driver = {
|
static struct platform_driver b53_srab_driver = {
|
||||||
.probe = b53_srab_probe,
|
.probe = b53_srab_probe,
|
||||||
.remove = b53_srab_remove,
|
.remove = b53_srab_remove,
|
||||||
|
.shutdown = b53_srab_shutdown,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "b53-srab-switch",
|
.name = "b53-srab-switch",
|
||||||
.of_match_table = b53_srab_of_match,
|
.of_match_table = b53_srab_of_match,
|
||||||
|
@ -1512,6 +1512,9 @@ static int bcm_sf2_sw_remove(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
struct bcm_sf2_priv *priv = platform_get_drvdata(pdev);
|
struct bcm_sf2_priv *priv = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return 0;
|
||||||
|
|
||||||
priv->wol_ports_mask = 0;
|
priv->wol_ports_mask = 0;
|
||||||
/* Disable interrupts */
|
/* Disable interrupts */
|
||||||
bcm_sf2_intr_disable(priv);
|
bcm_sf2_intr_disable(priv);
|
||||||
@ -1523,6 +1526,8 @@ static int bcm_sf2_sw_remove(struct platform_device *pdev)
|
|||||||
if (priv->type == BCM7278_DEVICE_ID)
|
if (priv->type == BCM7278_DEVICE_ID)
|
||||||
reset_control_assert(priv->rcdev);
|
reset_control_assert(priv->rcdev);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1530,6 +1535,9 @@ static void bcm_sf2_sw_shutdown(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
struct bcm_sf2_priv *priv = platform_get_drvdata(pdev);
|
struct bcm_sf2_priv *priv = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return;
|
||||||
|
|
||||||
/* For a kernel about to be kexec'd we want to keep the GPHY on for a
|
/* For a kernel about to be kexec'd we want to keep the GPHY on for a
|
||||||
* successful MDIO bus scan to occur. If we did turn off the GPHY
|
* successful MDIO bus scan to occur. If we did turn off the GPHY
|
||||||
* before (e.g: port_disable), this will also power it back on.
|
* before (e.g: port_disable), this will also power it back on.
|
||||||
@ -1538,6 +1546,10 @@ static void bcm_sf2_sw_shutdown(struct platform_device *pdev)
|
|||||||
*/
|
*/
|
||||||
if (priv->hw_params.num_gphy == 1)
|
if (priv->hw_params.num_gphy == 1)
|
||||||
bcm_sf2_gphy_enable_set(priv->dev->ds, true);
|
bcm_sf2_gphy_enable_set(priv->dev->ds, true);
|
||||||
|
|
||||||
|
dsa_switch_shutdown(priv->dev->ds);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PM_SLEEP
|
#ifdef CONFIG_PM_SLEEP
|
||||||
|
@ -340,10 +340,29 @@ static int dsa_loop_drv_probe(struct mdio_device *mdiodev)
|
|||||||
static void dsa_loop_drv_remove(struct mdio_device *mdiodev)
|
static void dsa_loop_drv_remove(struct mdio_device *mdiodev)
|
||||||
{
|
{
|
||||||
struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
|
struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
|
||||||
struct dsa_loop_priv *ps = ds->priv;
|
struct dsa_loop_priv *ps;
|
||||||
|
|
||||||
|
if (!ds)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ps = ds->priv;
|
||||||
|
|
||||||
dsa_unregister_switch(ds);
|
dsa_unregister_switch(ds);
|
||||||
dev_put(ps->netdev);
|
dev_put(ps->netdev);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dsa_loop_drv_shutdown(struct mdio_device *mdiodev)
|
||||||
|
{
|
||||||
|
struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
|
||||||
|
|
||||||
|
if (!ds)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dsa_switch_shutdown(ds);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct mdio_driver dsa_loop_drv = {
|
static struct mdio_driver dsa_loop_drv = {
|
||||||
@ -352,6 +371,7 @@ static struct mdio_driver dsa_loop_drv = {
|
|||||||
},
|
},
|
||||||
.probe = dsa_loop_drv_probe,
|
.probe = dsa_loop_drv_probe,
|
||||||
.remove = dsa_loop_drv_remove,
|
.remove = dsa_loop_drv_remove,
|
||||||
|
.shutdown = dsa_loop_drv_shutdown,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define NUM_FIXED_PHYS (DSA_LOOP_NUM_PORTS - 2)
|
#define NUM_FIXED_PHYS (DSA_LOOP_NUM_PORTS - 2)
|
||||||
|
@ -1916,6 +1916,9 @@ static int hellcreek_remove(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
struct hellcreek *hellcreek = platform_get_drvdata(pdev);
|
struct hellcreek *hellcreek = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
if (!hellcreek)
|
||||||
|
return 0;
|
||||||
|
|
||||||
hellcreek_hwtstamp_free(hellcreek);
|
hellcreek_hwtstamp_free(hellcreek);
|
||||||
hellcreek_ptp_free(hellcreek);
|
hellcreek_ptp_free(hellcreek);
|
||||||
dsa_unregister_switch(hellcreek->ds);
|
dsa_unregister_switch(hellcreek->ds);
|
||||||
@ -1924,6 +1927,18 @@ static int hellcreek_remove(struct platform_device *pdev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void hellcreek_shutdown(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
struct hellcreek *hellcreek = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
if (!hellcreek)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dsa_switch_shutdown(hellcreek->ds);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct hellcreek_platform_data de1soc_r1_pdata = {
|
static const struct hellcreek_platform_data de1soc_r1_pdata = {
|
||||||
.name = "r4c30",
|
.name = "r4c30",
|
||||||
.num_ports = 4,
|
.num_ports = 4,
|
||||||
@ -1946,6 +1961,7 @@ MODULE_DEVICE_TABLE(of, hellcreek_of_match);
|
|||||||
static struct platform_driver hellcreek_driver = {
|
static struct platform_driver hellcreek_driver = {
|
||||||
.probe = hellcreek_probe,
|
.probe = hellcreek_probe,
|
||||||
.remove = hellcreek_remove,
|
.remove = hellcreek_remove,
|
||||||
|
.shutdown = hellcreek_shutdown,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "hellcreek",
|
.name = "hellcreek",
|
||||||
.of_match_table = hellcreek_of_match,
|
.of_match_table = hellcreek_of_match,
|
||||||
|
@ -1379,6 +1379,12 @@ int lan9303_remove(struct lan9303 *chip)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(lan9303_remove);
|
EXPORT_SYMBOL(lan9303_remove);
|
||||||
|
|
||||||
|
void lan9303_shutdown(struct lan9303 *chip)
|
||||||
|
{
|
||||||
|
dsa_switch_shutdown(chip->ds);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(lan9303_shutdown);
|
||||||
|
|
||||||
MODULE_AUTHOR("Juergen Borleis <kernel@pengutronix.de>");
|
MODULE_AUTHOR("Juergen Borleis <kernel@pengutronix.de>");
|
||||||
MODULE_DESCRIPTION("Core driver for SMSC/Microchip LAN9303 three port ethernet switch");
|
MODULE_DESCRIPTION("Core driver for SMSC/Microchip LAN9303 three port ethernet switch");
|
||||||
MODULE_LICENSE("GPL v2");
|
MODULE_LICENSE("GPL v2");
|
||||||
|
@ -10,3 +10,4 @@ extern const struct lan9303_phy_ops lan9303_indirect_phy_ops;
|
|||||||
|
|
||||||
int lan9303_probe(struct lan9303 *chip, struct device_node *np);
|
int lan9303_probe(struct lan9303 *chip, struct device_node *np);
|
||||||
int lan9303_remove(struct lan9303 *chip);
|
int lan9303_remove(struct lan9303 *chip);
|
||||||
|
void lan9303_shutdown(struct lan9303 *chip);
|
||||||
|
@ -67,13 +67,28 @@ static int lan9303_i2c_probe(struct i2c_client *client,
|
|||||||
|
|
||||||
static int lan9303_i2c_remove(struct i2c_client *client)
|
static int lan9303_i2c_remove(struct i2c_client *client)
|
||||||
{
|
{
|
||||||
struct lan9303_i2c *sw_dev;
|
struct lan9303_i2c *sw_dev = i2c_get_clientdata(client);
|
||||||
|
|
||||||
sw_dev = i2c_get_clientdata(client);
|
|
||||||
if (!sw_dev)
|
if (!sw_dev)
|
||||||
return -ENODEV;
|
return 0;
|
||||||
|
|
||||||
return lan9303_remove(&sw_dev->chip);
|
lan9303_remove(&sw_dev->chip);
|
||||||
|
|
||||||
|
i2c_set_clientdata(client, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lan9303_i2c_shutdown(struct i2c_client *client)
|
||||||
|
{
|
||||||
|
struct lan9303_i2c *sw_dev = i2c_get_clientdata(client);
|
||||||
|
|
||||||
|
if (!sw_dev)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lan9303_shutdown(&sw_dev->chip);
|
||||||
|
|
||||||
|
i2c_set_clientdata(client, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
@ -97,6 +112,7 @@ static struct i2c_driver lan9303_i2c_driver = {
|
|||||||
},
|
},
|
||||||
.probe = lan9303_i2c_probe,
|
.probe = lan9303_i2c_probe,
|
||||||
.remove = lan9303_i2c_remove,
|
.remove = lan9303_i2c_remove,
|
||||||
|
.shutdown = lan9303_i2c_shutdown,
|
||||||
.id_table = lan9303_i2c_id,
|
.id_table = lan9303_i2c_id,
|
||||||
};
|
};
|
||||||
module_i2c_driver(lan9303_i2c_driver);
|
module_i2c_driver(lan9303_i2c_driver);
|
||||||
|
@ -138,6 +138,20 @@ static void lan9303_mdio_remove(struct mdio_device *mdiodev)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
lan9303_remove(&sw_dev->chip);
|
lan9303_remove(&sw_dev->chip);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void lan9303_mdio_shutdown(struct mdio_device *mdiodev)
|
||||||
|
{
|
||||||
|
struct lan9303_mdio *sw_dev = dev_get_drvdata(&mdiodev->dev);
|
||||||
|
|
||||||
|
if (!sw_dev)
|
||||||
|
return;
|
||||||
|
|
||||||
|
lan9303_shutdown(&sw_dev->chip);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
@ -155,6 +169,7 @@ static struct mdio_driver lan9303_mdio_driver = {
|
|||||||
},
|
},
|
||||||
.probe = lan9303_mdio_probe,
|
.probe = lan9303_mdio_probe,
|
||||||
.remove = lan9303_mdio_remove,
|
.remove = lan9303_mdio_remove,
|
||||||
|
.shutdown = lan9303_mdio_shutdown,
|
||||||
};
|
};
|
||||||
mdio_module_driver(lan9303_mdio_driver);
|
mdio_module_driver(lan9303_mdio_driver);
|
||||||
|
|
||||||
|
@ -2184,6 +2184,9 @@ static int gswip_remove(struct platform_device *pdev)
|
|||||||
struct gswip_priv *priv = platform_get_drvdata(pdev);
|
struct gswip_priv *priv = platform_get_drvdata(pdev);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* disable the switch */
|
/* disable the switch */
|
||||||
gswip_mdio_mask(priv, GSWIP_MDIO_GLOB_ENABLE, 0, GSWIP_MDIO_GLOB);
|
gswip_mdio_mask(priv, GSWIP_MDIO_GLOB_ENABLE, 0, GSWIP_MDIO_GLOB);
|
||||||
|
|
||||||
@ -2197,9 +2200,23 @@ static int gswip_remove(struct platform_device *pdev)
|
|||||||
for (i = 0; i < priv->num_gphy_fw; i++)
|
for (i = 0; i < priv->num_gphy_fw; i++)
|
||||||
gswip_gphy_fw_remove(priv, &priv->gphy_fw[i]);
|
gswip_gphy_fw_remove(priv, &priv->gphy_fw[i]);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void gswip_shutdown(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
struct gswip_priv *priv = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dsa_switch_shutdown(priv->ds);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct gswip_hw_info gswip_xrx200 = {
|
static const struct gswip_hw_info gswip_xrx200 = {
|
||||||
.max_ports = 7,
|
.max_ports = 7,
|
||||||
.cpu_port = 6,
|
.cpu_port = 6,
|
||||||
@ -2223,6 +2240,7 @@ MODULE_DEVICE_TABLE(of, gswip_of_match);
|
|||||||
static struct platform_driver gswip_driver = {
|
static struct platform_driver gswip_driver = {
|
||||||
.probe = gswip_probe,
|
.probe = gswip_probe,
|
||||||
.remove = gswip_remove,
|
.remove = gswip_remove,
|
||||||
|
.shutdown = gswip_shutdown,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "gswip",
|
.name = "gswip",
|
||||||
.of_match_table = gswip_of_match,
|
.of_match_table = gswip_of_match,
|
||||||
|
@ -94,6 +94,8 @@ static int ksz8795_spi_remove(struct spi_device *spi)
|
|||||||
if (dev)
|
if (dev)
|
||||||
ksz_switch_remove(dev);
|
ksz_switch_remove(dev);
|
||||||
|
|
||||||
|
spi_set_drvdata(spi, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,8 +103,15 @@ static void ksz8795_spi_shutdown(struct spi_device *spi)
|
|||||||
{
|
{
|
||||||
struct ksz_device *dev = spi_get_drvdata(spi);
|
struct ksz_device *dev = spi_get_drvdata(spi);
|
||||||
|
|
||||||
if (dev && dev->dev_ops->shutdown)
|
if (!dev)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (dev->dev_ops->shutdown)
|
||||||
dev->dev_ops->shutdown(dev);
|
dev->dev_ops->shutdown(dev);
|
||||||
|
|
||||||
|
dsa_switch_shutdown(dev->ds);
|
||||||
|
|
||||||
|
spi_set_drvdata(spi, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id ksz8795_dt_ids[] = {
|
static const struct of_device_id ksz8795_dt_ids[] = {
|
||||||
|
@ -191,6 +191,18 @@ static void ksz8863_smi_remove(struct mdio_device *mdiodev)
|
|||||||
|
|
||||||
if (dev)
|
if (dev)
|
||||||
ksz_switch_remove(dev);
|
ksz_switch_remove(dev);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ksz8863_smi_shutdown(struct mdio_device *mdiodev)
|
||||||
|
{
|
||||||
|
struct ksz_device *dev = dev_get_drvdata(&mdiodev->dev);
|
||||||
|
|
||||||
|
if (dev)
|
||||||
|
dsa_switch_shutdown(dev->ds);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id ksz8863_dt_ids[] = {
|
static const struct of_device_id ksz8863_dt_ids[] = {
|
||||||
@ -203,6 +215,7 @@ MODULE_DEVICE_TABLE(of, ksz8863_dt_ids);
|
|||||||
static struct mdio_driver ksz8863_driver = {
|
static struct mdio_driver ksz8863_driver = {
|
||||||
.probe = ksz8863_smi_probe,
|
.probe = ksz8863_smi_probe,
|
||||||
.remove = ksz8863_smi_remove,
|
.remove = ksz8863_smi_remove,
|
||||||
|
.shutdown = ksz8863_smi_shutdown,
|
||||||
.mdiodrv.driver = {
|
.mdiodrv.driver = {
|
||||||
.name = "ksz8863-switch",
|
.name = "ksz8863-switch",
|
||||||
.of_match_table = ksz8863_dt_ids,
|
.of_match_table = ksz8863_dt_ids,
|
||||||
|
@ -56,7 +56,10 @@ static int ksz9477_i2c_remove(struct i2c_client *i2c)
|
|||||||
{
|
{
|
||||||
struct ksz_device *dev = i2c_get_clientdata(i2c);
|
struct ksz_device *dev = i2c_get_clientdata(i2c);
|
||||||
|
|
||||||
ksz_switch_remove(dev);
|
if (dev)
|
||||||
|
ksz_switch_remove(dev);
|
||||||
|
|
||||||
|
i2c_set_clientdata(i2c, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -65,8 +68,15 @@ static void ksz9477_i2c_shutdown(struct i2c_client *i2c)
|
|||||||
{
|
{
|
||||||
struct ksz_device *dev = i2c_get_clientdata(i2c);
|
struct ksz_device *dev = i2c_get_clientdata(i2c);
|
||||||
|
|
||||||
if (dev && dev->dev_ops->shutdown)
|
if (!dev)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (dev->dev_ops->shutdown)
|
||||||
dev->dev_ops->shutdown(dev);
|
dev->dev_ops->shutdown(dev);
|
||||||
|
|
||||||
|
dsa_switch_shutdown(dev->ds);
|
||||||
|
|
||||||
|
i2c_set_clientdata(i2c, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct i2c_device_id ksz9477_i2c_id[] = {
|
static const struct i2c_device_id ksz9477_i2c_id[] = {
|
||||||
|
@ -72,6 +72,8 @@ static int ksz9477_spi_remove(struct spi_device *spi)
|
|||||||
if (dev)
|
if (dev)
|
||||||
ksz_switch_remove(dev);
|
ksz_switch_remove(dev);
|
||||||
|
|
||||||
|
spi_set_drvdata(spi, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,8 +81,10 @@ static void ksz9477_spi_shutdown(struct spi_device *spi)
|
|||||||
{
|
{
|
||||||
struct ksz_device *dev = spi_get_drvdata(spi);
|
struct ksz_device *dev = spi_get_drvdata(spi);
|
||||||
|
|
||||||
if (dev && dev->dev_ops->shutdown)
|
if (dev)
|
||||||
dev->dev_ops->shutdown(dev);
|
dsa_switch_shutdown(dev->ds);
|
||||||
|
|
||||||
|
spi_set_drvdata(spi, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id ksz9477_dt_ids[] = {
|
static const struct of_device_id ksz9477_dt_ids[] = {
|
||||||
|
@ -3286,6 +3286,9 @@ mt7530_remove(struct mdio_device *mdiodev)
|
|||||||
struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return;
|
||||||
|
|
||||||
ret = regulator_disable(priv->core_pwr);
|
ret = regulator_disable(priv->core_pwr);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
dev_err(priv->dev,
|
dev_err(priv->dev,
|
||||||
@ -3301,11 +3304,26 @@ mt7530_remove(struct mdio_device *mdiodev)
|
|||||||
|
|
||||||
dsa_unregister_switch(priv->ds);
|
dsa_unregister_switch(priv->ds);
|
||||||
mutex_destroy(&priv->reg_mutex);
|
mutex_destroy(&priv->reg_mutex);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mt7530_shutdown(struct mdio_device *mdiodev)
|
||||||
|
{
|
||||||
|
struct mt7530_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dsa_switch_shutdown(priv->ds);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct mdio_driver mt7530_mdio_driver = {
|
static struct mdio_driver mt7530_mdio_driver = {
|
||||||
.probe = mt7530_probe,
|
.probe = mt7530_probe,
|
||||||
.remove = mt7530_remove,
|
.remove = mt7530_remove,
|
||||||
|
.shutdown = mt7530_shutdown,
|
||||||
.mdiodrv.driver = {
|
.mdiodrv.driver = {
|
||||||
.name = "mt7530",
|
.name = "mt7530",
|
||||||
.of_match_table = mt7530_of_match,
|
.of_match_table = mt7530_of_match,
|
||||||
|
@ -290,7 +290,24 @@ static void mv88e6060_remove(struct mdio_device *mdiodev)
|
|||||||
{
|
{
|
||||||
struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
|
struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
|
||||||
|
|
||||||
|
if (!ds)
|
||||||
|
return;
|
||||||
|
|
||||||
dsa_unregister_switch(ds);
|
dsa_unregister_switch(ds);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mv88e6060_shutdown(struct mdio_device *mdiodev)
|
||||||
|
{
|
||||||
|
struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
|
||||||
|
|
||||||
|
if (!ds)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dsa_switch_shutdown(ds);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id mv88e6060_of_match[] = {
|
static const struct of_device_id mv88e6060_of_match[] = {
|
||||||
@ -303,6 +320,7 @@ static const struct of_device_id mv88e6060_of_match[] = {
|
|||||||
static struct mdio_driver mv88e6060_driver = {
|
static struct mdio_driver mv88e6060_driver = {
|
||||||
.probe = mv88e6060_probe,
|
.probe = mv88e6060_probe,
|
||||||
.remove = mv88e6060_remove,
|
.remove = mv88e6060_remove,
|
||||||
|
.shutdown = mv88e6060_shutdown,
|
||||||
.mdiodrv.driver = {
|
.mdiodrv.driver = {
|
||||||
.name = "mv88e6060",
|
.name = "mv88e6060",
|
||||||
.of_match_table = mv88e6060_of_match,
|
.of_match_table = mv88e6060_of_match,
|
||||||
|
@ -6389,7 +6389,12 @@ out:
|
|||||||
static void mv88e6xxx_remove(struct mdio_device *mdiodev)
|
static void mv88e6xxx_remove(struct mdio_device *mdiodev)
|
||||||
{
|
{
|
||||||
struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
|
struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
|
||||||
struct mv88e6xxx_chip *chip = ds->priv;
|
struct mv88e6xxx_chip *chip;
|
||||||
|
|
||||||
|
if (!ds)
|
||||||
|
return;
|
||||||
|
|
||||||
|
chip = ds->priv;
|
||||||
|
|
||||||
if (chip->info->ptp_support) {
|
if (chip->info->ptp_support) {
|
||||||
mv88e6xxx_hwtstamp_free(chip);
|
mv88e6xxx_hwtstamp_free(chip);
|
||||||
@ -6410,6 +6415,20 @@ static void mv88e6xxx_remove(struct mdio_device *mdiodev)
|
|||||||
mv88e6xxx_g1_irq_free(chip);
|
mv88e6xxx_g1_irq_free(chip);
|
||||||
else
|
else
|
||||||
mv88e6xxx_irq_poll_free(chip);
|
mv88e6xxx_irq_poll_free(chip);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mv88e6xxx_shutdown(struct mdio_device *mdiodev)
|
||||||
|
{
|
||||||
|
struct dsa_switch *ds = dev_get_drvdata(&mdiodev->dev);
|
||||||
|
|
||||||
|
if (!ds)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dsa_switch_shutdown(ds);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id mv88e6xxx_of_match[] = {
|
static const struct of_device_id mv88e6xxx_of_match[] = {
|
||||||
@ -6433,6 +6452,7 @@ MODULE_DEVICE_TABLE(of, mv88e6xxx_of_match);
|
|||||||
static struct mdio_driver mv88e6xxx_driver = {
|
static struct mdio_driver mv88e6xxx_driver = {
|
||||||
.probe = mv88e6xxx_probe,
|
.probe = mv88e6xxx_probe,
|
||||||
.remove = mv88e6xxx_remove,
|
.remove = mv88e6xxx_remove,
|
||||||
|
.shutdown = mv88e6xxx_shutdown,
|
||||||
.mdiodrv.driver = {
|
.mdiodrv.driver = {
|
||||||
.name = "mv88e6085",
|
.name = "mv88e6085",
|
||||||
.of_match_table = mv88e6xxx_of_match,
|
.of_match_table = mv88e6xxx_of_match,
|
||||||
|
@ -1472,9 +1472,10 @@ err_pci_enable:
|
|||||||
|
|
||||||
static void felix_pci_remove(struct pci_dev *pdev)
|
static void felix_pci_remove(struct pci_dev *pdev)
|
||||||
{
|
{
|
||||||
struct felix *felix;
|
struct felix *felix = pci_get_drvdata(pdev);
|
||||||
|
|
||||||
felix = pci_get_drvdata(pdev);
|
if (!felix)
|
||||||
|
return;
|
||||||
|
|
||||||
dsa_unregister_switch(felix->ds);
|
dsa_unregister_switch(felix->ds);
|
||||||
|
|
||||||
@ -1482,6 +1483,20 @@ static void felix_pci_remove(struct pci_dev *pdev)
|
|||||||
kfree(felix);
|
kfree(felix);
|
||||||
|
|
||||||
pci_disable_device(pdev);
|
pci_disable_device(pdev);
|
||||||
|
|
||||||
|
pci_set_drvdata(pdev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void felix_pci_shutdown(struct pci_dev *pdev)
|
||||||
|
{
|
||||||
|
struct felix *felix = pci_get_drvdata(pdev);
|
||||||
|
|
||||||
|
if (!felix)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dsa_switch_shutdown(felix->ds);
|
||||||
|
|
||||||
|
pci_set_drvdata(pdev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct pci_device_id felix_ids[] = {
|
static struct pci_device_id felix_ids[] = {
|
||||||
@ -1498,6 +1513,7 @@ static struct pci_driver felix_vsc9959_pci_driver = {
|
|||||||
.id_table = felix_ids,
|
.id_table = felix_ids,
|
||||||
.probe = felix_pci_probe,
|
.probe = felix_pci_probe,
|
||||||
.remove = felix_pci_remove,
|
.remove = felix_pci_remove,
|
||||||
|
.shutdown = felix_pci_shutdown,
|
||||||
};
|
};
|
||||||
module_pci_driver(felix_vsc9959_pci_driver);
|
module_pci_driver(felix_vsc9959_pci_driver);
|
||||||
|
|
||||||
|
@ -1245,18 +1245,33 @@ err_alloc_felix:
|
|||||||
|
|
||||||
static int seville_remove(struct platform_device *pdev)
|
static int seville_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct felix *felix;
|
struct felix *felix = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
felix = platform_get_drvdata(pdev);
|
if (!felix)
|
||||||
|
return 0;
|
||||||
|
|
||||||
dsa_unregister_switch(felix->ds);
|
dsa_unregister_switch(felix->ds);
|
||||||
|
|
||||||
kfree(felix->ds);
|
kfree(felix->ds);
|
||||||
kfree(felix);
|
kfree(felix);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void seville_shutdown(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
struct felix *felix = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
if (!felix)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dsa_switch_shutdown(felix->ds);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct of_device_id seville_of_match[] = {
|
static const struct of_device_id seville_of_match[] = {
|
||||||
{ .compatible = "mscc,vsc9953-switch" },
|
{ .compatible = "mscc,vsc9953-switch" },
|
||||||
{ },
|
{ },
|
||||||
@ -1266,6 +1281,7 @@ MODULE_DEVICE_TABLE(of, seville_of_match);
|
|||||||
static struct platform_driver seville_vsc9953_driver = {
|
static struct platform_driver seville_vsc9953_driver = {
|
||||||
.probe = seville_probe,
|
.probe = seville_probe,
|
||||||
.remove = seville_remove,
|
.remove = seville_remove,
|
||||||
|
.shutdown = seville_shutdown,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "mscc_seville",
|
.name = "mscc_seville",
|
||||||
.of_match_table = of_match_ptr(seville_of_match),
|
.of_match_table = of_match_ptr(seville_of_match),
|
||||||
|
@ -1083,6 +1083,9 @@ static void ar9331_sw_remove(struct mdio_device *mdiodev)
|
|||||||
struct ar9331_sw_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
struct ar9331_sw_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(priv->port); i++) {
|
for (i = 0; i < ARRAY_SIZE(priv->port); i++) {
|
||||||
struct ar9331_sw_port *port = &priv->port[i];
|
struct ar9331_sw_port *port = &priv->port[i];
|
||||||
|
|
||||||
@ -1094,6 +1097,20 @@ static void ar9331_sw_remove(struct mdio_device *mdiodev)
|
|||||||
dsa_unregister_switch(&priv->ds);
|
dsa_unregister_switch(&priv->ds);
|
||||||
|
|
||||||
reset_control_assert(priv->sw_reset);
|
reset_control_assert(priv->sw_reset);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ar9331_sw_shutdown(struct mdio_device *mdiodev)
|
||||||
|
{
|
||||||
|
struct ar9331_sw_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dsa_switch_shutdown(&priv->ds);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id ar9331_sw_of_match[] = {
|
static const struct of_device_id ar9331_sw_of_match[] = {
|
||||||
@ -1104,6 +1121,7 @@ static const struct of_device_id ar9331_sw_of_match[] = {
|
|||||||
static struct mdio_driver ar9331_sw_mdio_driver = {
|
static struct mdio_driver ar9331_sw_mdio_driver = {
|
||||||
.probe = ar9331_sw_probe,
|
.probe = ar9331_sw_probe,
|
||||||
.remove = ar9331_sw_remove,
|
.remove = ar9331_sw_remove,
|
||||||
|
.shutdown = ar9331_sw_shutdown,
|
||||||
.mdiodrv.driver = {
|
.mdiodrv.driver = {
|
||||||
.name = AR9331_SW_NAME,
|
.name = AR9331_SW_NAME,
|
||||||
.of_match_table = ar9331_sw_of_match,
|
.of_match_table = ar9331_sw_of_match,
|
||||||
|
@ -1880,10 +1880,27 @@ qca8k_sw_remove(struct mdio_device *mdiodev)
|
|||||||
struct qca8k_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
struct qca8k_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return;
|
||||||
|
|
||||||
for (i = 0; i < QCA8K_NUM_PORTS; i++)
|
for (i = 0; i < QCA8K_NUM_PORTS; i++)
|
||||||
qca8k_port_set_status(priv, i, 0);
|
qca8k_port_set_status(priv, i, 0);
|
||||||
|
|
||||||
dsa_unregister_switch(priv->ds);
|
dsa_unregister_switch(priv->ds);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void qca8k_sw_shutdown(struct mdio_device *mdiodev)
|
||||||
|
{
|
||||||
|
struct qca8k_priv *priv = dev_get_drvdata(&mdiodev->dev);
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dsa_switch_shutdown(priv->ds);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PM_SLEEP
|
#ifdef CONFIG_PM_SLEEP
|
||||||
@ -1940,6 +1957,7 @@ static const struct of_device_id qca8k_of_match[] = {
|
|||||||
static struct mdio_driver qca8kmdio_driver = {
|
static struct mdio_driver qca8kmdio_driver = {
|
||||||
.probe = qca8k_sw_probe,
|
.probe = qca8k_sw_probe,
|
||||||
.remove = qca8k_sw_remove,
|
.remove = qca8k_sw_remove,
|
||||||
|
.shutdown = qca8k_sw_shutdown,
|
||||||
.mdiodrv.driver = {
|
.mdiodrv.driver = {
|
||||||
.name = "qca8k",
|
.name = "qca8k",
|
||||||
.of_match_table = qca8k_of_match,
|
.of_match_table = qca8k_of_match,
|
||||||
|
@ -464,16 +464,33 @@ static int realtek_smi_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
static int realtek_smi_remove(struct platform_device *pdev)
|
static int realtek_smi_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct realtek_smi *smi = dev_get_drvdata(&pdev->dev);
|
struct realtek_smi *smi = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
if (!smi)
|
||||||
|
return 0;
|
||||||
|
|
||||||
dsa_unregister_switch(smi->ds);
|
dsa_unregister_switch(smi->ds);
|
||||||
if (smi->slave_mii_bus)
|
if (smi->slave_mii_bus)
|
||||||
of_node_put(smi->slave_mii_bus->dev.of_node);
|
of_node_put(smi->slave_mii_bus->dev.of_node);
|
||||||
gpiod_set_value(smi->reset, 1);
|
gpiod_set_value(smi->reset, 1);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void realtek_smi_shutdown(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
struct realtek_smi *smi = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
if (!smi)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dsa_switch_shutdown(smi->ds);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct of_device_id realtek_smi_of_match[] = {
|
static const struct of_device_id realtek_smi_of_match[] = {
|
||||||
{
|
{
|
||||||
.compatible = "realtek,rtl8366rb",
|
.compatible = "realtek,rtl8366rb",
|
||||||
@ -495,6 +512,7 @@ static struct platform_driver realtek_smi_driver = {
|
|||||||
},
|
},
|
||||||
.probe = realtek_smi_probe,
|
.probe = realtek_smi_probe,
|
||||||
.remove = realtek_smi_remove,
|
.remove = realtek_smi_remove,
|
||||||
|
.shutdown = realtek_smi_shutdown,
|
||||||
};
|
};
|
||||||
module_platform_driver(realtek_smi_driver);
|
module_platform_driver(realtek_smi_driver);
|
||||||
|
|
||||||
|
@ -3335,13 +3335,29 @@ static int sja1105_probe(struct spi_device *spi)
|
|||||||
static int sja1105_remove(struct spi_device *spi)
|
static int sja1105_remove(struct spi_device *spi)
|
||||||
{
|
{
|
||||||
struct sja1105_private *priv = spi_get_drvdata(spi);
|
struct sja1105_private *priv = spi_get_drvdata(spi);
|
||||||
struct dsa_switch *ds = priv->ds;
|
|
||||||
|
|
||||||
dsa_unregister_switch(ds);
|
if (!priv)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
dsa_unregister_switch(priv->ds);
|
||||||
|
|
||||||
|
spi_set_drvdata(spi, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sja1105_shutdown(struct spi_device *spi)
|
||||||
|
{
|
||||||
|
struct sja1105_private *priv = spi_get_drvdata(spi);
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return;
|
||||||
|
|
||||||
|
dsa_switch_shutdown(priv->ds);
|
||||||
|
|
||||||
|
spi_set_drvdata(spi, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct of_device_id sja1105_dt_ids[] = {
|
static const struct of_device_id sja1105_dt_ids[] = {
|
||||||
{ .compatible = "nxp,sja1105e", .data = &sja1105e_info },
|
{ .compatible = "nxp,sja1105e", .data = &sja1105e_info },
|
||||||
{ .compatible = "nxp,sja1105t", .data = &sja1105t_info },
|
{ .compatible = "nxp,sja1105t", .data = &sja1105t_info },
|
||||||
@ -3365,6 +3381,7 @@ static struct spi_driver sja1105_driver = {
|
|||||||
},
|
},
|
||||||
.probe = sja1105_probe,
|
.probe = sja1105_probe,
|
||||||
.remove = sja1105_remove,
|
.remove = sja1105_remove,
|
||||||
|
.shutdown = sja1105_shutdown,
|
||||||
};
|
};
|
||||||
|
|
||||||
module_spi_driver(sja1105_driver);
|
module_spi_driver(sja1105_driver);
|
||||||
|
@ -1225,6 +1225,12 @@ int vsc73xx_remove(struct vsc73xx *vsc)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(vsc73xx_remove);
|
EXPORT_SYMBOL(vsc73xx_remove);
|
||||||
|
|
||||||
|
void vsc73xx_shutdown(struct vsc73xx *vsc)
|
||||||
|
{
|
||||||
|
dsa_switch_shutdown(vsc->ds);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(vsc73xx_shutdown);
|
||||||
|
|
||||||
MODULE_AUTHOR("Linus Walleij <linus.walleij@linaro.org>");
|
MODULE_AUTHOR("Linus Walleij <linus.walleij@linaro.org>");
|
||||||
MODULE_DESCRIPTION("Vitesse VSC7385/7388/7395/7398 driver");
|
MODULE_DESCRIPTION("Vitesse VSC7385/7388/7395/7398 driver");
|
||||||
MODULE_LICENSE("GPL v2");
|
MODULE_LICENSE("GPL v2");
|
||||||
|
@ -116,7 +116,26 @@ static int vsc73xx_platform_remove(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
struct vsc73xx_platform *vsc_platform = platform_get_drvdata(pdev);
|
struct vsc73xx_platform *vsc_platform = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
return vsc73xx_remove(&vsc_platform->vsc);
|
if (!vsc_platform)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
vsc73xx_remove(&vsc_platform->vsc);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vsc73xx_platform_shutdown(struct platform_device *pdev)
|
||||||
|
{
|
||||||
|
struct vsc73xx_platform *vsc_platform = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
|
if (!vsc_platform)
|
||||||
|
return;
|
||||||
|
|
||||||
|
vsc73xx_shutdown(&vsc_platform->vsc);
|
||||||
|
|
||||||
|
platform_set_drvdata(pdev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct vsc73xx_ops vsc73xx_platform_ops = {
|
static const struct vsc73xx_ops vsc73xx_platform_ops = {
|
||||||
@ -144,6 +163,7 @@ MODULE_DEVICE_TABLE(of, vsc73xx_of_match);
|
|||||||
static struct platform_driver vsc73xx_platform_driver = {
|
static struct platform_driver vsc73xx_platform_driver = {
|
||||||
.probe = vsc73xx_platform_probe,
|
.probe = vsc73xx_platform_probe,
|
||||||
.remove = vsc73xx_platform_remove,
|
.remove = vsc73xx_platform_remove,
|
||||||
|
.shutdown = vsc73xx_platform_shutdown,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "vsc73xx-platform",
|
.name = "vsc73xx-platform",
|
||||||
.of_match_table = vsc73xx_of_match,
|
.of_match_table = vsc73xx_of_match,
|
||||||
|
@ -163,7 +163,26 @@ static int vsc73xx_spi_remove(struct spi_device *spi)
|
|||||||
{
|
{
|
||||||
struct vsc73xx_spi *vsc_spi = spi_get_drvdata(spi);
|
struct vsc73xx_spi *vsc_spi = spi_get_drvdata(spi);
|
||||||
|
|
||||||
return vsc73xx_remove(&vsc_spi->vsc);
|
if (!vsc_spi)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
vsc73xx_remove(&vsc_spi->vsc);
|
||||||
|
|
||||||
|
spi_set_drvdata(spi, NULL);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vsc73xx_spi_shutdown(struct spi_device *spi)
|
||||||
|
{
|
||||||
|
struct vsc73xx_spi *vsc_spi = spi_get_drvdata(spi);
|
||||||
|
|
||||||
|
if (!vsc_spi)
|
||||||
|
return;
|
||||||
|
|
||||||
|
vsc73xx_shutdown(&vsc_spi->vsc);
|
||||||
|
|
||||||
|
spi_set_drvdata(spi, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct vsc73xx_ops vsc73xx_spi_ops = {
|
static const struct vsc73xx_ops vsc73xx_spi_ops = {
|
||||||
@ -191,6 +210,7 @@ MODULE_DEVICE_TABLE(of, vsc73xx_of_match);
|
|||||||
static struct spi_driver vsc73xx_spi_driver = {
|
static struct spi_driver vsc73xx_spi_driver = {
|
||||||
.probe = vsc73xx_spi_probe,
|
.probe = vsc73xx_spi_probe,
|
||||||
.remove = vsc73xx_spi_remove,
|
.remove = vsc73xx_spi_remove,
|
||||||
|
.shutdown = vsc73xx_spi_shutdown,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "vsc73xx-spi",
|
.name = "vsc73xx-spi",
|
||||||
.of_match_table = vsc73xx_of_match,
|
.of_match_table = vsc73xx_of_match,
|
||||||
|
@ -27,3 +27,4 @@ struct vsc73xx_ops {
|
|||||||
int vsc73xx_is_addr_valid(u8 block, u8 subblock);
|
int vsc73xx_is_addr_valid(u8 block, u8 subblock);
|
||||||
int vsc73xx_probe(struct vsc73xx *vsc);
|
int vsc73xx_probe(struct vsc73xx *vsc);
|
||||||
int vsc73xx_remove(struct vsc73xx *vsc);
|
int vsc73xx_remove(struct vsc73xx *vsc);
|
||||||
|
void vsc73xx_shutdown(struct vsc73xx *vsc);
|
||||||
|
@ -822,6 +822,12 @@ void xrs700x_switch_remove(struct xrs700x *priv)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(xrs700x_switch_remove);
|
EXPORT_SYMBOL(xrs700x_switch_remove);
|
||||||
|
|
||||||
|
void xrs700x_switch_shutdown(struct xrs700x *priv)
|
||||||
|
{
|
||||||
|
dsa_switch_shutdown(priv->ds);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL(xrs700x_switch_shutdown);
|
||||||
|
|
||||||
MODULE_AUTHOR("George McCollister <george.mccollister@gmail.com>");
|
MODULE_AUTHOR("George McCollister <george.mccollister@gmail.com>");
|
||||||
MODULE_DESCRIPTION("Arrow SpeedChips XRS700x DSA driver");
|
MODULE_DESCRIPTION("Arrow SpeedChips XRS700x DSA driver");
|
||||||
MODULE_LICENSE("GPL v2");
|
MODULE_LICENSE("GPL v2");
|
||||||
|
@ -40,3 +40,4 @@ struct xrs700x {
|
|||||||
struct xrs700x *xrs700x_switch_alloc(struct device *base, void *devpriv);
|
struct xrs700x *xrs700x_switch_alloc(struct device *base, void *devpriv);
|
||||||
int xrs700x_switch_register(struct xrs700x *priv);
|
int xrs700x_switch_register(struct xrs700x *priv);
|
||||||
void xrs700x_switch_remove(struct xrs700x *priv);
|
void xrs700x_switch_remove(struct xrs700x *priv);
|
||||||
|
void xrs700x_switch_shutdown(struct xrs700x *priv);
|
||||||
|
@ -109,11 +109,28 @@ static int xrs700x_i2c_remove(struct i2c_client *i2c)
|
|||||||
{
|
{
|
||||||
struct xrs700x *priv = i2c_get_clientdata(i2c);
|
struct xrs700x *priv = i2c_get_clientdata(i2c);
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return 0;
|
||||||
|
|
||||||
xrs700x_switch_remove(priv);
|
xrs700x_switch_remove(priv);
|
||||||
|
|
||||||
|
i2c_set_clientdata(i2c, NULL);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void xrs700x_i2c_shutdown(struct i2c_client *i2c)
|
||||||
|
{
|
||||||
|
struct xrs700x *priv = i2c_get_clientdata(i2c);
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return;
|
||||||
|
|
||||||
|
xrs700x_switch_shutdown(priv);
|
||||||
|
|
||||||
|
i2c_set_clientdata(i2c, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static const struct i2c_device_id xrs700x_i2c_id[] = {
|
static const struct i2c_device_id xrs700x_i2c_id[] = {
|
||||||
{ "xrs700x-switch", 0 },
|
{ "xrs700x-switch", 0 },
|
||||||
{},
|
{},
|
||||||
@ -137,6 +154,7 @@ static struct i2c_driver xrs700x_i2c_driver = {
|
|||||||
},
|
},
|
||||||
.probe = xrs700x_i2c_probe,
|
.probe = xrs700x_i2c_probe,
|
||||||
.remove = xrs700x_i2c_remove,
|
.remove = xrs700x_i2c_remove,
|
||||||
|
.shutdown = xrs700x_i2c_shutdown,
|
||||||
.id_table = xrs700x_i2c_id,
|
.id_table = xrs700x_i2c_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -136,7 +136,24 @@ static void xrs700x_mdio_remove(struct mdio_device *mdiodev)
|
|||||||
{
|
{
|
||||||
struct xrs700x *priv = dev_get_drvdata(&mdiodev->dev);
|
struct xrs700x *priv = dev_get_drvdata(&mdiodev->dev);
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return;
|
||||||
|
|
||||||
xrs700x_switch_remove(priv);
|
xrs700x_switch_remove(priv);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xrs700x_mdio_shutdown(struct mdio_device *mdiodev)
|
||||||
|
{
|
||||||
|
struct xrs700x *priv = dev_get_drvdata(&mdiodev->dev);
|
||||||
|
|
||||||
|
if (!priv)
|
||||||
|
return;
|
||||||
|
|
||||||
|
xrs700x_switch_shutdown(priv);
|
||||||
|
|
||||||
|
dev_set_drvdata(&mdiodev->dev, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct of_device_id __maybe_unused xrs700x_mdio_dt_ids[] = {
|
static const struct of_device_id __maybe_unused xrs700x_mdio_dt_ids[] = {
|
||||||
@ -155,6 +172,7 @@ static struct mdio_driver xrs700x_mdio_driver = {
|
|||||||
},
|
},
|
||||||
.probe = xrs700x_mdio_probe,
|
.probe = xrs700x_mdio_probe,
|
||||||
.remove = xrs700x_mdio_remove,
|
.remove = xrs700x_mdio_remove,
|
||||||
|
.shutdown = xrs700x_mdio_shutdown,
|
||||||
};
|
};
|
||||||
|
|
||||||
mdio_module_driver(xrs700x_mdio_driver);
|
mdio_module_driver(xrs700x_mdio_driver);
|
||||||
|
@ -179,6 +179,16 @@ static int mdio_remove(struct device *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void mdio_shutdown(struct device *dev)
|
||||||
|
{
|
||||||
|
struct mdio_device *mdiodev = to_mdio_device(dev);
|
||||||
|
struct device_driver *drv = mdiodev->dev.driver;
|
||||||
|
struct mdio_driver *mdiodrv = to_mdio_driver(drv);
|
||||||
|
|
||||||
|
if (mdiodrv->shutdown)
|
||||||
|
mdiodrv->shutdown(mdiodev);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mdio_driver_register - register an mdio_driver with the MDIO layer
|
* mdio_driver_register - register an mdio_driver with the MDIO layer
|
||||||
* @drv: new mdio_driver to register
|
* @drv: new mdio_driver to register
|
||||||
@ -193,6 +203,7 @@ int mdio_driver_register(struct mdio_driver *drv)
|
|||||||
mdiodrv->driver.bus = &mdio_bus_type;
|
mdiodrv->driver.bus = &mdio_bus_type;
|
||||||
mdiodrv->driver.probe = mdio_probe;
|
mdiodrv->driver.probe = mdio_probe;
|
||||||
mdiodrv->driver.remove = mdio_remove;
|
mdiodrv->driver.remove = mdio_remove;
|
||||||
|
mdiodrv->driver.shutdown = mdio_shutdown;
|
||||||
|
|
||||||
retval = driver_register(&mdiodrv->driver);
|
retval = driver_register(&mdiodrv->driver);
|
||||||
if (retval) {
|
if (retval) {
|
||||||
|
@ -80,6 +80,9 @@ struct mdio_driver {
|
|||||||
|
|
||||||
/* Clears up any memory if needed */
|
/* Clears up any memory if needed */
|
||||||
void (*remove)(struct mdio_device *mdiodev);
|
void (*remove)(struct mdio_device *mdiodev);
|
||||||
|
|
||||||
|
/* Quiesces the device on system shutdown, turns off interrupts etc */
|
||||||
|
void (*shutdown)(struct mdio_device *mdiodev);
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct mdio_driver *
|
static inline struct mdio_driver *
|
||||||
|
@ -1046,6 +1046,7 @@ static inline int dsa_ndo_eth_ioctl(struct net_device *dev, struct ifreq *ifr,
|
|||||||
|
|
||||||
void dsa_unregister_switch(struct dsa_switch *ds);
|
void dsa_unregister_switch(struct dsa_switch *ds);
|
||||||
int dsa_register_switch(struct dsa_switch *ds);
|
int dsa_register_switch(struct dsa_switch *ds);
|
||||||
|
void dsa_switch_shutdown(struct dsa_switch *ds);
|
||||||
struct dsa_switch *dsa_switch_find(int tree_index, int sw_index);
|
struct dsa_switch *dsa_switch_find(int tree_index, int sw_index);
|
||||||
#ifdef CONFIG_PM_SLEEP
|
#ifdef CONFIG_PM_SLEEP
|
||||||
int dsa_switch_suspend(struct dsa_switch *ds);
|
int dsa_switch_suspend(struct dsa_switch *ds);
|
||||||
|
@ -1562,3 +1562,53 @@ void dsa_unregister_switch(struct dsa_switch *ds)
|
|||||||
mutex_unlock(&dsa2_mutex);
|
mutex_unlock(&dsa2_mutex);
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(dsa_unregister_switch);
|
EXPORT_SYMBOL_GPL(dsa_unregister_switch);
|
||||||
|
|
||||||
|
/* If the DSA master chooses to unregister its net_device on .shutdown, DSA is
|
||||||
|
* blocking that operation from completion, due to the dev_hold taken inside
|
||||||
|
* netdev_upper_dev_link. Unlink the DSA slave interfaces from being uppers of
|
||||||
|
* the DSA master, so that the system can reboot successfully.
|
||||||
|
*/
|
||||||
|
void dsa_switch_shutdown(struct dsa_switch *ds)
|
||||||
|
{
|
||||||
|
struct net_device *master, *slave_dev;
|
||||||
|
LIST_HEAD(unregister_list);
|
||||||
|
struct dsa_port *dp;
|
||||||
|
|
||||||
|
mutex_lock(&dsa2_mutex);
|
||||||
|
rtnl_lock();
|
||||||
|
|
||||||
|
list_for_each_entry(dp, &ds->dst->ports, list) {
|
||||||
|
if (dp->ds != ds)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!dsa_port_is_user(dp))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
master = dp->cpu_dp->master;
|
||||||
|
slave_dev = dp->slave;
|
||||||
|
|
||||||
|
netdev_upper_dev_unlink(master, slave_dev);
|
||||||
|
/* Just unlinking ourselves as uppers of the master is not
|
||||||
|
* sufficient. When the master net device unregisters, that will
|
||||||
|
* also call dev_close, which we will catch as NETDEV_GOING_DOWN
|
||||||
|
* and trigger a dev_close on our own devices (dsa_slave_close).
|
||||||
|
* In turn, that will call dev_mc_unsync on the master's net
|
||||||
|
* device. If the master is also a DSA switch port, this will
|
||||||
|
* trigger dsa_slave_set_rx_mode which will call dev_mc_sync on
|
||||||
|
* its own master. Lockdep will complain about the fact that
|
||||||
|
* all cascaded masters have the same dsa_master_addr_list_lock_key,
|
||||||
|
* which it normally would not do if the cascaded masters would
|
||||||
|
* be in a proper upper/lower relationship, which we've just
|
||||||
|
* destroyed.
|
||||||
|
* To suppress the lockdep warnings, let's actually unregister
|
||||||
|
* the DSA slave interfaces too, to avoid the nonsensical
|
||||||
|
* multicast address list synchronization on shutdown.
|
||||||
|
*/
|
||||||
|
unregister_netdevice_queue(slave_dev, &unregister_list);
|
||||||
|
}
|
||||||
|
unregister_netdevice_many(&unregister_list);
|
||||||
|
|
||||||
|
rtnl_unlock();
|
||||||
|
mutex_unlock(&dsa2_mutex);
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(dsa_switch_shutdown);
|
||||||
|
Loading…
Reference in New Issue
Block a user