net: ibm: emac: modernize a bit
Subsystems (2)
v4 cover net: ibm: emac: modernize a bit
It's a very old driver with a lot of potential for cleaning up code to modern standards. This was a simple one dealing with mostly the probe function and adding some devm to it.
v2: removed the waiting code in favor of EPROBE_DEFER.
v3: reverse xmas order fix, unnecessary assignment fix, wrong usage of EPROBE_DEFER fix.
v4: fixed line length warnings and unused goto.
Rosen Penev (8):
net: ibm: emac: manage emac_irq with devm
net: ibm: emac: use devm for of_iomap
net: ibm: emac: remove mii_bus with devm
net: ibm: emac: use devm for register_netdev
net: ibm: emac: use netdev's phydev directly
net: ibm: emac: replace of_get_property
net: ibm: emac: remove all waiting code
net: ibm: emac: get rid of wol_irq
drivers/net/ethernet/ibm/emac/core.c | 210 +++++++++------------------ drivers/net/ethernet/ibm/emac/core.h | 4 - 2 files changed, 68 insertions(+), 146 deletions(-)
Signature · 1 line
2.46.0
PATCH v4 1/8 net: ibm: emac: manage emac_irq with devm
It's the last to go in remove. Safe to let devm handle it.
Also move request_irq to probe for clarity. It's removed in _remove not close.
Use dev_err_probe instead of printk. Handles EPROBE_DEFER automatically.
--- drivers/net/ethernet/ibm/emac/core.c | 29 +++++++++++----------------- 1 file changed, 11 insertions(+), 18 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +11 -18
@@ -1228,18 +1228,10 @@ static void emac_print_link_status(struct emac_instance *dev)static int emac_open (struct net_device *ndev) {struct emac_instance *dev =netdev_priv (ndev); -int err, i; +int i;DBG (dev,"open" NL ); -/* Setup error IRQ handler */ - err =request_irq (dev->emac_irq, emac_irq,0 ,"EMAC" , dev); -if (err) { -printk (KERN_ERR "%s: failed to request IRQ %d\n" , - ndev->name, dev->emac_irq); -return err; - } -/* Allocate RX ring */ for (i =0 ; i <NUM_RX_BUFF ; ++i)if (emac_alloc_rx_skb (dev, i)) {
@@ -1293,8 +1285,6 @@ static int emac_open(struct net_device *ndev)return 0 ; oom:emac_clean_rx_ring (dev); -free_irq (dev->emac_irq, dev); -return -ENOMEM ; }
@@ -1408,8 +1398,6 @@ static int emac_close(struct net_device *ndev)emac_clean_tx_ring (dev);emac_clean_rx_ring (dev); -free_irq (dev->emac_irq, dev); -netif_carrier_off (ndev);return 0 ;
@@ -3082,6 +3070,16 @@ static int emac_probe(struct platform_device *ofdev) err = -ENODEV ; goto err_gone; } + +/* Setup error IRQ handler */ + err =devm_request_irq (&ofdev->dev, dev->emac_irq, emac_irq,0 ,"EMAC" , + dev); +if (err) { +dev_err_probe (&ofdev->dev, err,"failed to request IRQ %d" , + dev->emac_irq); + goto err_gone; + } + ndev->irq = dev->emac_irq;/* Map EMAC regs */
@@ -3237,8 +3235,6 @@ static int emac_probe(struct platform_device *ofdev) err_irq_unmap:if (dev->wol_irq)irq_dispose_mapping (dev->wol_irq); -if (dev->emac_irq) -irq_dispose_mapping (dev->emac_irq); err_gone:/* if we were on the bootlist, remove us as we won't show up and * wake up all waiters to notify them in case they were waiting
@@ -3284,9 +3280,6 @@ static void emac_remove(struct platform_device *ofdev)if (dev->wol_irq)irq_dispose_mapping (dev->wol_irq); -if (dev->emac_irq) -irq_dispose_mapping (dev->emac_irq); - }/* XXX Features in here should be replaced by properties... */
Signature · 1 line
2.46.0
PATCH v4 2/8 net: ibm: emac: use devm for of_iomap
In reply to Rosen PenevAllows removing manual iounmap.
--- drivers/net/ethernet/ibm/emac/core.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +4 -8
@@ -3084,9 +3084,9 @@ static int emac_probe(struct platform_device *ofdev)/* Map EMAC regs */ // TODO : platform_get_resource() and devm_ioremap_resource() - dev->emacp =of_iomap (np,0 ); -if (dev->emacp ==NULL ) { -printk (KERN_ERR "%pOF: Can't map device registers!\n" , np); + dev->emacp =devm_of_iomap (&ofdev->dev, np,0 ,NULL ); +if (!dev->emacp) { +dev_err (&ofdev->dev,"can't map device registers" ); err = -ENOMEM ; goto err_irq_unmap; }
@@ -3097,7 +3097,7 @@ static int emac_probe(struct platform_device *ofdev)printk (KERN_ERR "%pOF: Timeout waiting for dependent devices\n" , np);/* display more info about what's missing ? */ - goto err_reg_unmap; + goto err_irq_unmap; } dev->mal =platform_get_drvdata (dev->mal_dev);if (dev->mdio_dev !=NULL )
@@ -3230,8 +3230,6 @@ static int emac_probe(struct platform_device *ofdev)mal_unregister_commac (dev->mal, &dev->commac); err_rel_deps:emac_put_deps (dev); - err_reg_unmap: -iounmap (dev->emacp); err_irq_unmap:if (dev->wol_irq)irq_dispose_mapping (dev->wol_irq);
@@ -3276,8 +3274,6 @@ static void emac_remove(struct platform_device *ofdev)mal_unregister_commac (dev->mal, &dev->commac);emac_put_deps (dev); -iounmap (dev->emacp); -if (dev->wol_irq)irq_dispose_mapping (dev->wol_irq); }
Signature · 1 line
2.46.0
PATCH v4 3/8 net: ibm: emac: remove mii_bus with devm
In reply to Rosen PenevSwitching to devm management of mii_bus allows to remove mdiobus_unregister calls and thus avoids needing a mii_bus global struct member.
--- drivers/net/ethernet/ibm/emac/core.c | 32 +++++++++++----------------- drivers/net/ethernet/ibm/emac/core.h | 1 - 2 files changed, 13 insertions(+), 20 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +13 -19
@@ -2581,6 +2581,7 @@ static const struct mii_phy_ops emac_dt_mdio_phy_ops = {static int emac_dt_mdio_probe (struct emac_instance *dev) {struct device_node *mii_np; +struct mii_bus *bus;int res; mii_np =of_get_child_by_name (dev->ofdev->dev.of_node,"mdio" );
@@ -2594,23 +2595,23 @@ static int emac_dt_mdio_probe(struct emac_instance *dev) goto put_node; } - dev->mii_bus =devm_mdiobus_alloc (&dev->ofdev->dev); -if (!dev->mii_bus) { + bus =devm_mdiobus_alloc (&dev->ofdev->dev); +if (!bus) { res = -ENOMEM ; goto put_node; } - dev->mii_bus->priv = dev->ndev; - dev->mii_bus->parent = dev->ndev->dev.parent; - dev->mii_bus->name ="emac_mdio" ; - dev->mii_bus->read = &emac_mii_bus_read; - dev->mii_bus->write = &emac_mii_bus_write; - dev->mii_bus->reset = &emac_mii_bus_reset; -snprintf (dev->mii_bus->id,MII_BUS_ID_SIZE ,"%s" , dev->ofdev->name); - res =of_mdiobus_register (dev->mii_bus, mii_np); + bus->priv = dev->ndev; + bus->parent = dev->ndev->dev.parent; + bus->name ="emac_mdio" ; + bus->read = &emac_mii_bus_read; + bus->write = &emac_mii_bus_write; + bus->reset = &emac_mii_bus_reset; +snprintf (bus->id,MII_BUS_ID_SIZE ,"%s" , dev->ofdev->name); + res =devm_of_mdiobus_register (&dev->ofdev->dev, bus, mii_np);if (res) {dev_err (&dev->ofdev->dev,"cannot register MDIO bus %s (%d)" , - dev->mii_bus->name, res); + bus->name, res); } put_node:
@@ -2656,8 +2657,6 @@ static int emac_dt_phy_probe(struct emac_instance *dev) res =emac_dt_mdio_probe (dev);if (!res) { res =emac_dt_phy_connect (dev, phy_handle); -if (res) -mdiobus_unregister (dev->mii_bus); } }
@@ -2697,10 +2696,8 @@ static int emac_init_phy(struct emac_instance *dev) res =of_phy_register_fixed_link (np); dev->phy_dev =of_phy_find_device (np); -if (res || !dev->phy_dev) { -mdiobus_unregister (dev->mii_bus); +if (res || !dev->phy_dev)return res ? res : -EINVAL ; - }emac_adjust_link (dev->ndev);put_device (&dev->phy_dev->mdio.dev); }
@@ -3265,9 +3262,6 @@ static void emac_remove(struct platform_device *ofdev)if (dev->phy_dev)phy_disconnect (dev->phy_dev); -if (dev->mii_bus) -mdiobus_unregister (dev->mii_bus); - busy_phy_map &= ~(1 << dev->phy.address);DBG (dev,"busy_phy_map now %#x" NL , busy_phy_map);
drivers/net/ethernet/ibm/emac/core.h +0 -1
@@ -189,7 +189,6 @@ struct emac_instance {struct mutex mdio_lock;/* Device-tree based phy configuration */ -struct mii_bus *mii_bus;struct phy_device *phy_dev;/* ZMII infos if any */
Signature · 1 line
2.46.0
PATCH v4 4/8 net: ibm: emac: use devm for register_netdev
In reply to Rosen PenevCleans it up automatically. No need to handle manually.
--- drivers/net/ethernet/ibm/emac/core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +1 -3
@@ -3182,7 +3182,7 @@ static int emac_probe(struct platform_device *ofdev)netif_carrier_off (ndev); - err =register_netdev (ndev); + err =devm_register_netdev (&ofdev->dev, ndev);if (err) {printk (KERN_ERR "%pOF: failed to register net device (%d)!\n" , np, err);
@@ -3248,8 +3248,6 @@ static void emac_remove(struct platform_device *ofdev)DBG (dev,"remove" NL ); -unregister_netdev (dev->ndev); -cancel_work_sync (&dev->reset_work);if (emac_has_feature (dev,EMAC_FTR_HAS_TAH ))
Signature · 1 line
2.46.0
PATCH v4 5/8 net: ibm: emac: use netdev's phydev directly
In reply to Rosen PenevAvoids having to use own struct member.
--- drivers/net/ethernet/ibm/emac/core.c | 49 +++++++++++++--------------- drivers/net/ethernet/ibm/emac/core.h | 3 -- 2 files changed, 22 insertions(+), 30 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +22 -27
@@ -2459,7 +2459,7 @@ static int emac_read_uint_prop(struct device_node *np, const char *name,static void emac_adjust_link (struct net_device *ndev) {struct emac_instance *dev =netdev_priv (ndev); -struct phy_device *phy = dev->phy_dev; +struct phy_device *phy = ndev->phydev; dev->phy.autoneg = phy->autoneg; dev->phy.speed = phy->speed;
@@ -2510,22 +2510,20 @@ static int emac_mdio_phy_start_aneg(struct mii_phy *phy,static int emac_mdio_setup_aneg (struct mii_phy *phy,u32 advertise) {struct net_device *ndev = phy->dev; -struct emac_instance *dev =netdev_priv (ndev); phy->autoneg =AUTONEG_ENABLE ; phy->advertising = advertise; -return emac_mdio_phy_start_aneg (phy, dev->phy_dev); +return emac_mdio_phy_start_aneg (phy, ndev->phydev); }static int emac_mdio_setup_forced (struct mii_phy *phy,int speed,int fd) {struct net_device *ndev = phy->dev; -struct emac_instance *dev =netdev_priv (ndev); phy->autoneg =AUTONEG_DISABLE ; phy->speed = speed; phy->duplex = fd; -return emac_mdio_phy_start_aneg (phy, dev->phy_dev); +return emac_mdio_phy_start_aneg (phy, ndev->phydev); }static int emac_mdio_poll_link (struct mii_phy *phy)
@@ -2534,20 +2532,19 @@ static int emac_mdio_poll_link(struct mii_phy *phy)struct emac_instance *dev =netdev_priv (ndev);int res; - res =phy_read_status (dev->phy_dev); + res =phy_read_status (ndev->phydev);if (res) {dev_err (&dev->ofdev->dev,"link update failed (%d)." , res);return ethtool_op_get_link (ndev); } -return dev->phy_dev->link; +return ndev->phydev->link; }static int emac_mdio_read_link (struct mii_phy *phy) {struct net_device *ndev = phy->dev; -struct emac_instance *dev =netdev_priv (ndev); -struct phy_device *phy_dev = dev->phy_dev; +struct phy_device *phy_dev = ndev->phydev;int res; res =phy_read_status (phy_dev);
@@ -2564,10 +2561,9 @@ static int emac_mdio_read_link(struct mii_phy *phy)static int emac_mdio_init_phy (struct mii_phy *phy) {struct net_device *ndev = phy->dev; -struct emac_instance *dev =netdev_priv (ndev); -phy_start (dev->phy_dev); -return phy_init_hw (dev->phy_dev); +phy_start (ndev->phydev); +return phy_init_hw (ndev->phydev); }static const struct mii_phy_ops emac_dt_mdio_phy_ops = {
@@ -2622,26 +2618,28 @@ static int emac_dt_mdio_probe(struct emac_instance *dev)static int emac_dt_phy_connect (struct emac_instance *dev,struct device_node *phy_handle) { +struct phy_device *phy_dev; + dev->phy.def =devm_kzalloc (&dev->ofdev->dev,sizeof (*dev->phy.def),GFP_KERNEL );if (!dev->phy.def)return -ENOMEM ; - dev->phy_dev =of_phy_connect (dev->ndev, phy_handle, &emac_adjust_link, -0 , dev->phy_mode); -if (!dev->phy_dev) { + phy_dev =of_phy_connect (dev->ndev, phy_handle, &emac_adjust_link,0 , + dev->phy_mode); +if (!phy_dev) {dev_err (&dev->ofdev->dev,"failed to connect to PHY.\n" );return -ENODEV ; } - dev->phy.def->phy_id = dev->phy_dev->drv->phy_id; - dev->phy.def->phy_id_mask = dev->phy_dev->drv->phy_id_mask; - dev->phy.def->name = dev->phy_dev->drv->name; + dev->phy.def->phy_id = phy_dev->drv->phy_id; + dev->phy.def->phy_id_mask = phy_dev->drv->phy_id_mask; + dev->phy.def->name = phy_dev->drv->name; dev->phy.def->ops = &emac_dt_mdio_phy_ops;ethtool_convert_link_mode_to_legacy_u32 (&dev->phy.features, - dev->phy_dev->supported); - dev->phy.address = dev->phy_dev->mdio.addr; - dev->phy.mode = dev->phy_dev->interface; + phy_dev->supported); + dev->phy.address = phy_dev->mdio.addr; + dev->phy.mode = phy_dev->interface;return 0 ; }
@@ -2695,11 +2693,11 @@ static int emac_init_phy(struct emac_instance *dev)return res; res =of_phy_register_fixed_link (np); - dev->phy_dev =of_phy_find_device (np); -if (res || !dev->phy_dev) + ndev->phydev =of_phy_find_device (np); +if (res || !ndev->phydev)return res ? res : -EINVAL ;emac_adjust_link (dev->ndev); -put_device (&dev->phy_dev->mdio.dev); +put_device (&ndev->phydev->mdio.dev); }return 0 ; }
@@ -3257,9 +3255,6 @@ static void emac_remove(struct platform_device *ofdev)if (emac_has_feature (dev,EMAC_FTR_HAS_ZMII ))zmii_detach (dev->zmii_dev, dev->zmii_port); -if (dev->phy_dev) -phy_disconnect (dev->phy_dev); - busy_phy_map &= ~(1 << dev->phy.address);DBG (dev,"busy_phy_map now %#x" NL , busy_phy_map);
drivers/net/ethernet/ibm/emac/core.h +0 -3
@@ -188,9 +188,6 @@ struct emac_instance {struct emac_instance *mdio_instance;struct mutex mdio_lock; -/* Device-tree based phy configuration */ -struct phy_device *phy_dev; -/* ZMII infos if any */ u32 zmii_ph;u32 zmii_port;
Signature · 1 line
2.46.0
PATCH v4 6/8 net: ibm: emac: replace of_get_property
In reply to Rosen Penevof_property_read_u32 can be used.
--- drivers/net/ethernet/ibm/emac/core.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +9 -11
@@ -2444,15 +2444,14 @@ static int emac_wait_deps(struct emac_instance *dev)static int emac_read_uint_prop (struct device_node *np,const char *name,u32 *val,int fatal) { -int len; -const u32 *prop =of_get_property (np, name, &len); -if (prop ==NULL || len <sizeof (u32)) { +int err; + + err =of_property_read_u32 (np, name, val); +if (err) {if (fatal) -printk (KERN_ERR "%pOF: missing %s property\n" , - np, name); -return -ENODEV ; +pr_err ("%pOF: missing %s property" , np, name); +return err; } - *val = *prop;return 0 ; }
@@ -3301,16 +3300,15 @@ static void __init emac_make_bootlist(void)/* Collect EMACs */ while ((np =of_find_all_nodes (np)) !=NULL ) { -const u32 *idx; +u32 idx;if (of_match_node (emac_match, np) ==NULL )continue ;if (of_property_read_bool (np,"unused" ))continue ; - idx =of_get_property (np,"cell-index" ,NULL ); -if (idx ==NULL ) +if (of_property_read_u32 (np,"cell-index" , &idx))continue ; - cell_indices[i] = *idx; + cell_indices[i] = idx; emac_boot_list[i++] =of_node_get (np);if (i >=EMAC_BOOT_LIST_SIZE ) {of_node_put (np);
Signature · 1 line
2.46.0
PATCH v4 7/8 net: ibm: emac: remove all waiting code
In reply to Rosen PenevEPROBE_DEFER, which probably wasn't available when this driver was written, can be used instead of waiting manually.
--- drivers/net/ethernet/ibm/emac/core.c | 55 ++++------------------------ 1 file changed, 7 insertions(+), 48 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +7 -48
@@ -32,7 +32,6 @@#include <linux/ethtool.h> #include <linux/mii.h> #include <linux/bitops.h> -#include <linux/workqueue.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_irq.h>
@@ -96,11 +95,6 @@ MODULE_LICENSE("GPL");static u32 busy_phy_map;static DEFINE_MUTEX (emac_phy_map_lock); -/* This is the wait queue used to wait on any event related to probe, that -* is discovery of MALs, other EMACs, ZMII/RGMIIs, etc... -*/ -static DECLARE_WAIT_QUEUE_HEAD (emac_probe_wait); -/* Having stable interface names is a doomed idea. However, it would be nice * if we didn't have completely random interface names at boot too :-) It's * just a matter of making everybody's life easier. Since we are doing
@@ -116,9 +110,6 @@ static DECLARE_WAIT_QUEUE_HEAD(emac_probe_wait);#define EMAC_BOOT_LIST_SIZE 4static struct device_node *emac_boot_list[EMAC_BOOT_LIST_SIZE ]; -/* How long should I wait for dependent devices ? */ -#define EMAC_PROBE_DEP_TIMEOUT (HZ * 5) -/* I don't want to litter system log with timeout errors * when we have brain-damaged PHY. */
@@ -973,8 +964,6 @@ static void __emac_set_multicast_list(struct emac_instance *dev)* we need is just to stop RX channel. This seems to work on all * tested SoCs. --ebs * -* If we need the full reset, we might just trigger the workqueue -* and do it async... a bit nasty but should work --BenH */ dev->mcast_pending =0 ;emac_rx_disable (dev);
@@ -2378,7 +2367,9 @@ static int emac_check_deps(struct emac_instance *dev,if (deps[i].drvdata !=NULL ) there++; } -return there ==EMAC_DEP_COUNT ; +if (there !=EMAC_DEP_COUNT ) +return -EPROBE_DEFER ; +return 0 ; }static void emac_put_deps (struct emac_instance *dev)
@@ -2390,19 +2381,6 @@ static void emac_put_deps(struct emac_instance *dev)platform_device_put (dev->tah_dev); } -static int emac_of_bus_notify (struct notifier_block *nb,unsigned long action, -void *data) -{ -/* We are only intereted in device addition */ -if (action ==BUS_NOTIFY_BOUND_DRIVER ) -wake_up_all (&emac_probe_wait); -return 0 ; -} - -static struct notifier_block emac_of_bus_notifier = { - .notifier_call = emac_of_bus_notify -}; -static int emac_wait_deps (struct emac_instance *dev) {struct emac_depentry deps[EMAC_DEP_COUNT ];
@@ -2419,18 +2397,13 @@ static int emac_wait_deps(struct emac_instance *dev) deps[EMAC_DEP_MDIO_IDX ].phandle = dev->mdio_ph;if (dev->blist && dev->blist > emac_boot_list) deps[EMAC_DEP_PREV_IDX ].phandle =0xffffffffu ; -bus_register_notifier (&platform_bus_type, &emac_of_bus_notifier); -wait_event_timeout (emac_probe_wait, -emac_check_deps (dev, deps), -EMAC_PROBE_DEP_TIMEOUT ); -bus_unregister_notifier (&platform_bus_type, &emac_of_bus_notifier); - err =emac_check_deps (dev, deps) ?0 : -ENODEV ; + err =emac_check_deps (dev, deps);for (i =0 ; i <EMAC_DEP_COUNT ; i++) {of_node_put (deps[i].node);if (err)platform_device_put (deps[i].ofdev); } -if (err ==0 ) { +if (!err) { dev->mal_dev = deps[EMAC_DEP_MAL_IDX ].ofdev; dev->zmii_dev = deps[EMAC_DEP_ZMII_IDX ].ofdev; dev->rgmii_dev = deps[EMAC_DEP_RGMII_IDX ].ofdev;
@@ -3087,12 +3060,8 @@ static int emac_probe(struct platform_device *ofdev)/* Wait for dependent devices */ err =emac_wait_deps (dev); -if (err) { -printk (KERN_ERR -"%pOF: Timeout waiting for dependent devices\n" , np); -/* display more info about what's missing ? */ +if (err) goto err_irq_unmap; - } dev->mal =platform_get_drvdata (dev->mal_dev);if (dev->mdio_dev !=NULL ) dev->mdio_instance =platform_get_drvdata (dev->mdio_dev);
@@ -3192,10 +3161,6 @@ static int emac_probe(struct platform_device *ofdev)wmb ();platform_set_drvdata (ofdev, dev); -/* There's a new kid in town ! Let's tell everybody */ -wake_up_all (&emac_probe_wait); - -printk (KERN_INFO "%s: EMAC-%d %pOF, MAC %pM\n" , ndev->name, dev->cell_index, np, ndev->dev_addr);
@@ -3228,14 +3193,8 @@ static int emac_probe(struct platform_device *ofdev)if (dev->wol_irq)irq_dispose_mapping (dev->wol_irq); err_gone: -/* if we were on the bootlist, remove us as we won't show up and -* wake up all waiters to notify them in case they were waiting -* on us -*/ -if (blist) { +if (blist) *blist =NULL ; -wake_up_all (&emac_probe_wait); - }return err; }
Signature · 1 line
2.46.0
PATCH v4 8/8 net: ibm: emac: get rid of wol_irq
In reply to Rosen PenevThis is completely unused.
--- drivers/net/ethernet/ibm/emac/core.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/net/ethernet/ibm/emac/core.c +3 -10
@@ -3029,9 +3029,8 @@ static int emac_probe(struct platform_device *ofdev)if (err) goto err_gone; -/* Get interrupts. EMAC irq is mandatory, WOL irq is optional */ +/* Get interrupts. EMAC irq is mandatory */ dev->emac_irq =irq_of_parse_and_map (np,0 ); - dev->wol_irq =irq_of_parse_and_map (np,1 );if (!dev->emac_irq) {printk (KERN_ERR "%pOF: Can't map main interrupt\n" , np); err = -ENODEV ;
@@ -3055,13 +3054,13 @@ static int emac_probe(struct platform_device *ofdev)if (!dev->emacp) {dev_err (&ofdev->dev,"can't map device registers" ); err = -ENOMEM ; - goto err_irq_unmap; + goto err_gone; }/* Wait for dependent devices */ err =emac_wait_deps (dev);if (err) - goto err_irq_unmap; + goto err_gone; dev->mal =platform_get_drvdata (dev->mal_dev);if (dev->mdio_dev !=NULL ) dev->mdio_instance =platform_get_drvdata (dev->mdio_dev);
@@ -3189,9 +3188,6 @@ static int emac_probe(struct platform_device *ofdev)mal_unregister_commac (dev->mal, &dev->commac); err_rel_deps:emac_put_deps (dev); - err_irq_unmap: -if (dev->wol_irq) -irq_dispose_mapping (dev->wol_irq); err_gone:if (blist) *blist =NULL ;
@@ -3218,9 +3214,6 @@ static void emac_remove(struct platform_device *ofdev)mal_unregister_commac (dev->mal, &dev->commac);emac_put_deps (dev); - -if (dev->wol_irq) -irq_dispose_mapping (dev->wol_irq); }/* XXX Features in here should be replaced by properties... */
Signature · 1 line
2.46.0
Le 07/09/2024 à 20:45, Rosen Penev a écrit :
Quoted 19 lines
It's a very old driver with a lot of potential for cleaning up code to modern standards. This was a simple one dealing with mostly the probe function and adding some devm to it.
v2: removed the waiting code in favor of
EPROBE_DEFER.
v3: reverse xmas order fix, unnecessary assignment fix, wrong usage ofEPROBE_DEFERfix.
v4: fixed line length warnings and unused goto.Rosen Penev (8):
net: ibm: emac: manageemac_irqwith devm
net: ibm: emac: use devm forof_iomap
net: ibm: emac: removemii_buswith devm
net: ibm: emac: use devm forregister_netdev
net: ibm: emac: use netdev's phydev directly
net: ibm: emac: replaceof_get_property
net: ibm: emac: remove all waiting code
net: ibm: emac: get rid ofwol_irq
Quoted 4 lines
drivers/net/ethernet/ibm/emac/core.c | 210 +++++++++------------------ drivers/net/ethernet/ibm/emac/core.h | 4 - 2 files changed, 68 insertions(+), 146 deletions(-)
There was 9 patches in v3.
Patch 1/9: net: ibm: emac: use devm for alloc_etherdev is no more. Is it removed intentionaly?
Also I made a comment on v3 6/9. It also apply to v4 5/9.
CJ
Quoted 21 lines · Christophe JAILLET
Quoted 19 lines · Rosen Penev
It's a very old driver with a lot of potential for cleaning up code to modern standards. This was a simple one dealing with mostly the probe function and adding some devm to it.
v2: removed the waiting code in favor of
EPROBE_DEFER.
v3: reverse xmas order fix, unnecessary assignment fix, wrong usage ofEPROBE_DEFERfix.
v4: fixed line length warnings and unused goto.Rosen Penev (8):
net: ibm: emac: manageemac_irqwith devm
net: ibm: emac: use devm forof_iomap
net: ibm: emac: removemii_buswith devm
net: ibm: emac: use devm forregister_netdev
net: ibm: emac: use netdev's phydev directly
net: ibm: emac: replaceof_get_property
net: ibm: emac: remove all waiting code
net: ibm: emac: get rid ofwol_irq
Quoted 8 lines
Quoted 4 lines
drivers/net/ethernet/ibm/emac/core.c | 210 +++++++++------------------ drivers/net/ethernet/ibm/emac/core.h | 4 - 2 files changed, 68 insertions(+), 146 deletions(-)There was 9 patches in v3.
Patch 1/9: net: ibm: emac: use devm for
alloc_etherdevis no more. Is it removed intentionaly?
Nope. I messed up when resending.
Quoted 2 lines
Also I made a comment on v3 6/9. It also apply to v4 5/9.
Sure. Unfortunately net-next closes on Monday. It might make sense to resubmit when it reopens.
Quoted 2 lines
CJ