[PATCH net-next] net: use pdev instead of OF funcs
Rob Herring
robh at kernel.org
Tue Nov 12 03:20:50 AEDT 2024
On Sat, Nov 9, 2024 at 5:40 PM Rosen Penev <rosenp at 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 at 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
More information about the Linuxppc-dev
mailing list