diff mbox series

[net-next] net: use pdev instead of OF funcs

Message ID 20241109233821.8619-1-rosenp@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: use pdev instead of OF funcs | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 2 maintainers not CCed: robh@kernel.org u.kleine-koenig@baylibre.com
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 21 this patch: 21
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 347 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 44 this patch: 44
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-11-10--00-00 (tests: 785)

Commit Message

Rosen Penev Nov. 9, 2024, 11:38 p.m. UTC
np here is ofdev->dev.of_node. Better to use the proper functions as
there's no use of children or anything else.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/can/grcan.c                       |  2 +-
 drivers/net/can/mscan/mpc5xxx_can.c           |  2 +-
 drivers/net/dsa/bcm_sf2.c                     |  4 ++--
 drivers/net/ethernet/allwinner/sun4i-emac.c   |  2 +-
 drivers/net/ethernet/freescale/fec_mpc52xx.c  | 23 ++++++++++---------
 .../net/ethernet/freescale/fec_mpc52xx_phy.c  | 12 ++++++----
 .../net/ethernet/freescale/fs_enet/mac-fcc.c  |  2 +-
 .../net/ethernet/freescale/fs_enet/mac-fec.c  |  2 +-
 .../net/ethernet/freescale/fs_enet/mac-scc.c  |  2 +-
 .../net/ethernet/freescale/fs_enet/mii-fec.c  | 12 ++++++----
 drivers/net/ethernet/freescale/ucc_geth.c     | 12 +++++-----
 drivers/net/ethernet/marvell/mvneta.c         |  2 +-
 drivers/net/ethernet/moxa/moxart_ether.c      |  4 ++--
 .../ethernet/samsung/sxgbe/sxgbe_platform.c   |  8 +++----
 drivers/net/ethernet/via/via-rhine.c          |  2 +-
 drivers/net/ethernet/via/via-velocity.c       |  2 +-
 drivers/net/ethernet/xilinx/ll_temac_mdio.c   |  6 ++---
 drivers/net/mdio/mdio-mux-mmioreg.c           | 16 +++++++------
 drivers/net/wan/fsl_ucc_hdlc.c                | 10 ++++----
 19 files changed, 66 insertions(+), 59 deletions(-)

Comments

kernel test robot Nov. 10, 2024, 10:53 a.m. UTC | #1
Hi Rosen,

kernel test robot noticed the following build errors:

