net: mdio: Add mdio_free() and mdio_unregister() API
PATCH v2 1/4 net: mdio: Add mdio_free() and mdio_unregister() API
Currently there is no API to uninitialize mdio. Add two APIs for this.
---
Changes in v2: None
common/miiphyutil.c | 19 +++++++++++++++++++ include/miiphy.h | 2 ++ 2 files changed, 21 insertions(+)
common/miiphyutil.c +19 -0
@@ -152,6 +152,11 @@ struct mii_dev *mdio_alloc(void)return bus; } +void mdio_free (struct mii_dev *bus) +{ +free (bus); +} +int mdio_register (struct mii_dev *bus) {if (!bus || !bus->name || !bus->read || !bus->write)
@@ -173,6 +178,20 @@ int mdio_register(struct mii_dev *bus)return 0 ; } +int mdio_unregister (struct mii_dev *bus) +{ +if (!bus) +return 0 ; + +/* delete it from the list */ +list_del (&bus->link); + +if (current_mii == bus) + current_mii =NULL ; + +return 0 ; +} +void mdio_list_devices (void ) {struct list_head *entry;
include/miiphy.h +2 -0
@@ -59,7 +59,9 @@ struct phy_device *mdio_phydev_for_ethname(const char *devname);void miiphy_listdev (void );struct mii_dev *mdio_alloc (void ); +void mdio_free (struct mii_dev *bus);int mdio_register (struct mii_dev *bus); +int mdio_unregister (struct mii_dev *bus);void mdio_list_devices (void );#ifdef CONFIG_BITBANGMII
Signature · 1 line
1.8.2.1
PATCH v2 2/4 net: designware: Add driver remove support
In designware_eth_probe(), some additional resources are allocated (eg: mdio, phy). We should free these in the driver remove phase. Add designware_eth_remove() to clean it up.
---
Changes in v2: None
drivers/net/designware.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/designware.c +12 -0
@@ -613,6 +613,17 @@ static int designware_eth_probe(struct udevice *dev)return ret; } +static int designware_eth_remove (struct udevice *dev) +{ +struct dw_eth_dev *priv =dev_get_priv (dev); + +free (priv->phydev); +mdio_unregister (priv->bus); +mdio_free (priv->bus); + +return 0 ; +} +static const struct eth_ops designware_eth_ops = { .start = designware_eth_start, .send = designware_eth_send,
@@ -653,6 +664,7 @@ U_BOOT_DRIVER(eth_designware) = { .ofdata_to_platdata = designware_eth_ofdata_to_platdata, .bind = designware_eth_bind, .probe = designware_eth_probe, + .remove = designware_eth_remove, .ops = &designware_eth_ops, .priv_auto_alloc_size = sizeof(struct dw_eth_dev), .platdata_auto_alloc_size = sizeof(struct eth_pdata),
Signature · 1 line
1.8.2.1
PATCH v2 2/4 net: designware: Add driver remove support
Quoted 6 lines · Bin Meng
In
designware_eth_probe(), some additional resources are allocated (eg: mdio, phy). We should free these in the driver remove phase. Adddesignware_eth_remove()to clean it up.Signed-off-by Bin Meng <[email protected]>Acked-by Simon Glass <[email protected]>
Applied to u-boot-net/master, thanks!
-Joe
PATCH v2 3/4 net: pch_gbe: Add driver remove support
In reply to Bin MengIn pch_gbe_probe(), some additional resources are allocated (eg: mdio, phy). We should free these in the driver remove phase. Add pch_gbe_remove() to clean it up.
---
Changes in v2: None
drivers/net/pch_gbe.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/pch_gbe.c +12 -0
@@ -452,6 +452,17 @@ int pch_gbe_probe(struct udevice *dev)return pch_gbe_phy_init (dev); } +int pch_gbe_remove (struct udevice *dev) +{ +struct pch_gbe_priv *priv =dev_get_priv (dev); + +free (priv->phydev); +mdio_unregister (priv->bus); +mdio_free (priv->bus); + +return 0 ; +} +static const struct eth_ops pch_gbe_ops = { .start = pch_gbe_start, .send = pch_gbe_send,
@@ -470,6 +481,7 @@ U_BOOT_DRIVER(eth_pch_gbe) = { .id = UCLASS_ETH, .of_match = pch_gbe_ids, .probe = pch_gbe_probe, + .remove = pch_gbe_remove, .ops = &pch_gbe_ops, .priv_auto_alloc_size = sizeof(struct pch_gbe_priv), .platdata_auto_alloc_size = sizeof(struct eth_pdata),
Signature · 1 line
1.8.2.1
PATCH v2 3/4 net: pch_gbe: Add driver remove support
Hi Bin,
Quoted 6 lines · Bin Meng
In
pch_gbe_probe(), some additional resources are allocated (eg: mdio, phy). We should free these in the driver remove phase. Addpch_gbe_remove()to clean it up.Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>
PATCH v2 3/4 net: pch_gbe: Add driver remove support
In reply to Bin MengQuoted 6 lines · Bin Meng
In
pch_gbe_probe(), some additional resources are allocated (eg: mdio, phy). We should free these in the driver remove phase. Addpch_gbe_remove()to clean it up.Signed-off-by Bin Meng <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot-net/master, thanks!
-Joe
PATCH v2 4/4 dm: core: Remove unnecessary codes in uclass_pre_remove_device()
In reply to Bin Mengdev->uclass->uc_drv->per_device_auto_alloc_size is to be freed in device_free(), so is dev->seq. Remove these unnecessary codes.
---
Changes in v2:
- Drop the v1 patch: "dm: core: Remove the call to device_free()"
drivers/core/uclass.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/core/uclass.c +0 -7
@@ -523,22 +523,15 @@ int uclass_post_probe_device(struct udevice *dev)#if CONFIG_IS_ENABLED (DM_DEVICE_REMOVE )int uclass_pre_remove_device (struct udevice *dev) { -struct uclass_driver *uc_drv;struct uclass *uc;int ret; uc = dev->uclass; - uc_drv = uc->uc_drv;if (uc->uc_drv->pre_remove) { ret = uc->uc_drv->pre_remove (dev);if (ret)return ret; } -if (uc_drv->per_device_auto_alloc_size) { -free (dev->uclass_priv); - dev->uclass_priv =NULL ; - } - dev->seq =-1 ;return 0 ; }
Signature · 1 line
1.8.2.1
PATCH v2 4/4 dm: core: Remove unnecessary codes in uclass_pre_remove_device()
Quoted 5 lines · Bin Meng
dev->uclass->uc_drv->per_device_auto_alloc_sizeis to be freed indevice_free(), so isdev->seq. Remove these unnecessary codes.Signed-off-by Bin Meng <[email protected]>Acked-by Simon Glass <[email protected]>
Applied to u-boot-net/master, thanks!
-Joe
PATCH v2 1/4 net: mdio: Add mdio_free() and mdio_unregister() API
In reply to Bin MengQuoted 4 lines · Bin Meng
Currently there is no API to uninitialize mdio. Add two APIs for this.
Signed-off-by Bin Meng <[email protected]>Acked-by Joe Hershberger <[email protected]>
Applied to u-boot-net/master, thanks!
-Joe