[auto build test ERROR on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/net-use-pdev-instead-of-OF-funcs/20241110-073939
base:   net-next/main
patch link:    https://lore.kernel.org/r/20241109233821.8619-1-rosenp%40gmail.com
patch subject: [PATCH net-next] net: use pdev instead of OF funcs
config: powerpc-ge_imp3a_defconfig (https://download.01.org/0day-ci/archive/20241110/202411101834.A8QNRx3c-lkp@intel.com/config)
compiler: powerpc-linux-gcc (GCC) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241110/202411101834.A8QNRx3c-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411101834.A8QNRx3c-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/net/ethernet/freescale/ucc_geth.c: In function 'ucc_geth_free_rx':
   drivers/net/ethernet/freescale/ucc_geth.c:1810:31: warning: variable 'uf_info' set but not used [-Wunused-but-set-variable]
    1810 |         struct ucc_fast_info *uf_info;
         |                               ^~~~~~~
   drivers/net/ethernet/freescale/ucc_geth.c: In function 'ucc_geth_free_tx':
   drivers/net/ethernet/freescale/ucc_geth.c:1849:31: warning: variable 'uf_info' set but not used [-Wunused-but-set-variable]
    1849 |         struct ucc_fast_info *uf_info;
         |                               ^~~~~~~
   drivers/net/ethernet/freescale/ucc_geth.c: In function 'ucc_geth_alloc_tx':
   drivers/net/ethernet/freescale/ucc_geth.c:2142:31: warning: variable 'uf_info' set but not used [-Wunused-but-set-variable]
    2142 |         struct ucc_fast_info *uf_info;
         |                               ^~~~~~~
   drivers/net/ethernet/freescale/ucc_geth.c: In function 'ucc_geth_alloc_rx':
   drivers/net/ethernet/freescale/ucc_geth.c:2204:31: warning: variable 'uf_info' set but not used [-Wunused-but-set-variable]
    2204 |         struct ucc_fast_info *uf_info;
         |                               ^~~~~~~
   drivers/net/ethernet/freescale/ucc_geth.c: In function 'ucc_geth_startup':
   drivers/net/ethernet/freescale/ucc_geth.c:2271:13: warning: variable 'ifstat' set but not used [-Wunused-but-set-variable]
    2271 |         u32 ifstat, i, j, size, l2qt, l3qt;
         |             ^~~~~~
   drivers/net/ethernet/freescale/ucc_geth.c:2261:62: warning: variable 'p_82xx_addr_filt' set but not used [-Wunused-but-set-variable]
    2261 |         struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt;
         |                                                              ^~~~~~~~~~~~~~~~
   drivers/net/ethernet/freescale/ucc_geth.c: In function 'ucc_geth_rx':
   drivers/net/ethernet/freescale/ucc_geth.c:2996:13: warning: variable 'bdBuffer' set but not used [-Wunused-but-set-variable]
    2996 |         u8 *bdBuffer;
         |             ^~~~~~~~
   drivers/net/ethernet/freescale/ucc_geth.c: In function 'ucc_geth_irq_handler':
   drivers/net/ethernet/freescale/ucc_geth.c:3149:31: warning: variable 'ug_info' set but not used [-Wunused-but-set-variable]
    3149 |         struct ucc_geth_info *ug_info;
         |                               ^~~~~~~
   drivers/net/ethernet/freescale/ucc_geth.c: In function 'ucc_geth_probe':
>> drivers/net/ethernet/freescale/ucc_geth.c:3608:42: error: expected ')' before numeric constant
    3608 |         res = platform_get_resource(ofdev 0, IORESOURCE_MEM);
         |                                    ~     ^~
         |                                          )
>> drivers/net/ethernet/freescale/ucc_geth.c:3608:15: error: too few arguments to function 'platform_get_resource'
    3608 |         res = platform_get_resource(ofdev 0, IORESOURCE_MEM);
         |               ^~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/net/ethernet/freescale/ucc_geth.c:36:
   include/linux/platform_device.h:58:25: note: declared here
      58 | extern struct resource *platform_get_resource(struct platform_device *,
         |                         ^~~~~~~~~~~~~~~~~~~~~


vim +3608 drivers/net/ethernet/freescale/ucc_geth.c

  3555	
  3556	static int ucc_geth_probe(struct platform_device* ofdev)
  3557	{
  3558		struct device *device = &ofdev->dev;
  3559		struct device_node *np = ofdev->dev.of_node;
  3560		struct net_device *dev = NULL;
  3561		struct ucc_geth_private *ugeth = NULL;
  3562		struct ucc_geth_info *ug_info;
  3563		struct resource *res;
  3564		int err, ucc_num, max_speed = 0;
  3565		const unsigned int *prop;
  3566		phy_interface_t phy_interface;
  3567		static const int enet_to_speed[] = {
  3568			SPEED_10, SPEED_10, SPEED_10,
  3569			SPEED_100, SPEED_100, SPEED_100,
  3570			SPEED_1000, SPEED_1000, SPEED_1000, SPEED_1000,
  3571		};
  3572		static const phy_interface_t enet_to_phy_interface[] = {
  3573			PHY_INTERFACE_MODE_MII, PHY_INTERFACE_MODE_RMII,
  3574			PHY_INTERFACE_MODE_RGMII, PHY_INTERFACE_MODE_MII,
  3575			PHY_INTERFACE_MODE_RMII, PHY_INTERFACE_MODE_RGMII,
  3576			PHY_INTERFACE_MODE_GMII, PHY_INTERFACE_MODE_RGMII,
  3577			PHY_INTERFACE_MODE_TBI, PHY_INTERFACE_MODE_RTBI,
  3578			PHY_INTERFACE_MODE_SGMII,
  3579		};
  3580	
  3581		ugeth_vdbg("%s: IN", __func__);
  3582	
  3583		prop = of_get_property(np, "cell-index", NULL);
  3584		if (!prop) {
  3585			prop = of_get_property(np, "device-id", NULL);
  3586			if (!prop)
  3587				return -ENODEV;
  3588		}
  3589	
  3590		ucc_num = *prop - 1;
  3591		if ((ucc_num < 0) || (ucc_num > 7))
  3592			return -ENODEV;
  3593	
  3594		ug_info = devm_kmemdup(&ofdev->dev, &ugeth_primary_info,
  3595				       sizeof(*ug_info), GFP_KERNEL);
  3596		if (!ug_info)
  3597			return -ENOMEM;
  3598	
  3599		ug_info->uf_info.ucc_num = ucc_num;
  3600	
  3601		err = ucc_geth_parse_clock(np, "rx", &ug_info->uf_info.rx_clock);
  3602		if (err)
  3603			return err;
  3604		err = ucc_geth_parse_clock(np, "tx", &ug_info->uf_info.tx_clock);
  3605		if (err)
  3606			return err;
  3607	
> 3608		res = platform_get_resource(ofdev 0, IORESOURCE_MEM);
  3609		if (!res)
  3610			return -ENODEV;
  3611	
  3612		ug_info->uf_info.regs = res->start;
  3613		ug_info->uf_info.irq = platform_get_irq(ofdev, 0);
  3614	
  3615		ug_info->phy_node = of_parse_phandle(np, "phy-handle", 0);
  3616		if (!ug_info->phy_node && of_phy_is_fixed_link(np)) {
  3617			/*
  3618			 * In the case of a fixed PHY, the DT node associated
  3619			 * to the PHY is the Ethernet MAC DT node.
  3620			 */
  3621			err = of_phy_register_fixed_link(np);
  3622			if (err)
  3623				return err;
  3624			ug_info->phy_node = of_node_get(np);
  3625		}
  3626	
  3627		/* Find the TBI PHY node.  If it's not there, we don't support SGMII */
  3628		ug_info->tbi_node = of_parse_phandle(np, "tbi-handle", 0);
  3629	
  3630		/* get the phy interface type, or default to MII */
  3631		prop = of_get_property(np, "phy-connection-type", NULL);
  3632		if (!prop) {
  3633			/* handle interface property present in old trees */
  3634			prop = of_get_property(ug_info->phy_node, "interface", NULL);
  3635			if (prop != NULL) {
  3636				phy_interface = enet_to_phy_interface[*prop];
  3637				max_speed = enet_to_speed[*prop];
  3638			} else
  3639				phy_interface = PHY_INTERFACE_MODE_MII;
  3640		} else {
  3641			phy_interface = to_phy_interface((const char *)prop);
  3642		}
  3643	
  3644		/* get speed, or derive from PHY interface */
  3645		if (max_speed == 0)
  3646			switch (phy_interface) {
  3647			case PHY_INTERFACE_MODE_GMII:
  3648			case PHY_INTERFACE_MODE_RGMII:
  3649			case PHY_INTERFACE_MODE_RGMII_ID:
  3650			case PHY_INTERFACE_MODE_RGMII_RXID:
  3651			case PHY_INTERFACE_MODE_RGMII_TXID:
  3652			case PHY_INTERFACE_MODE_TBI:
  3653			case PHY_INTERFACE_MODE_RTBI:
  3654			case PHY_INTERFACE_MODE_SGMII:
  3655				max_speed = SPEED_1000;
  3656				break;
  3657			default:
  3658				max_speed = SPEED_100;
  3659				break;
  3660			}
  3661	
  3662		if (max_speed == SPEED_1000) {
  3663			unsigned int snums = qe_get_num_of_snums();
  3664	
  3665			/* configure muram FIFOs for gigabit operation */
  3666			ug_info->uf_info.urfs = UCC_GETH_URFS_GIGA_INIT;
  3667			ug_info->uf_info.urfet = UCC_GETH_URFET_GIGA_INIT;
  3668			ug_info->uf_info.urfset = UCC_GETH_URFSET_GIGA_INIT;
  3669			ug_info->uf_info.utfs = UCC_GETH_UTFS_GIGA_INIT;
  3670			ug_info->uf_info.utfet = UCC_GETH_UTFET_GIGA_INIT;
  3671			ug_info->uf_info.utftt = UCC_GETH_UTFTT_GIGA_INIT;
  3672			ug_info->numThreadsTx = UCC_GETH_NUM_OF_THREADS_4;
  3673	
  3674			/* If QE's snum number is 46/76 which means we need to support
  3675			 * 4 UECs at 1000Base-T simultaneously, we need to allocate
  3676			 * more Threads to Rx.
  3677			 */
  3678			if ((snums == 76) || (snums == 46))
  3679				ug_info->numThreadsRx = UCC_GETH_NUM_OF_THREADS_6;
  3680			else
  3681				ug_info->numThreadsRx = UCC_GETH_NUM_OF_THREADS_4;
  3682		}
  3683	
  3684		if (netif_msg_probe(&debug))
  3685			pr_info("UCC%1d at 0x%8llx (irq = %d)\n",
  3686				ug_info->uf_info.ucc_num + 1,
  3687				(u64)ug_info->uf_info.regs,
  3688				ug_info->uf_info.irq);
  3689	
  3690		/* Create an ethernet device instance */
  3691		dev = devm_alloc_etherdev(&ofdev->dev, sizeof(*ugeth));
  3692		if (!dev) {
  3693			err = -ENOMEM;
  3694			goto err_deregister_fixed_link;
  3695		}
  3696	
  3697		ugeth = netdev_priv(dev);
  3698		spin_lock_init(&ugeth->lock);
  3699	
  3700		/* Create CQs for hash tables */
  3701		INIT_LIST_HEAD(&ugeth->group_hash_q);
  3702		INIT_LIST_HEAD(&ugeth->ind_hash_q);
  3703	
  3704		dev_set_drvdata(device, dev);
  3705	
  3706		/* Set the dev->base_addr to the gfar reg region */
  3707		dev->base_addr = (unsigned long)(ug_info->uf_info.regs);
  3708	
  3709		SET_NETDEV_DEV(dev, device);
  3710	
  3711		/* Fill in the dev structure */
  3712		uec_set_ethtool_ops(dev);
  3713		dev->netdev_ops = &ucc_geth_netdev_ops;
  3714		dev->watchdog_timeo = TX_TIMEOUT;
  3715		INIT_WORK(&ugeth->timeout_work, ucc_geth_timeout_work);
  3716		netif_napi_add(dev, &ugeth->napi, ucc_geth_poll);
  3717		dev->mtu = 1500;
  3718		dev->max_mtu = 1518;
  3719	
  3720		ugeth->msg_enable = netif_msg_init(debug.msg_enable, UGETH_MSG_DEFAULT);
  3721		ugeth->phy_interface = phy_interface;
  3722		ugeth->max_speed = max_speed;
  3723	
  3724		/* Carrier starts down, phylib will bring it up */
  3725		netif_carrier_off(dev);
  3726	
  3727		err = devm_register_netdev(&ofdev->dev, dev);
  3728		if (err) {
  3729			if (netif_msg_probe(ugeth))
  3730				pr_err("%s: Cannot register net device, aborting\n",
  3731				       dev->name);
  3732			goto err_deregister_fixed_link;
  3733		}
  3734	
  3735		err = of_get_ethdev_address(np, dev);
  3736		if (err == -EPROBE_DEFER)
  3737			goto err_deregister_fixed_link;
  3738	
  3739		ugeth->ug_info = ug_info;
  3740		ugeth->dev = device;
  3741		ugeth->ndev = dev;
  3742		ugeth->node = np;
  3743	
  3744		return 0;
  3745	
  3746	err_deregister_fixed_link:
  3747		if (of_phy_is_fixed_link(np))
  3748			of_phy_deregister_fixed_link(np);
  3749		of_node_put(ug_info->tbi_node);
  3750		of_node_put(ug_info->phy_node);
  3751		return err;
  3752	}
  3753
kernel test robot Nov. 10, 2024, 12:37 p.m. UTC | #2
Hi Rosen,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]

url:    https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/net-use-pdev-instead-of-OF-funcs/20241110-073939
base:   net-next/main
patch link:    https://lore.kernel.org/r/20241109233821.8619-1-rosenp%40gmail.com
patch subject: [PATCH net-next] net: use pdev instead of OF funcs
config: arm-moxart_defconfig (https://download.01.org/0day-ci/archive/20241110/202411102000.aEYCgzAp-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241110/202411102000.aEYCgzAp-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411102000.aEYCgzAp-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/moxa/moxart_ether.c: In function 'moxart_mac_probe':
>> drivers/net/ethernet/moxa/moxart_ether.c:457:29: warning: unused variable 'node' [-Wunused-variable]
     457 |         struct device_node *node = p_dev->of_node;
         |                             ^~~~


vim +/node +457 drivers/net/ethernet/moxa/moxart_ether.c

6c821bd9edc956 Jonas Jensen      2013-08-08  453  
6c821bd9edc956 Jonas Jensen      2013-08-08  454  static int moxart_mac_probe(struct platform_device *pdev)
6c821bd9edc956 Jonas Jensen      2013-08-08  455  {
6c821bd9edc956 Jonas Jensen      2013-08-08  456  	struct device *p_dev = &pdev->dev;
6c821bd9edc956 Jonas Jensen      2013-08-08 @457  	struct device_node *node = p_dev->of_node;
6c821bd9edc956 Jonas Jensen      2013-08-08  458  	struct net_device *ndev;
6c821bd9edc956 Jonas Jensen      2013-08-08  459  	struct moxart_mac_priv_t *priv;
6c821bd9edc956 Jonas Jensen      2013-08-08  460  	struct resource *res;
6c821bd9edc956 Jonas Jensen      2013-08-08  461  	unsigned int irq;
6c821bd9edc956 Jonas Jensen      2013-08-08  462  	int ret;
6c821bd9edc956 Jonas Jensen      2013-08-08  463  
6c821bd9edc956 Jonas Jensen      2013-08-08  464  	ndev = alloc_etherdev(sizeof(struct moxart_mac_priv_t));
6c821bd9edc956 Jonas Jensen      2013-08-08  465  	if (!ndev)
6c821bd9edc956 Jonas Jensen      2013-08-08  466  		return -ENOMEM;
6c821bd9edc956 Jonas Jensen      2013-08-08  467  
c22f4680de3d5a Rosen Penev       2024-11-09  468  	irq = platform_get_irq(pdev, 0);
6c821bd9edc956 Jonas Jensen      2013-08-08  469  	if (irq <= 0) {
c22f4680de3d5a Rosen Penev       2024-11-09  470  		netdev_err(ndev, "platform_get_irq failed\n");
bdfd6304c8e243 Wei Yongjun       2013-10-08  471  		ret = -EINVAL;
bdfd6304c8e243 Wei Yongjun       2013-10-08  472  		goto irq_map_fail;
6c821bd9edc956 Jonas Jensen      2013-08-08  473  	}
6c821bd9edc956 Jonas Jensen      2013-08-08  474  
6c821bd9edc956 Jonas Jensen      2013-08-08  475  	priv = netdev_priv(ndev);
6c821bd9edc956 Jonas Jensen      2013-08-08  476  	priv->ndev = ndev;
5dac33ad6f0d1d Christoph Hellwig 2019-02-11  477  	priv->pdev = pdev;
6c821bd9edc956 Jonas Jensen      2013-08-08  478  
35cba15a504bf4 Yang Yingliang    2021-06-07  479  	priv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
1d3cd1773fddfd Dan Carpenter     2016-03-02  480  	if (IS_ERR(priv->base)) {
1d3cd1773fddfd Dan Carpenter     2016-03-02  481  		ret = PTR_ERR(priv->base);
6c821bd9edc956 Jonas Jensen      2013-08-08  482  		goto init_fail;
6c821bd9edc956 Jonas Jensen      2013-08-08  483  	}
35cba15a504bf4 Yang Yingliang    2021-06-07  484  	ndev->base_addr = res->start;
6c821bd9edc956 Jonas Jensen      2013-08-08  485  
f4693b81ea3802 Sergei Antonov    2022-08-18  486  	ret = platform_get_ethdev_address(p_dev, ndev);
f4693b81ea3802 Sergei Antonov    2022-08-18  487  	if (ret == -EPROBE_DEFER)
f4693b81ea3802 Sergei Antonov    2022-08-18  488  		goto init_fail;
f4693b81ea3802 Sergei Antonov    2022-08-18  489  	if (ret)
f4693b81ea3802 Sergei Antonov    2022-08-18  490  		eth_hw_addr_random(ndev);
f4693b81ea3802 Sergei Antonov    2022-08-18  491  	moxart_update_mac_address(ndev);
f4693b81ea3802 Sergei Antonov    2022-08-18  492  
6c821bd9edc956 Jonas Jensen      2013-08-08  493  	spin_lock_init(&priv->txlock);
6c821bd9edc956 Jonas Jensen      2013-08-08  494  
6c821bd9edc956 Jonas Jensen      2013-08-08  495  	priv->tx_buf_size = TX_BUF_SIZE;
9fe1b3bc8d9182 Jonas Jensen      2014-08-25  496  	priv->rx_buf_size = RX_BUF_SIZE;
6c821bd9edc956 Jonas Jensen      2013-08-08  497  
3a12df22a8f689 Sergei Antonov    2022-08-12  498  	priv->tx_desc_base = dma_alloc_coherent(p_dev, TX_REG_DESC_SIZE *
6c821bd9edc956 Jonas Jensen      2013-08-08  499  						TX_DESC_NUM, &priv->tx_base,
6c821bd9edc956 Jonas Jensen      2013-08-08  500  						GFP_DMA | GFP_KERNEL);
e8048b84bbfd3e SZ Lin            2017-07-29  501  	if (!priv->tx_desc_base) {
bdfd6304c8e243 Wei Yongjun       2013-10-08  502  		ret = -ENOMEM;
6c821bd9edc956 Jonas Jensen      2013-08-08  503  		goto init_fail;
bdfd6304c8e243 Wei Yongjun       2013-10-08  504  	}
6c821bd9edc956 Jonas Jensen      2013-08-08  505  
3a12df22a8f689 Sergei Antonov    2022-08-12  506  	priv->rx_desc_base = dma_alloc_coherent(p_dev, RX_REG_DESC_SIZE *
6c821bd9edc956 Jonas Jensen      2013-08-08  507  						RX_DESC_NUM, &priv->rx_base,
6c821bd9edc956 Jonas Jensen      2013-08-08  508  						GFP_DMA | GFP_KERNEL);
e8048b84bbfd3e SZ Lin            2017-07-29  509  	if (!priv->rx_desc_base) {
bdfd6304c8e243 Wei Yongjun       2013-10-08  510  		ret = -ENOMEM;
6c821bd9edc956 Jonas Jensen      2013-08-08  511  		goto init_fail;
bdfd6304c8e243 Wei Yongjun       2013-10-08  512  	}
6c821bd9edc956 Jonas Jensen      2013-08-08  513  
6da2ec56059c3c Kees Cook         2018-06-12  514  	priv->tx_buf_base = kmalloc_array(priv->tx_buf_size, TX_DESC_NUM,
c9ac080b25d98d Julia Lawall      2022-02-10  515  					  GFP_KERNEL);
bdfd6304c8e243 Wei Yongjun       2013-10-08  516  	if (!priv->tx_buf_base) {
bdfd6304c8e243 Wei Yongjun       2013-10-08  517  		ret = -ENOMEM;
6c821bd9edc956 Jonas Jensen      2013-08-08  518  		goto init_fail;
bdfd6304c8e243 Wei Yongjun       2013-10-08  519  	}
6c821bd9edc956 Jonas Jensen      2013-08-08  520  
6da2ec56059c3c Kees Cook         2018-06-12  521  	priv->rx_buf_base = kmalloc_array(priv->rx_buf_size, RX_DESC_NUM,
c9ac080b25d98d Julia Lawall      2022-02-10  522  					  GFP_KERNEL);
bdfd6304c8e243 Wei Yongjun       2013-10-08  523  	if (!priv->rx_buf_base) {
bdfd6304c8e243 Wei Yongjun       2013-10-08  524  		ret = -ENOMEM;
6c821bd9edc956 Jonas Jensen      2013-08-08  525  		goto init_fail;
bdfd6304c8e243 Wei Yongjun       2013-10-08  526  	}
6c821bd9edc956 Jonas Jensen      2013-08-08  527  
6c821bd9edc956 Jonas Jensen      2013-08-08  528  	platform_set_drvdata(pdev, ndev);
6c821bd9edc956 Jonas Jensen      2013-08-08  529  
6c821bd9edc956 Jonas Jensen      2013-08-08  530  	ret = devm_request_irq(p_dev, irq, moxart_mac_interrupt, 0,
6c821bd9edc956 Jonas Jensen      2013-08-08  531  			       pdev->name, ndev);
6c821bd9edc956 Jonas Jensen      2013-08-08  532  	if (ret) {
6c821bd9edc956 Jonas Jensen      2013-08-08  533  		netdev_err(ndev, "devm_request_irq failed\n");
6c821bd9edc956 Jonas Jensen      2013-08-08  534  		goto init_fail;
6c821bd9edc956 Jonas Jensen      2013-08-08  535  	}
6c821bd9edc956 Jonas Jensen      2013-08-08  536  
6c821bd9edc956 Jonas Jensen      2013-08-08  537  	ndev->netdev_ops = &moxart_netdev_ops;
b707b89f7be361 Jakub Kicinski    2022-05-06  538  	netif_napi_add_weight(ndev, &priv->napi, moxart_rx_poll, RX_DESC_NUM);
6c821bd9edc956 Jonas Jensen      2013-08-08  539  	ndev->priv_flags |= IFF_UNICAST_FLT;
6c821bd9edc956 Jonas Jensen      2013-08-08  540  	ndev->irq = irq;
6c821bd9edc956 Jonas Jensen      2013-08-08  541  
6c821bd9edc956 Jonas Jensen      2013-08-08  542  	SET_NETDEV_DEV(ndev, &pdev->dev);
6c821bd9edc956 Jonas Jensen      2013-08-08  543  
6c821bd9edc956 Jonas Jensen      2013-08-08  544  	ret = register_netdev(ndev);
c78eaeebe855fd Pavel Skripkin    2021-07-09  545  	if (ret)
6c821bd9edc956 Jonas Jensen      2013-08-08  546  		goto init_fail;
6c821bd9edc956 Jonas Jensen      2013-08-08  547  
6c821bd9edc956 Jonas Jensen      2013-08-08  548  	netdev_dbg(ndev, "%s: IRQ=%d address=%pM\n",
6c821bd9edc956 Jonas Jensen      2013-08-08  549  		   __func__, ndev->irq, ndev->dev_addr);
6c821bd9edc956 Jonas Jensen      2013-08-08  550  
6c821bd9edc956 Jonas Jensen      2013-08-08  551  	return 0;
6c821bd9edc956 Jonas Jensen      2013-08-08  552  
6c821bd9edc956 Jonas Jensen      2013-08-08  553  init_fail:
6c821bd9edc956 Jonas Jensen      2013-08-08  554  	netdev_err(ndev, "init failed\n");
6c821bd9edc956 Jonas Jensen      2013-08-08  555  	moxart_mac_free_memory(ndev);
bdfd6304c8e243 Wei Yongjun       2013-10-08  556  irq_map_fail:
bdfd6304c8e243 Wei Yongjun       2013-10-08  557  	free_netdev(ndev);
6c821bd9edc956 Jonas Jensen      2013-08-08  558  	return ret;
6c821bd9edc956 Jonas Jensen      2013-08-08  559  }
6c821bd9edc956 Jonas Jensen      2013-08-08  560
Francois Romieu Nov. 10, 2024, 4:37 p.m. UTC | #3
Rosen Penev <rosenp@gmail.com> :
> np here is ofdev->dev.of_node. Better to use the proper functions as
> there's no use of children or anything else.
> 
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
[...]
> diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
> index 894911f3d560..f079242c33e2 100644
> --- a/drivers/net/ethernet/via/via-rhine.c
> +++ b/drivers/net/ethernet/via/via-rhine.c
> @@ -1127,7 +1127,7 @@ static int rhine_init_one_platform(struct platform_device *pdev)
>  	if (IS_ERR(ioaddr))
>  		return PTR_ERR(ioaddr);
>  
> -	irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
> +	irq = platform_get_irq(pdev, 0);
>  	if (!irq)
>  		return -EINVAL;
>  
> diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c
> index dd4a07c97eee..4aac9599c14d 100644
> --- a/drivers/net/ethernet/via/via-velocity.c
> +++ b/drivers/net/ethernet/via/via-velocity.c
> @@ -2950,7 +2950,7 @@ static int velocity_platform_probe(struct platform_device *pdev)
>  	if (!info)
>  		return -EINVAL;
>  
> -	irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
> +	irq = platform_get_irq(pdev, 0);
>  	if (!irq)
>  		return -EINVAL;
>  

The change makes sense. However neither the description nor the commit message
really match here.
Rob Herring (Arm) Nov. 11, 2024, 4:20 p.m. UTC | #4
On Sat, Nov 9, 2024 at 5:40 PM Rosen Penev <rosenp@gmail.com> wrote:
>
> np here is ofdev->dev.of_node. Better to use the proper functions as
> there's no use of children or anything else.

Your commit message needs some work.

> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  drivers/net/can/grcan.c                       |  2 +-
>  drivers/net/can/mscan/mpc5xxx_can.c           |  2 +-
>  drivers/net/dsa/bcm_sf2.c                     |  4 ++--
>  drivers/net/ethernet/allwinner/sun4i-emac.c   |  2 +-
>  drivers/net/ethernet/freescale/fec_mpc52xx.c  | 23 ++++++++++---------
>  .../net/ethernet/freescale/fec_mpc52xx_phy.c  | 12 ++++++----
>  .../net/ethernet/freescale/fs_enet/mac-fcc.c  |  2 +-
>  .../net/ethernet/freescale/fs_enet/mac-fec.c  |  2 +-
>  .../net/ethernet/freescale/fs_enet/mac-scc.c  |  2 +-
>  .../net/ethernet/freescale/fs_enet/mii-fec.c  | 12 ++++++----
>  drivers/net/ethernet/freescale/ucc_geth.c     | 12 +++++-----
>  drivers/net/ethernet/marvell/mvneta.c         |  2 +-
>  drivers/net/ethernet/moxa/moxart_ether.c      |  4 ++--
>  .../ethernet/samsung/sxgbe/sxgbe_platform.c   |  8 +++----
>  drivers/net/ethernet/via/via-rhine.c          |  2 +-
>  drivers/net/ethernet/via/via-velocity.c       |  2 +-
>  drivers/net/ethernet/xilinx/ll_temac_mdio.c   |  6 ++---
>  drivers/net/mdio/mdio-mux-mmioreg.c           | 16 +++++++------
>  drivers/net/wan/fsl_ucc_hdlc.c                | 10 ++++----
>  19 files changed, 66 insertions(+), 59 deletions(-)
>
> diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
> index cdf0ec9fa7f3..0a2cc0ba219f 100644
> --- a/drivers/net/can/grcan.c
> +++ b/drivers/net/can/grcan.c
> @@ -1673,7 +1673,7 @@ static int grcan_probe(struct platform_device *ofdev)
>                 goto exit_error;
>         }
>
> -       irq = irq_of_parse_and_map(np, GRCAN_IRQIX_IRQ);
> +       irq = platform_get_irq(ofdev, GRCAN_IRQIX_IRQ);
>         if (!irq) {
>                 dev_err(&ofdev->dev, "no irq found\n");
>                 err = -ENODEV;
> diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
> index 0080c39ee182..252ad40bdb97 100644
> --- a/drivers/net/can/mscan/mpc5xxx_can.c
> +++ b/drivers/net/can/mscan/mpc5xxx_can.c
> @@ -300,7 +300,7 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
>         if (!base)
>                 return dev_err_probe(&ofdev->dev, err, "couldn't ioremap\n");
>
> -       irq = irq_of_parse_and_map(np, 0);
> +       irq = platform_get_irq(ofdev, 0);
>         if (!irq) {
>                 dev_err(&ofdev->dev, "no irq found\n");
>                 err = -ENODEV;
> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> index 43bde1f583ff..9229582efd05 100644
> --- a/drivers/net/dsa/bcm_sf2.c
> +++ b/drivers/net/dsa/bcm_sf2.c
> @@ -1443,8 +1443,8 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
>                 of_node_put(ports);
>         }
>
> -       priv->irq0 = irq_of_parse_and_map(dn, 0);
> -       priv->irq1 = irq_of_parse_and_map(dn, 1);
> +       priv->irq0 = platform_get_irq(pdev, 0);
> +       priv->irq1 = platform_get_irq(pdev, 1);
>
>         base = &priv->core;
>         for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
> diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
> index 2f516b950f4e..18df8d1d93fd 100644
> --- a/drivers/net/ethernet/allwinner/sun4i-emac.c
> +++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
> @@ -995,7 +995,7 @@ static int emac_probe(struct platform_device *pdev)
>
>         /* fill in parameters for net-dev structure */
>         ndev->base_addr = (unsigned long)db->membase;
> -       ndev->irq = irq_of_parse_and_map(np, 0);
> +       ndev->irq = platform_get_irq(pdev, 0);
>         if (ndev->irq == -ENXIO) {
>                 netdev_err(ndev, "No irq resource\n");
>                 ret = ndev->irq;
> diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.c b/drivers/net/ethernet/freescale/fec_mpc52xx.c
> index 2bfaf14f65c8..553d33a98c99 100644
> --- a/drivers/net/ethernet/freescale/fec_mpc52xx.c
> +++ b/drivers/net/ethernet/freescale/fec_mpc52xx.c
> @@ -811,7 +811,7 @@ static int mpc52xx_fec_probe(struct platform_device *op)
>         int rv;
>         struct net_device *ndev;
>         struct mpc52xx_fec_priv *priv = NULL;
> -       struct resource mem;
> +       struct resource *mem;
>         const u32 *prop;
>         int prop_size;
>         struct device_node *np = op->dev.of_node;
> @@ -828,20 +828,21 @@ static int mpc52xx_fec_probe(struct platform_device *op)
>         priv->ndev = ndev;
>
>         /* Reserve FEC control zone */
> -       rv = of_address_to_resource(np, 0, &mem);
> -       if (rv) {
> +       mem = platform_get_resource(op, 0, IORESOURCE_MEM);
> +       if (!mem) {
>                 pr_err("Error while parsing device node resource\n");
> +               rv = -ENODEV;
>                 goto err_netdev;
>         }
> -       if (resource_size(&mem) < sizeof(struct mpc52xx_fec)) {
> +       if (resource_size(mem) < sizeof(struct mpc52xx_fec)) {
>                 pr_err("invalid resource size (%lx < %x), check mpc52xx_devices.c\n",
> -                      (unsigned long)resource_size(&mem),
> +                      (unsigned long)resource_size(mem),
>                        sizeof(struct mpc52xx_fec));
>                 rv = -EINVAL;
>                 goto err_netdev;
>         }
>
> -       if (!request_mem_region(mem.start, sizeof(struct mpc52xx_fec),
> +       if (!request_mem_region(mem->start, sizeof(struct mpc52xx_fec),
>                                 DRIVER_NAME)) {
>                 rv = -EBUSY;
>                 goto err_netdev;
> @@ -851,13 +852,13 @@ static int mpc52xx_fec_probe(struct platform_device *op)
>         ndev->netdev_ops        = &mpc52xx_fec_netdev_ops;
>         ndev->ethtool_ops       = &mpc52xx_fec_ethtool_ops;
>         ndev->watchdog_timeo    = FEC_WATCHDOG_TIMEOUT;
> -       ndev->base_addr         = mem.start;
> +       ndev->base_addr         = mem->start;
>         SET_NETDEV_DEV(ndev, &op->dev);
>
>         spin_lock_init(&priv->lock);
>
>         /* ioremap the zones */
> -       priv->fec = ioremap(mem.start, sizeof(struct mpc52xx_fec));
> +       priv->fec = ioremap(mem->start, sizeof(struct mpc52xx_fec));

Generally, devm_platform_ioremap_resource(),
devm_platform_get_and_ioremap_resource(), etc. are preferred. So if
we're going to rework things, rework them to use those.

Rob
Rosen Penev Nov. 11, 2024, 6:15 p.m. UTC | #5
On Mon, Nov 11, 2024 at 8:21 AM Rob Herring <robh@kernel.org> wrote:
>
> On Sat, Nov 9, 2024 at 5:40 PM Rosen Penev <rosenp@gmail.com> wrote:
> >
> > np here is ofdev->dev.of_node. Better to use the proper functions as
> > there's no use of children or anything else.
>
> Your commit message needs some work.
>
> > Signed-off-by: Rosen Penev <rosenp@gmail.com>
> > ---
> >  drivers/net/can/grcan.c                       |  2 +-
> >  drivers/net/can/mscan/mpc5xxx_can.c           |  2 +-
> >  drivers/net/dsa/bcm_sf2.c                     |  4 ++--
> >  drivers/net/ethernet/allwinner/sun4i-emac.c   |  2 +-
> >  drivers/net/ethernet/freescale/fec_mpc52xx.c  | 23 ++++++++++---------
> >  .../net/ethernet/freescale/fec_mpc52xx_phy.c  | 12 ++++++----
> >  .../net/ethernet/freescale/fs_enet/mac-fcc.c  |  2 +-
> >  .../net/ethernet/freescale/fs_enet/mac-fec.c  |  2 +-
> >  .../net/ethernet/freescale/fs_enet/mac-scc.c  |  2 +-
> >  .../net/ethernet/freescale/fs_enet/mii-fec.c  | 12 ++++++----
> >  drivers/net/ethernet/freescale/ucc_geth.c     | 12 +++++-----
> >  drivers/net/ethernet/marvell/mvneta.c         |  2 +-
> >  drivers/net/ethernet/moxa/moxart_ether.c      |  4 ++--
> >  .../ethernet/samsung/sxgbe/sxgbe_platform.c   |  8 +++----
> >  drivers/net/ethernet/via/via-rhine.c          |  2 +-
> >  drivers/net/ethernet/via/via-velocity.c       |  2 +-
> >  drivers/net/ethernet/xilinx/ll_temac_mdio.c   |  6 ++---
> >  drivers/net/mdio/mdio-mux-mmioreg.c           | 16 +++++++------
> >  drivers/net/wan/fsl_ucc_hdlc.c                | 10 ++++----
> >  19 files changed, 66 insertions(+), 59 deletions(-)
> >
> > diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
> > index cdf0ec9fa7f3..0a2cc0ba219f 100644
> > --- a/drivers/net/can/grcan.c
> > +++ b/drivers/net/can/grcan.c
> > @@ -1673,7 +1673,7 @@ static int grcan_probe(struct platform_device *ofdev)
> >                 goto exit_error;
> >         }
> >
> > -       irq = irq_of_parse_and_map(np, GRCAN_IRQIX_IRQ);
> > +       irq = platform_get_irq(ofdev, GRCAN_IRQIX_IRQ);
> >         if (!irq) {
> >                 dev_err(&ofdev->dev, "no irq found\n");
> >                 err = -ENODEV;
> > diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
> > index 0080c39ee182..252ad40bdb97 100644
> > --- a/drivers/net/can/mscan/mpc5xxx_can.c
> > +++ b/drivers/net/can/mscan/mpc5xxx_can.c
> > @@ -300,7 +300,7 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev)
> >         if (!base)
> >                 return dev_err_probe(&ofdev->dev, err, "couldn't ioremap\n");
> >
> > -       irq = irq_of_parse_and_map(np, 0);
> > +       irq = platform_get_irq(ofdev, 0);
> >         if (!irq) {
> >                 dev_err(&ofdev->dev, "no irq found\n");
> >                 err = -ENODEV;
> > diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> > index 43bde1f583ff..9229582efd05 100644
> > --- a/drivers/net/dsa/bcm_sf2.c
> > +++ b/drivers/net/dsa/bcm_sf2.c
> > @@ -1443,8 +1443,8 @@ static int bcm_sf2_sw_probe(struct platform_device *pdev)
> >                 of_node_put(ports);
> >         }
> >
> > -       priv->irq0 = irq_of_parse_and_map(dn, 0);
> > -       priv->irq1 = irq_of_parse_and_map(dn, 1);
> > +       priv->irq0 = platform_get_irq(pdev, 0);
> > +       priv->irq1 = platform_get_irq(pdev, 1);
> >
> >         base = &priv->core;
> >         for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
> > diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
> > index 2f516b950f4e..18df8d1d93fd 100644
> > --- a/drivers/net/ethernet/allwinner/sun4i-emac.c
> > +++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
> > @@ -995,7 +995,7 @@ static int emac_probe(struct platform_device *pdev)
> >
> >         /* fill in parameters for net-dev structure */
> >         ndev->base_addr = (unsigned long)db->membase;
> > -       ndev->irq = irq_of_parse_and_map(np, 0);
> > +       ndev->irq = platform_get_irq(pdev, 0);
> >         if (ndev->irq == -ENXIO) {
> >                 netdev_err(ndev, "No irq resource\n");
> >                 ret = ndev->irq;
> > diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.c b/drivers/net/ethernet/freescale/fec_mpc52xx.c
> > index 2bfaf14f65c8..553d33a98c99 100644
> > --- a/drivers/net/ethernet/freescale/fec_mpc52xx.c
> > +++ b/drivers/net/ethernet/freescale/fec_mpc52xx.c
> > @@ -811,7 +811,7 @@ static int mpc52xx_fec_probe(struct platform_device *op)
> >         int rv;
> >         struct net_device *ndev;
> >         struct mpc52xx_fec_priv *priv = NULL;
> > -       struct resource mem;
> > +       struct resource *mem;
> >         const u32 *prop;
> >         int prop_size;
> >         struct device_node *np = op->dev.of_node;
> > @@ -828,20 +828,21 @@ static int mpc52xx_fec_probe(struct platform_device *op)
> >         priv->ndev = ndev;
> >
> >         /* Reserve FEC control zone */
> > -       rv = of_address_to_resource(np, 0, &mem);
> > -       if (rv) {
> > +       mem = platform_get_resource(op, 0, IORESOURCE_MEM);
> > +       if (!mem) {
> >                 pr_err("Error while parsing device node resource\n");
> > +               rv = -ENODEV;
> >                 goto err_netdev;
> >         }
> > -       if (resource_size(&mem) < sizeof(struct mpc52xx_fec)) {
> > +       if (resource_size(mem) < sizeof(struct mpc52xx_fec)) {
> >                 pr_err("invalid resource size (%lx < %x), check mpc52xx_devices.c\n",
> > -                      (unsigned long)resource_size(&mem),
> > +                      (unsigned long)resource_size(mem),
> >                        sizeof(struct mpc52xx_fec));
> >                 rv = -EINVAL;
> >                 goto err_netdev;
> >         }
> >
> > -       if (!request_mem_region(mem.start, sizeof(struct mpc52xx_fec),
> > +       if (!request_mem_region(mem->start, sizeof(struct mpc52xx_fec),
> >                                 DRIVER_NAME)) {
> >                 rv = -EBUSY;
> >                 goto err_netdev;
> > @@ -851,13 +852,13 @@ static int mpc52xx_fec_probe(struct platform_device *op)
> >         ndev->netdev_ops        = &mpc52xx_fec_netdev_ops;
> >         ndev->ethtool_ops       = &mpc52xx_fec_ethtool_ops;
> >         ndev->watchdog_timeo    = FEC_WATCHDOG_TIMEOUT;
> > -       ndev->base_addr         = mem.start;
> > +       ndev->base_addr         = mem->start;
> >         SET_NETDEV_DEV(ndev, &op->dev);
> >
> >         spin_lock_init(&priv->lock);
> >
> >         /* ioremap the zones */
> > -       priv->fec = ioremap(mem.start, sizeof(struct mpc52xx_fec));
> > +       priv->fec = ioremap(mem->start, sizeof(struct mpc52xx_fec));
>
> Generally, devm_platform_ioremap_resource(),
> devm_platform_get_and_ioremap_resource(), etc. are preferred. So if
> we're going to rework things, rework them to use those.
I'm going to avoid that as I've been constantly getting requests to
test my changes on real hardware. I don't own anything that uses
fec_mpc52xx.c.

Plus, documentation states that netdev isn't too big of a fan of devm.

Oh and this file uses no devm of any kind.
>
> Rob
diff mbox series

Patch

diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
index cdf0ec9fa7f3..0a2cc0ba219f 100644
--- a/drivers/net/can/grcan.c
+++ b/drivers/net/can/grcan.c
@@ -1673,7 +1673,7 @@  static int grcan_probe(struct platform_device *ofdev)
 		goto exit_error;
 	}
 
-	irq = irq_of_parse_and_map(np, GRCAN_IRQIX_IRQ);
+	irq = platform_get_irq(ofdev, GRCAN_IRQIX_IRQ);
 	if (!irq) {
 		dev_err(&ofdev->dev, "no irq found\n");
 		err = -ENODEV;
diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c
index 0080c39ee182..252ad40bdb97 100644
--- a/drivers/net/can/mscan/mpc5xxx_can.c
+++ b/drivers/net/can/mscan/mpc5xxx_can.c
@@ -300,7 +300,7 @@  static int mpc5xxx_can_probe(struct platform_device *ofdev)
 	if (!base)
 		return dev_err_probe(&ofdev->dev, err, "couldn't ioremap\n");
 
-	irq = irq_of_parse_and_map(np, 0);
+	irq = platform_get_irq(ofdev, 0);
 	if (!irq) {
 		dev_err(&ofdev->dev, "no irq found\n");
 		err = -ENODEV;
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 43bde1f583ff..9229582efd05 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -1443,8 +1443,8 @@  static int bcm_sf2_sw_probe(struct platform_device *pdev)
 		of_node_put(ports);
 	}
 
-	priv->irq0 = irq_of_parse_and_map(dn, 0);
-	priv->irq1 = irq_of_parse_and_map(dn, 1);
+	priv->irq0 = platform_get_irq(pdev, 0);
+	priv->irq1 = platform_get_irq(pdev, 1);
 
 	base = &priv->core;
 	for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 2f516b950f4e..18df8d1d93fd 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -995,7 +995,7 @@  static int emac_probe(struct platform_device *pdev)
 
 	/* fill in parameters for net-dev structure */
 	ndev->base_addr = (unsigned long)db->membase;
-	ndev->irq = irq_of_parse_and_map(np, 0);
+	ndev->irq = platform_get_irq(pdev, 0);
 	if (ndev->irq == -ENXIO) {
 		netdev_err(ndev, "No irq resource\n");
 		ret = ndev->irq;
diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.c b/drivers/net/ethernet/freescale/fec_mpc52xx.c
index 2bfaf14f65c8..553d33a98c99 100644
--- a/drivers/net/ethernet/freescale/fec_mpc52xx.c
+++ b/drivers/net/ethernet/freescale/fec_mpc52xx.c
@@ -811,7 +811,7 @@  static int mpc52xx_fec_probe(struct platform_device *op)
 	int rv;
 	struct net_device *ndev;
 	struct mpc52xx_fec_priv *priv = NULL;
-	struct resource mem;
+	struct resource *mem;
 	const u32 *prop;
 	int prop_size;
 	struct device_node *np = op->dev.of_node;
@@ -828,20 +828,21 @@  static int mpc52xx_fec_probe(struct platform_device *op)
 	priv->ndev = ndev;
 
 	/* Reserve FEC control zone */
-	rv = of_address_to_resource(np, 0, &mem);
-	if (rv) {
+	mem = platform_get_resource(op, 0, IORESOURCE_MEM);
+	if (!mem) {
 		pr_err("Error while parsing device node resource\n");
+		rv = -ENODEV;
 		goto err_netdev;
 	}
-	if (resource_size(&mem) < sizeof(struct mpc52xx_fec)) {
+	if (resource_size(mem) < sizeof(struct mpc52xx_fec)) {
 		pr_err("invalid resource size (%lx < %x), check mpc52xx_devices.c\n",
-		       (unsigned long)resource_size(&mem),
+		       (unsigned long)resource_size(mem),
 		       sizeof(struct mpc52xx_fec));
 		rv = -EINVAL;
 		goto err_netdev;
 	}
 
-	if (!request_mem_region(mem.start, sizeof(struct mpc52xx_fec),
+	if (!request_mem_region(mem->start, sizeof(struct mpc52xx_fec),
 				DRIVER_NAME)) {
 		rv = -EBUSY;
 		goto err_netdev;
@@ -851,13 +852,13 @@  static int mpc52xx_fec_probe(struct platform_device *op)
 	ndev->netdev_ops	= &mpc52xx_fec_netdev_ops;
 	ndev->ethtool_ops	= &mpc52xx_fec_ethtool_ops;
 	ndev->watchdog_timeo	= FEC_WATCHDOG_TIMEOUT;
-	ndev->base_addr		= mem.start;
+	ndev->base_addr		= mem->start;
 	SET_NETDEV_DEV(ndev, &op->dev);
 
 	spin_lock_init(&priv->lock);
 
 	/* ioremap the zones */
-	priv->fec = ioremap(mem.start, sizeof(struct mpc52xx_fec));
+	priv->fec = ioremap(mem->start, sizeof(struct mpc52xx_fec));
 
 	if (!priv->fec) {
 		rv = -ENOMEM;
@@ -879,9 +880,9 @@  static int mpc52xx_fec_probe(struct platform_device *op)
 
 	/* Get the IRQ we need one by one */
 		/* Control */
-	ndev->irq = irq_of_parse_and_map(np, 0);
+	ndev->irq = platform_get_irq(op, 0);
 
-		/* RX */
+	/* RX */
 	priv->r_irq = bcom_get_task_irq(priv->rx_dmatsk);
 
 		/* TX */
@@ -967,7 +968,7 @@  static int mpc52xx_fec_probe(struct platform_device *op)
 		bcom_fec_tx_release(priv->tx_dmatsk);
 	iounmap(priv->fec);
 err_mem_region:
-	release_mem_region(mem.start, sizeof(struct mpc52xx_fec));
+	release_mem_region(mem->start, sizeof(struct mpc52xx_fec));
 err_netdev:
 	free_netdev(ndev);
 
diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx_phy.c b/drivers/net/ethernet/freescale/fec_mpc52xx_phy.c
index 3d073f0fae63..4ffab516f770 100644
--- a/drivers/net/ethernet/freescale/fec_mpc52xx_phy.c
+++ b/drivers/net/ethernet/freescale/fec_mpc52xx_phy.c
@@ -68,7 +68,7 @@  static int mpc52xx_fec_mdio_probe(struct platform_device *of)
 	struct device_node *np = of->dev.of_node;
 	struct mii_bus *bus;
 	struct mpc52xx_fec_mdio_priv *priv;
-	struct resource res;
+	struct resource *res;
 	int err;
 
 	bus = mdiobus_alloc();
@@ -85,16 +85,18 @@  static int mpc52xx_fec_mdio_probe(struct platform_device *of)
 	bus->write = mpc52xx_fec_mdio_write;
 
 	/* setup registers */
-	err = of_address_to_resource(np, 0, &res);
-	if (err)
+	res = platform_get_resource(of, 0, IORESOURCE_MEM);
+	if (!res) {
+		err = -ENODEV;
 		goto out_free;
-	priv->regs = ioremap(res.start, resource_size(&res));
+	}
+	priv->regs = ioremap(res->start, resource_size(res));
 	if (priv->regs == NULL) {
 		err = -ENOMEM;
 		goto out_free;
 	}
 
-	snprintf(bus->id, MII_BUS_ID_SIZE, "%pa", &res.start);
+	snprintf(bus->id, MII_BUS_ID_SIZE, "%pa", &res->start);
 	bus->priv = priv;
 
 	bus->parent = dev;
diff --git a/drivers/net/ethernet/freescale/fs_enet/mac-fcc.c b/drivers/net/ethernet/freescale/fs_enet/mac-fcc.c
index be63293511d9..8bed0ea11dd1 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mac-fcc.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mac-fcc.c
@@ -83,7 +83,7 @@  static int do_pd_setup(struct fs_enet_private *fep)
 	struct fs_platform_info *fpi = fep->fpi;
 	int ret = -EINVAL;
 
-	fep->interrupt = irq_of_parse_and_map(ofdev->dev.of_node, 0);
+	fep->interrupt = platform_get_irq(ofdev, 0);
 	if (!fep->interrupt)
 		goto out;
 
diff --git a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
index f2ecd20027cf..8dbd624b87ac 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
@@ -88,7 +88,7 @@  static int do_pd_setup(struct fs_enet_private *fep)
 {
 	struct platform_device *ofdev = to_platform_device(fep->dev);
 
-	fep->interrupt = irq_of_parse_and_map(ofdev->dev.of_node, 0);
+	fep->interrupt = platform_get_irq(ofdev, 0);
 	if (!fep->interrupt)
 		return -EINVAL;
 
diff --git a/drivers/net/ethernet/freescale/fs_enet/mac-scc.c b/drivers/net/ethernet/freescale/fs_enet/mac-scc.c
index 6c97191649de..53d67fb08bad 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mac-scc.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mac-scc.c
@@ -87,7 +87,7 @@  static int do_pd_setup(struct fs_enet_private *fep)
 {
 	struct platform_device *ofdev = to_platform_device(fep->dev);
 
-	fep->interrupt = irq_of_parse_and_map(ofdev->dev.of_node, 0);
+	fep->interrupt = platform_get_irq(ofdev, 0);
 	if (!fep->interrupt)
 		return -EINVAL;
 
diff --git a/drivers/net/ethernet/freescale/fs_enet/mii-fec.c b/drivers/net/ethernet/freescale/fs_enet/mii-fec.c
index dec31b638941..0e6faba74e34 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mii-fec.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mii-fec.c
@@ -96,7 +96,7 @@  static int fs_enet_fec_mii_write(struct mii_bus *bus, int phy_id, int location,
 
 static int fs_enet_mdio_probe(struct platform_device *ofdev)
 {
-	struct resource res;
+	struct resource *res;
 	struct mii_bus *new_bus;
 	struct fec_info *fec;
 	int (*get_bus_freq)(struct device *);
@@ -117,13 +117,15 @@  static int fs_enet_mdio_probe(struct platform_device *ofdev)
 	new_bus->read = &fs_enet_fec_mii_read;
 	new_bus->write = &fs_enet_fec_mii_write;
 
-	ret = of_address_to_resource(ofdev->dev.of_node, 0, &res);
-	if (ret)
+	res = platform_get_resource(ofdev, 0, IORESOURCE_MEM);
+	if (!res) {
+		ret = -ENODEV;
 		goto out_res;
+	}
 
-	snprintf(new_bus->id, MII_BUS_ID_SIZE, "%pap", &res.start);
+	snprintf(new_bus->id, MII_BUS_ID_SIZE, "%pap", &res->start);
 
-	fec->fecp = ioremap(res.start, resource_size(&res));
+	fec->fecp = ioremap(res->start, resource_size(res));
 	if (!fec->fecp) {
 		ret = -ENOMEM;
 		goto out_fec;
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index 6663c1768089..2a10486bc1f0 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -3560,7 +3560,7 @@  static int ucc_geth_probe(struct platform_device* ofdev)
 	struct net_device *dev = NULL;
 	struct ucc_geth_private *ugeth = NULL;
 	struct ucc_geth_info *ug_info;
-	struct resource res;
+	struct resource *res;
 	int err, ucc_num, max_speed = 0;
 	const unsigned int *prop;
 	phy_interface_t phy_interface;
@@ -3605,12 +3605,12 @@  static int ucc_geth_probe(struct platform_device* ofdev)
 	if (err)
 		return err;
 
-	err = of_address_to_resource(np, 0, &res);
-	if (err)
-		return err;
+	res = platform_get_resource(ofdev 0, IORESOURCE_MEM);
+	if (!res)
+		return -ENODEV;
 
-	ug_info->uf_info.regs = res.start;
-	ug_info->uf_info.irq = irq_of_parse_and_map(np, 0);
+	ug_info->uf_info.regs = res->start;
+	ug_info->uf_info.irq = platform_get_irq(ofdev, 0);
 
 	ug_info->phy_node = of_parse_phandle(np, "phy-handle", 0);
 	if (!ug_info->phy_node && of_phy_is_fixed_link(np)) {
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index 1fb285fa0bdb..0da7084b80c4 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -5511,7 +5511,7 @@  static int mvneta_probe(struct platform_device *pdev)
 		pp->neta_ac5 = true;
 	}
 
-	dev->irq = irq_of_parse_and_map(dn, 0);
+	dev->irq = platform_get_irq(pdev, 0);
 	if (dev->irq == 0)
 		return -EINVAL;
 
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
index 8bd60168624a..f995591dc43b 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -465,9 +465,9 @@  static int moxart_mac_probe(struct platform_device *pdev)
 	if (!ndev)
 		return -ENOMEM;
 
-	irq = irq_of_parse_and_map(node, 0);
+	irq = platform_get_irq(pdev, 0);
 	if (irq <= 0) {
-		netdev_err(ndev, "irq_of_parse_and_map failed\n");
+		netdev_err(ndev, "platform_get_irq failed\n");
 		ret = -EINVAL;
 		goto irq_map_fail;
 	}
diff --git a/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c b/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
index 2eccc7617507..4118e35b99e5 100644
--- a/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
+++ b/drivers/net/ethernet/samsung/sxgbe/sxgbe_platform.c
@@ -111,7 +111,7 @@  static int sxgbe_platform_probe(struct platform_device *pdev)
 	}
 
 	/* Get the SXGBE common INT information */
-	priv->irq  = irq_of_parse_and_map(node, 0);
+	priv->irq = platform_get_irq(pdev, 0);
 	if (priv->irq <= 0) {
 		dev_err(dev, "sxgbe common irq parsing failed\n");
 		goto err_drv_remove;
@@ -122,7 +122,7 @@  static int sxgbe_platform_probe(struct platform_device *pdev)
 
 	/* Get the TX/RX IRQ numbers */
 	for (i = 0, chan = 1; i < SXGBE_TX_QUEUES; i++) {
-		priv->txq[i]->irq_no = irq_of_parse_and_map(node, chan++);
+		priv->txq[i]->irq_no = platform_get_irq(pdev, chan++);
 		if (priv->txq[i]->irq_no <= 0) {
 			dev_err(dev, "sxgbe tx irq parsing failed\n");
 			goto err_tx_irq_unmap;
@@ -130,14 +130,14 @@  static int sxgbe_platform_probe(struct platform_device *pdev)
 	}
 
 	for (i = 0; i < SXGBE_RX_QUEUES; i++) {
-		priv->rxq[i]->irq_no = irq_of_parse_and_map(node, chan++);
+		priv->rxq[i]->irq_no = platform_get_irq(pdev, chan++);
 		if (priv->rxq[i]->irq_no <= 0) {
 			dev_err(dev, "sxgbe rx irq parsing failed\n");
 			goto err_rx_irq_unmap;
 		}
 	}
 
-	priv->lpi_irq = irq_of_parse_and_map(node, chan);
+	priv->lpi_irq = platform_get_irq(pdev, chan);
 	if (priv->lpi_irq <= 0) {
 		dev_err(dev, "sxgbe lpi irq parsing failed\n");
 		goto err_rx_irq_unmap;
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index 894911f3d560..f079242c33e2 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -1127,7 +1127,7 @@  static int rhine_init_one_platform(struct platform_device *pdev)
 	if (IS_ERR(ioaddr))
 		return PTR_ERR(ioaddr);
 
-	irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+	irq = platform_get_irq(pdev, 0);
 	if (!irq)
 		return -EINVAL;
 
diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c
index dd4a07c97eee..4aac9599c14d 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -2950,7 +2950,7 @@  static int velocity_platform_probe(struct platform_device *pdev)
 	if (!info)
 		return -EINVAL;
 
-	irq = irq_of_parse_and_map(pdev->dev.of_node, 0);
+	irq = platform_get_irq(pdev, 0);
 	if (!irq)
 		return -EINVAL;
 
diff --git a/drivers/net/ethernet/xilinx/ll_temac_mdio.c b/drivers/net/ethernet/xilinx/ll_temac_mdio.c
index 07a9fb49eda1..4bc5d47ecb7e 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_mdio.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_mdio.c
@@ -69,7 +69,7 @@  int temac_mdio_setup(struct temac_local *lp, struct platform_device *pdev)
 	u32 bus_hz;
 	int clk_div;
 	int rc;
-	struct resource res;
+	struct resource *res;
 
 	/* Get MDIO bus frequency (if specified) */
 	bus_hz = 0;
@@ -98,9 +98,9 @@  int temac_mdio_setup(struct temac_local *lp, struct platform_device *pdev)
 		return -ENOMEM;
 
 	if (np) {
-		of_address_to_resource(np, 0, &res);
+		res = platform_get_resource(pdev, 0, IORESOURCE_MEM);
 		snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx",
-			 (unsigned long long)res.start);
+			 (unsigned long long)res->start);
 	} else if (pdata) {
 		snprintf(bus->id, MII_BUS_ID_SIZE, "%.8llx",
 			 pdata->mdio_bus_id);
diff --git a/drivers/net/mdio/mdio-mux-mmioreg.c b/drivers/net/mdio/mdio-mux-mmioreg.c
index 9c4b1efd0d53..b5a65a1ab406 100644
--- a/drivers/net/mdio/mdio-mux-mmioreg.c
+++ b/drivers/net/mdio/mdio-mux-mmioreg.c
@@ -98,7 +98,7 @@  static int mdio_mux_mmioreg_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct mdio_mux_mmioreg_state *s;
-	struct resource res;
+	struct resource *res;
 	const __be32 *iprop;
 	int len, ret;
 
@@ -108,13 +108,15 @@  static int mdio_mux_mmioreg_probe(struct platform_device *pdev)
 	if (!s)
 		return -ENOMEM;
 
-	ret = of_address_to_resource(np, 0, &res);
-	if (ret)
-		return dev_err_probe(&pdev->dev, ret,
-				     "could not obtain memory map for node %pOF\n", np);
-	s->phys = res.start;
+	res = platform_get_resource(pdev, 0, IORESOURCE_MEM);
+	if (!res) {
+		dev_err(&pdev->dev,
+			"could not obtain memory map for node %pOF\n", np);
+		return -ENODEV;
+	}
+	s->phys = res->start;
 
-	s->iosize = resource_size(&res);
+	s->iosize = resource_size(res);
 	if (s->iosize != sizeof(uint8_t) &&
 	    s->iosize != sizeof(uint16_t) &&
 	    s->iosize != sizeof(uint32_t))
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index f999798a5612..414a9d22da5e 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -1118,7 +1118,7 @@  static int ucc_hdlc_probe(struct platform_device *pdev)
 	struct ucc_hdlc_private *uhdlc_priv = NULL;
 	struct ucc_tdm_info *ut_info;
 	struct ucc_tdm *utdm = NULL;
-	struct resource res;
+	struct resource *res;
 	struct net_device *dev;
 	hdlc_device *hdlc;
 	int ucc_num;
@@ -1170,12 +1170,12 @@  static int ucc_hdlc_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	ret = of_address_to_resource(np, 0, &res);
-	if (ret)
+	res = platform_get_resource(pdev, 0, IORESOURCE_MEM);
+	if (!res)
 		return -EINVAL;
 
-	ut_info->uf_info.regs = res.start;
-	ut_info->uf_info.irq = irq_of_parse_and_map(np, 0);
+	ut_info->uf_info.regs = res->start;
+	ut_info->uf_info.irq = platform_get_irq(pdev, 0);
 
 	uhdlc_priv = kzalloc(sizeof(*uhdlc_priv), GFP_KERNEL);
 	if (!uhdlc_priv)