Linux CAN drivers development
 help / color / mirror / Atom feed
* [PATCH] net: modernize ioremap in probe
@ 2024-11-09 23:36 Rosen Penev
  2024-11-10 14:18 ` Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rosen Penev @ 2024-11-09 23:36 UTC (permalink / raw)
  To: netdev
  Cc: Chandrasekar Ramakrishnan, Marc Kleine-Budde, Vincent Mailhol,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Kurt Kanzenbach, Vladimir Oltean, Chris Snook,
	Marcin Wojtas, Russell King, Horatiu Vultur,
	maintainer:MICROCHIP LAN966X ETHERNET DRIVER, Yoshihiro Shimoda,
	Niklas Söderlund, Doug Berger, Florian Fainelli,
	Broadcom internal kernel review list, Heiner Kallweit,
	Richard Cochran, open list:MCAN MMIO DEVICE DRIVER, open list,
	open list:RENESAS ETHERNET SWITCH DRIVER

resource aquisition and ioremap can be performed in one step.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/can/m_can/m_can_platform.c        | 13 +++-------
 drivers/net/can/sja1000/sja1000_platform.c    | 15 +++--------
 drivers/net/dsa/hirschmann/hellcreek.c        | 18 +++----------
 drivers/net/ethernet/atheros/ag71xx.c         | 13 ++++------
 drivers/net/ethernet/broadcom/bcm63xx_enet.c  |  6 ++---
 drivers/net/ethernet/freescale/xgmac_mdio.c   | 12 +++------
 drivers/net/ethernet/marvell/mvmdio.c         | 12 +++------
 .../net/ethernet/marvell/mvpp2/mvpp2_main.c   | 14 ++++-------
 .../ethernet/microchip/lan966x/lan966x_main.c | 16 +++---------
 drivers/net/ethernet/renesas/rswitch.c        |  9 +------
 drivers/net/ethernet/renesas/rtsn.c           | 10 ++------
 drivers/net/ethernet/renesas/sh_eth.c         | 25 +++----------------
 drivers/net/mdio/mdio-bcm-unimac.c            | 11 +++-----
 drivers/net/mdio/mdio-ipq4019.c               |  7 ++----
 drivers/net/mdio/mdio-ipq8064.c               |  6 +----
 drivers/net/mdio/mdio-mux-bcm6368.c           | 11 +++-----
 drivers/net/mdio/mdio-octeon.c                | 25 +++----------------
 17 files changed, 50 insertions(+), 173 deletions(-)

diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index b832566efda0..dfc0d2834b50 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -79,7 +79,6 @@ static int m_can_plat_probe(struct platform_device *pdev)
 {
 	struct m_can_classdev *mcan_class;
 	struct m_can_plat_priv *priv;
-	struct resource *res;
 	void __iomem *addr;
 	void __iomem *mram_addr;
 	struct phy *transceiver;
@@ -112,15 +111,9 @@ static int m_can_plat_probe(struct platform_device *pdev)
 	}
 
 	/* message ram could be shared */
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "message_ram");
-	if (!res) {
-		ret = -ENODEV;
-		goto probe_fail;
-	}
-
-	mram_addr = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-	if (!mram_addr) {
-		ret = -ENOMEM;
+	mram_addr = devm_platform_ioremap_resource_byname(pdev, "message_ram");
+	if (IS_ERR(mram_addr)) {
+		ret = PTR_ERR(mram_addr);
 		goto probe_fail;
 	}
 
diff --git a/drivers/net/can/sja1000/sja1000_platform.c b/drivers/net/can/sja1000/sja1000_platform.c
index c42ebe9da55a..2d555f854008 100644
--- a/drivers/net/can/sja1000/sja1000_platform.c
+++ b/drivers/net/can/sja1000/sja1000_platform.c
@@ -230,18 +230,9 @@ static int sp_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res_mem)
-		return -ENODEV;
-
-	if (!devm_request_mem_region(&pdev->dev, res_mem->start,
-				     resource_size(res_mem), DRV_NAME))
-		return -EBUSY;
-
-	addr = devm_ioremap(&pdev->dev, res_mem->start,
-				    resource_size(res_mem));
-	if (!addr)
-		return -ENOMEM;
+	addr = devm_platform_get_and_ioremap_resource(pdev, 0, &res_mem);
+	if (IS_ERR(addr))
+		return PTR_ERR(addr);
 
 	if (of) {
 		irq = platform_get_irq(pdev, 0);
diff --git a/drivers/net/dsa/hirschmann/hellcreek.c b/drivers/net/dsa/hirschmann/hellcreek.c
index 283ec5a6e23c..940c4fa6a924 100644
--- a/drivers/net/dsa/hirschmann/hellcreek.c
+++ b/drivers/net/dsa/hirschmann/hellcreek.c
@@ -1932,7 +1932,6 @@ static int hellcreek_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct hellcreek *hellcreek;
-	struct resource *res;
 	int ret, i;
 
 	hellcreek = devm_kzalloc(dev, sizeof(*hellcreek), GFP_KERNEL);
@@ -1982,23 +1981,12 @@ static int hellcreek_probe(struct platform_device *pdev)
 
 	hellcreek->dev = dev;
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "tsn");
-	if (!res) {
-		dev_err(dev, "No memory region provided!\n");
-		return -ENODEV;
-	}
-
-	hellcreek->base = devm_ioremap_resource(dev, res);
+	hellcreek->base = devm_platform_ioremap_resource_byname(pdev, "tsn");
 	if (IS_ERR(hellcreek->base))
 		return PTR_ERR(hellcreek->base);
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ptp");
-	if (!res) {
-		dev_err(dev, "No PTP memory region provided!\n");
-		return -ENODEV;
-	}
-
-	hellcreek->ptp_base = devm_ioremap_resource(dev, res);
+	hellcreek->ptp_base =
+		devm_platform_ioremap_resource_byname(pdev, "ptp");
 	if (IS_ERR(hellcreek->ptp_base))
 		return PTR_ERR(hellcreek->ptp_base);
 
diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c
index 3d4c3d8698e2..928d27b51b2a 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -1798,15 +1798,16 @@ static int ag71xx_probe(struct platform_device *pdev)
 	if (!ndev)
 		return -ENOMEM;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -EINVAL;
-
 	dcfg = of_device_get_match_data(&pdev->dev);
 	if (!dcfg)
 		return -EINVAL;
 
 	ag = netdev_priv(ndev);
+
+	ag->mac_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
+	if (IS_ERR(ag->mac_base))
+		return PTR_ERR(ag->mac_base);
+
 	ag->mac_idx = -1;
 	for (i = 0; i < ARRAY_SIZE(ar71xx_addr_ar7100); i++) {
 		if (ar71xx_addr_ar7100[i] == res->start)
@@ -1836,10 +1837,6 @@ static int ag71xx_probe(struct platform_device *pdev)
 		return dev_err_probe(&pdev->dev, PTR_ERR(ag->mac_reset),
 				     "missing mac reset");
 
-	ag->mac_base = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(ag->mac_base))
-		return PTR_ERR(ag->mac_base);
-
 	/* ensure that HW is in manual polling mode before interrupts are
 	 * activated. Otherwise ag71xx_interrupt might call napi_schedule
 	 * before it is initialized by netif_napi_add.
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index 65e3a0656a4c..420317abe3d2 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -2646,16 +2646,14 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
 	struct bcm_enet_priv *priv;
 	struct net_device *dev;
 	struct bcm63xx_enetsw_platform_data *pd;
-	struct resource *res_mem;
 	int ret, irq_rx, irq_tx;
 
 	if (!bcm_enet_shared_base[0])
 		return -EPROBE_DEFER;
 
-	res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	irq_rx = platform_get_irq(pdev, 0);
 	irq_tx = platform_get_irq(pdev, 1);
-	if (!res_mem || irq_rx < 0)
+	if (irq_rx < 0)
 		return -ENODEV;
 
 	dev = alloc_etherdev(sizeof(*priv));
@@ -2688,7 +2686,7 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
 	if (ret)
 		goto out;
 
-	priv->base = devm_ioremap_resource(&pdev->dev, res_mem);
+	priv->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(priv->base)) {
 		ret = PTR_ERR(priv->base);
 		goto out;
diff --git a/drivers/net/ethernet/freescale/xgmac_mdio.c b/drivers/net/ethernet/freescale/xgmac_mdio.c
index 65dc07d0df0f..688720e48396 100644
--- a/drivers/net/ethernet/freescale/xgmac_mdio.c
+++ b/drivers/net/ethernet/freescale/xgmac_mdio.c
@@ -381,11 +381,6 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
 	 * subdevice areas. Therefore, MDIO cannot claim exclusive access to
 	 * this register area.
 	 */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res) {
-		dev_err(&pdev->dev, "could not obtain address\n");
-		return -EINVAL;
-	}
 
 	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(struct mdio_fsl_priv));
 	if (!bus)
@@ -400,10 +395,9 @@ static int xgmac_mdio_probe(struct platform_device *pdev)
 	snprintf(bus->id, MII_BUS_ID_SIZE, "%pa", &res->start);
 
 	priv = bus->priv;
-	priv->mdio_base = devm_ioremap(&pdev->dev, res->start,
-				       resource_size(res));
-	if (!priv->mdio_base)
-		return -ENOMEM;
+	priv->mdio_base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(priv->mdio_base))
+		return PTR_ERR(priv->mdio_base);
 
 	/* For both ACPI and DT cases, endianness of MDIO controller
 	 * needs to be specified using "little-endian" property.
diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
index 3f4447e68888..ad1dddfa6ea8 100644
--- a/drivers/net/ethernet/marvell/mvmdio.c
+++ b/drivers/net/ethernet/marvell/mvmdio.c
@@ -291,12 +291,6 @@ static int orion_mdio_probe(struct platform_device *pdev)
 
 	type = (uintptr_t)device_get_match_data(&pdev->dev);
 
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r) {
-		dev_err(&pdev->dev, "No SMI register address given\n");
-		return -ENODEV;
-	}
-
 	bus = devm_mdiobus_alloc_size(&pdev->dev,
 				      sizeof(struct orion_mdio_dev));
 	if (!bus)
@@ -319,10 +313,10 @@ static int orion_mdio_probe(struct platform_device *pdev)
 	bus->parent = &pdev->dev;
 
 	dev = bus->priv;
-	dev->regs = devm_ioremap(&pdev->dev, r->start, resource_size(r));
-	if (!dev->regs) {
+	dev->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r);
+	if (IS_ERR(dev->regs)) {
 		dev_err(&pdev->dev, "Unable to remap SMI register\n");
-		return -ENODEV;
+		return PTR_ERR(dev->regs);
 	}
 
 	init_waitqueue_head(&dev->smi_busy_wait);
diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
index 571631a30320..faf853edc0db 100644
--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
+++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c
@@ -7425,21 +7425,17 @@ static int mvpp2_init(struct platform_device *pdev, struct mvpp2 *priv)
 static int mvpp2_get_sram(struct platform_device *pdev,
 			  struct mvpp2 *priv)
 {
-	struct resource *res;
 	void __iomem *base;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
-	if (!res) {
+	base = devm_platform_ioremap_resource(pdev, 2);
+	if (IS_ERR(base)) {
 		if (has_acpi_companion(&pdev->dev))
 			dev_warn(&pdev->dev, "ACPI is too old, Flow control not supported\n");
 		else
-			dev_warn(&pdev->dev, "DT is too old, Flow control not supported\n");
-		return 0;
-	}
-
-	base = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(base))
+			dev_warn(&pdev->dev,
+				 "DT is too old, Flow control not supported\n");
 		return PTR_ERR(base);
+	}
 
 	priv->cm3_base = base;
 	return 0;
diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
index 3234a960fcc3..375e9a68b9a9 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
@@ -77,20 +77,12 @@ static int lan966x_create_targets(struct platform_device *pdev,
 	 * this.
 	 */
 	for (idx = 0; idx < IO_RANGES; idx++) {
-		iores[idx] = platform_get_resource(pdev, IORESOURCE_MEM,
-						   idx);
-		if (!iores[idx]) {
-			dev_err(&pdev->dev, "Invalid resource\n");
-			return -EINVAL;
-		}
-
-		begin[idx] = devm_ioremap(&pdev->dev,
-					  iores[idx]->start,
-					  resource_size(iores[idx]));
-		if (!begin[idx]) {
+		begin[idx] = devm_platform_get_and_ioremap_resource(
+			pdev, idx, &iores[idx]);
+		if (IS_ERR(begin[idx])) {
 			dev_err(&pdev->dev, "Unable to get registers: %s\n",
 				iores[idx]->name);
-			return -ENOMEM;
+			return PTR_ERR(begin[idx]);
 		}
 	}
 
diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c
index 8d18dae4d8fb..8ef52fc46a01 100644
--- a/drivers/net/ethernet/renesas/rswitch.c
+++ b/drivers/net/ethernet/renesas/rswitch.c
@@ -2046,15 +2046,8 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
 {
 	const struct soc_device_attribute *attr;
 	struct rswitch_private *priv;
-	struct resource *res;
 	int ret;
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "secure_base");
-	if (!res) {
-		dev_err(&pdev->dev, "invalid resource\n");
-		return -EINVAL;
-	}
-
 	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
@@ -2074,7 +2067,7 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, priv);
 	priv->pdev = pdev;
-	priv->addr = devm_ioremap_resource(&pdev->dev, res);
+	priv->addr = devm_platform_ioremap_resource_byname(pdev, "secure_base");
 	if (IS_ERR(priv->addr))
 		return PTR_ERR(priv->addr);
 
diff --git a/drivers/net/ethernet/renesas/rtsn.c b/drivers/net/ethernet/renesas/rtsn.c
index 6b3f7fca8d15..bfe08facc707 100644
--- a/drivers/net/ethernet/renesas/rtsn.c
+++ b/drivers/net/ethernet/renesas/rtsn.c
@@ -1297,14 +1297,8 @@ static int rtsn_probe(struct platform_device *pdev)
 	ndev->netdev_ops = &rtsn_netdev_ops;
 	ndev->ethtool_ops = &rtsn_ethtool_ops;
 
-	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gptp");
-	if (!res) {
-		dev_err(&pdev->dev, "Can't find gptp resource\n");
-		ret = -EINVAL;
-		goto error_free;
-	}
-
-	priv->ptp_priv->addr = devm_ioremap_resource(&pdev->dev, res);
+	priv->ptp_priv->addr =
+		devm_platform_ioremap_resource_byname(pdev, "gptp");
 	if (IS_ERR(priv->ptp_priv->addr)) {
 		ret = PTR_ERR(priv->ptp_priv->addr);
 		goto error_free;
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 8887b8921009..d9a2cba60a11 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -3349,31 +3349,12 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 
 	if (mdp->cd->tsu) {
 		int port = pdev->id < 0 ? 0 : pdev->id % 2;
-		struct resource *rtsu;
 
-		rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-		if (!rtsu) {
-			dev_err(&pdev->dev, "no TSU resource\n");
-			ret = -ENODEV;
-			goto out_release;
-		}
-		/* We can only request the  TSU region  for the first port
-		 * of the two  sharing this TSU for the probe to succeed...
-		 */
-		if (port == 0 &&
-		    !devm_request_mem_region(&pdev->dev, rtsu->start,
-					     resource_size(rtsu),
-					     dev_name(&pdev->dev))) {
-			dev_err(&pdev->dev, "can't request TSU resource.\n");
-			ret = -EBUSY;
-			goto out_release;
-		}
 		/* ioremap the TSU registers */
-		mdp->tsu_addr = devm_ioremap(&pdev->dev, rtsu->start,
-					     resource_size(rtsu));
-		if (!mdp->tsu_addr) {
+		mdp->tsu_addr = devm_platform_ioremap_resource(pdev, 1);
+		if (IS_ERR(mdp->tsu_addr)) {
 			dev_err(&pdev->dev, "TSU region ioremap() failed.\n");
-			ret = -ENOMEM;
+			ret = PTR_ERR(mdp->tsu_addr);
 			goto out_release;
 		}
 		mdp->port = port;
diff --git a/drivers/net/mdio/mdio-bcm-unimac.c b/drivers/net/mdio/mdio-bcm-unimac.c
index 074d96328f41..9796294d465a 100644
--- a/drivers/net/mdio/mdio-bcm-unimac.c
+++ b/drivers/net/mdio/mdio-bcm-unimac.c
@@ -239,7 +239,6 @@ static int unimac_mdio_probe(struct platform_device *pdev)
 	struct unimac_mdio_priv *priv;
 	struct device_node *np;
 	struct mii_bus *bus;
-	struct resource *r;
 	int ret;
 
 	np = pdev->dev.of_node;
@@ -248,17 +247,13 @@ static int unimac_mdio_probe(struct platform_device *pdev)
 	if (!priv)
 		return -ENOMEM;
 
-	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!r)
-		return -EINVAL;
-
 	/* Just ioremap, as this MDIO block is usually integrated into an
 	 * Ethernet MAC controller register range
 	 */
-	priv->base = devm_ioremap(&pdev->dev, r->start, resource_size(r));
-	if (!priv->base) {
+	priv->base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(priv->base)) {
 		dev_err(&pdev->dev, "failed to remap register\n");
-		return -ENOMEM;
+		return PTR_ERR(priv->base);
 	}
 
 	if (of_property_read_u32(np, "clock-frequency", &priv->clk_freq))
diff --git a/drivers/net/mdio/mdio-ipq4019.c b/drivers/net/mdio/mdio-ipq4019.c
index dd3ed2d6430b..725e5c13d212 100644
--- a/drivers/net/mdio/mdio-ipq4019.c
+++ b/drivers/net/mdio/mdio-ipq4019.c
@@ -256,7 +256,7 @@ static int ipq_mdio_reset(struct mii_bus *bus)
 	/* To indicate CMN_PLL that ethernet_ldo has been ready if platform resource 1
 	 * is specified in the device tree.
 	 */
-	if (priv->eth_ldo_rdy) {
+	if (!IS_ERR(priv->eth_ldo_rdy)) {
 		val = readl(priv->eth_ldo_rdy);
 		val |= BIT(0);
 		writel(val, priv->eth_ldo_rdy);
@@ -327,7 +327,6 @@ static int ipq4019_mdio_probe(struct platform_device *pdev)
 {
 	struct ipq4019_mdio_data *priv;
 	struct mii_bus *bus;
-	struct resource *res;
 	int ret;
 
 	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv));
@@ -351,9 +350,7 @@ static int ipq4019_mdio_probe(struct platform_device *pdev)
 
 	/* The platform resource is provided on the chipset IPQ5018 */
 	/* This resource is optional */
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-	if (res)
-		priv->eth_ldo_rdy = devm_ioremap_resource(&pdev->dev, res);
+	priv->eth_ldo_rdy = devm_platform_ioremap_resource(pdev, 1);
 
 	bus->name = "ipq4019_mdio";
 	bus->read = ipq4019_mdio_read_c22;
diff --git a/drivers/net/mdio/mdio-ipq8064.c b/drivers/net/mdio/mdio-ipq8064.c
index 6253a9ab8b69..716b22e9b93c 100644
--- a/drivers/net/mdio/mdio-ipq8064.c
+++ b/drivers/net/mdio/mdio-ipq8064.c
@@ -111,15 +111,11 @@ ipq8064_mdio_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct ipq8064_mdio *priv;
-	struct resource res;
 	struct mii_bus *bus;
 	void __iomem *base;
 	int ret;
 
-	if (of_address_to_resource(np, 0, &res))
-		return -ENOMEM;
-
-	base = devm_ioremap(&pdev->dev, res.start, resource_size(&res));
+	base = devm_platform_ioremap_resource(pdev, 0);
 	if (!base)
 		return -ENOMEM;
 
diff --git a/drivers/net/mdio/mdio-mux-bcm6368.c b/drivers/net/mdio/mdio-mux-bcm6368.c
index 476f8b72d020..fa369ff7d45c 100644
--- a/drivers/net/mdio/mdio-mux-bcm6368.c
+++ b/drivers/net/mdio/mdio-mux-bcm6368.c
@@ -90,7 +90,6 @@ static int bcm6368_mdiomux_probe(struct platform_device *pdev)
 {
 	struct bcm6368_mdiomux_desc *md;
 	struct mii_bus *bus;
-	struct resource *res;
 	int rc;
 
 	md = devm_kzalloc(&pdev->dev, sizeof(*md), GFP_KERNEL);
@@ -98,18 +97,14 @@ static int bcm6368_mdiomux_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	md->dev = &pdev->dev;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -EINVAL;
-
 	/*
 	 * Just ioremap, as this MDIO block is usually integrated into an
 	 * Ethernet MAC controller register range
 	 */
-	md->base = devm_ioremap(&pdev->dev, res->start, resource_size(res));
-	if (!md->base) {
+	md->base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(md->base)) {
 		dev_err(&pdev->dev, "failed to ioremap register\n");
-		return -ENOMEM;
+		return PTR_ERR(md->base);
 	}
 
 	md->mii_bus = devm_mdiobus_alloc(&pdev->dev);
diff --git a/drivers/net/mdio/mdio-octeon.c b/drivers/net/mdio/mdio-octeon.c
index 2beb83154d39..cb53dccbde1a 100644
--- a/drivers/net/mdio/mdio-octeon.c
+++ b/drivers/net/mdio/mdio-octeon.c
@@ -17,37 +17,20 @@ static int octeon_mdiobus_probe(struct platform_device *pdev)
 {
 	struct cavium_mdiobus *bus;
 	struct mii_bus *mii_bus;
-	struct resource *res_mem;
-	resource_size_t mdio_phys;
-	resource_size_t regsize;
 	union cvmx_smix_en smi_en;
-	int err = -ENOENT;
+	int err;
 
 	mii_bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*bus));
 	if (!mii_bus)
 		return -ENOMEM;
 
-	res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (res_mem == NULL) {
-		dev_err(&pdev->dev, "found no memory resource\n");
-		return -ENXIO;
-	}
-
 	bus = mii_bus->priv;
 	bus->mii_bus = mii_bus;
-	mdio_phys = res_mem->start;
-	regsize = resource_size(res_mem);
 
-	if (!devm_request_mem_region(&pdev->dev, mdio_phys, regsize,
-				     res_mem->name)) {
-		dev_err(&pdev->dev, "request_mem_region failed\n");
-		return -ENXIO;
-	}
-
-	bus->register_base = devm_ioremap(&pdev->dev, mdio_phys, regsize);
-	if (!bus->register_base) {
+	bus->register_base = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(bus->register_base)) {
 		dev_err(&pdev->dev, "dev_ioremap failed\n");
-		return -ENOMEM;
+		return PTR_ERR(bus->register_base);
 	}
 
 	smi_en.u64 = 0;
-- 
2.47.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: modernize ioremap in probe
  2024-11-09 23:36 [PATCH] net: modernize ioremap in probe Rosen Penev
@ 2024-11-10 14:18 ` Markus Elfring
  2024-11-10 20:28 ` kernel test robot
  2024-11-11  9:38 ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2024-11-10 14:18 UTC (permalink / raw)
  To: Rosen Penev, netdev, linux-can, linux-renesas-soc, UNGLinuxDriver,
	bcm-kernel-feedback-list, Andrew Lunn, Chandrasekar Ramakrishnan,
	Chris Snook, David S. Miller, Doug Berger, Eric Dumazet,
	Florian Fainelli, Heiner Kallweit, Horatiu Vultur, Jakub Kicinski,
	Kurt Kanzenbach, Marc Kleine-Budde, Marcin Wojtas,
	Niklas Söderlund, Paolo Abeni, Richard Cochran, Russell King,
	Vincent Mailhol, Vladimir Oltean, Yoshihiro Shimoda
  Cc: LKML, Simon Horman

> resource aquisition and ioremap can be performed in one step.

Will another imperative wording become helpful for an improved change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.12-rc6#n94

Regards,
Markus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: modernize ioremap in probe
  2024-11-09 23:36 [PATCH] net: modernize ioremap in probe Rosen Penev
  2024-11-10 14:18 ` Markus Elfring
@ 2024-11-10 20:28 ` kernel test robot
  2024-11-11  9:38 ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2024-11-10 20:28 UTC (permalink / raw)
  To: Rosen Penev, netdev
  Cc: llvm, oe-kbuild-all, Chandrasekar Ramakrishnan, Marc Kleine-Budde,
	Vincent Mailhol, Andrew Lunn, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Kurt Kanzenbach, Vladimir Oltean, Chris Snook,
	Marcin Wojtas, Russell King, Horatiu Vultur, UNGLinuxDriver,
	Yoshihiro Shimoda, Niklas Söderlund, Doug Berger,
	Florian Fainelli, Broadcom internal kernel review list,
	Heiner Kallweit, Richard Cochran, linux-can, linux-kernel,
	linux-renesas-soc

Hi Rosen,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]
[also build test WARNING on next-20241108]
[cannot apply to mkl-can-next/testing net/main linus/master v6.12-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/net-modernize-ioremap-in-probe/20241110-073751
base:   net-next/main
patch link:    https://lore.kernel.org/r/20241109233641.8313-1-rosenp%40gmail.com
patch subject: [PATCH] net: modernize ioremap in probe
config: hexagon-allmodconfig (https://download.01.org/0day-ci/archive/20241111/202411110419.EQz0nIvL-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 592c0fe55f6d9a811028b5f3507be91458ab2713)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241111/202411110419.EQz0nIvL-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/202411110419.EQz0nIvL-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from drivers/net/ethernet/freescale/xgmac_mdio.c:16:
   In file included from include/linux/acpi_mdio.h:9:
   In file included from include/linux/phy.h:16:
   In file included from include/linux/ethtool.h:18:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:10:
   In file included from include/linux/mm.h:2213:
   include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     518 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   In file included from drivers/net/ethernet/freescale/xgmac_mdio.c:16:
   In file included from include/linux/acpi_mdio.h:9:
   In file included from include/linux/phy.h:16:
   In file included from include/linux/ethtool.h:18:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:14:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:548:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     548 |         val = __raw_readb(PCI_IOBASE + addr);
         |                           ~~~~~~~~~~ ^
   include/asm-generic/io.h:561:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     561 |         val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
      37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
         |                                                   ^
   In file included from drivers/net/ethernet/freescale/xgmac_mdio.c:16:
   In file included from include/linux/acpi_mdio.h:9:
   In file included from include/linux/phy.h:16:
   In file included from include/linux/ethtool.h:18:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:14:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:574:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     574 |         val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
         |                                                         ~~~~~~~~~~ ^
   include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
      35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
         |                                                   ^
   In file included from drivers/net/ethernet/freescale/xgmac_mdio.c:16:
   In file included from include/linux/acpi_mdio.h:9:
   In file included from include/linux/phy.h:16:
   In file included from include/linux/ethtool.h:18:
   In file included from include/linux/if_ether.h:19:
   In file included from include/linux/skbuff.h:17:
   In file included from include/linux/bvec.h:10:
   In file included from include/linux/highmem.h:12:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/hexagon/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:14:
   In file included from arch/hexagon/include/asm/io.h:328:
   include/asm-generic/io.h:585:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     585 |         __raw_writeb(value, PCI_IOBASE + addr);
         |                             ~~~~~~~~~~ ^
   include/asm-generic/io.h:595:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     595 |         __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
   include/asm-generic/io.h:605:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
     605 |         __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
         |                                                       ~~~~~~~~~~ ^
>> drivers/net/ethernet/freescale/xgmac_mdio.c:395:45: warning: variable 'res' is uninitialized when used here [-Wuninitialized]
     395 |         snprintf(bus->id, MII_BUS_ID_SIZE, "%pa", &res->start);
         |                                                    ^~~
   drivers/net/ethernet/freescale/xgmac_mdio.c:375:22: note: initialize the variable 'res' to silence this warning
     375 |         struct resource *res;
         |                             ^
         |                              = NULL
   8 warnings generated.


vim +/res +395 drivers/net/ethernet/freescale/xgmac_mdio.c

909bea73485fab5 Tobias Waldekranz 2022-01-26  370  
33897cc869eef8b Bill Pemberton    2012-12-03  371  static int xgmac_mdio_probe(struct platform_device *pdev)
9f35a7342cff0be Timur Tabi        2012-08-20  372  {
ac53c26433b51f1 Marcin Wojtas     2021-06-25  373  	struct fwnode_handle *fwnode;
73ee5442978b2dd Shaohui Xie       2015-03-16  374  	struct mdio_fsl_priv *priv;
15e7064e8793352 Calvin Johnson    2021-06-11  375  	struct resource *res;
15e7064e8793352 Calvin Johnson    2021-06-11  376  	struct mii_bus *bus;
9f35a7342cff0be Timur Tabi        2012-08-20  377  	int ret;
9f35a7342cff0be Timur Tabi        2012-08-20  378  
229f4bb47512ece Calvin Johnson    2020-06-22  379  	/* In DPAA-1, MDIO is one of the many FMan sub-devices. The FMan
229f4bb47512ece Calvin Johnson    2020-06-22  380  	 * defines a register space that spans a large area, covering all the
229f4bb47512ece Calvin Johnson    2020-06-22  381  	 * subdevice areas. Therefore, MDIO cannot claim exclusive access to
229f4bb47512ece Calvin Johnson    2020-06-22  382  	 * this register area.
229f4bb47512ece Calvin Johnson    2020-06-22  383  	 */
9f35a7342cff0be Timur Tabi        2012-08-20  384  
1d14eb15dc2c396 Tobias Waldekranz 2022-01-26  385  	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(struct mdio_fsl_priv));
9f35a7342cff0be Timur Tabi        2012-08-20  386  	if (!bus)
9f35a7342cff0be Timur Tabi        2012-08-20  387  		return -ENOMEM;
9f35a7342cff0be Timur Tabi        2012-08-20  388  
9f35a7342cff0be Timur Tabi        2012-08-20  389  	bus->name = "Freescale XGMAC MDIO Bus";
c0fc8e6dcee40cf Andrew Lunn       2023-01-09  390  	bus->read = xgmac_mdio_read_c22;
c0fc8e6dcee40cf Andrew Lunn       2023-01-09  391  	bus->write = xgmac_mdio_write_c22;
c0fc8e6dcee40cf Andrew Lunn       2023-01-09  392  	bus->read_c45 = xgmac_mdio_read_c45;
c0fc8e6dcee40cf Andrew Lunn       2023-01-09  393  	bus->write_c45 = xgmac_mdio_write_c45;
9f35a7342cff0be Timur Tabi        2012-08-20  394  	bus->parent = &pdev->dev;
229f4bb47512ece Calvin Johnson    2020-06-22 @395  	snprintf(bus->id, MII_BUS_ID_SIZE, "%pa", &res->start);
9f35a7342cff0be Timur Tabi        2012-08-20  396  
73ee5442978b2dd Shaohui Xie       2015-03-16  397  	priv = bus->priv;
865bbb2945a1614 Rosen Penev       2024-11-09  398  	priv->mdio_base = devm_platform_ioremap_resource(pdev, 0);
865bbb2945a1614 Rosen Penev       2024-11-09  399  	if (IS_ERR(priv->mdio_base))
865bbb2945a1614 Rosen Penev       2024-11-09  400  		return PTR_ERR(priv->mdio_base);
9f35a7342cff0be Timur Tabi        2012-08-20  401  
15e7064e8793352 Calvin Johnson    2021-06-11  402  	/* For both ACPI and DT cases, endianness of MDIO controller
15e7064e8793352 Calvin Johnson    2021-06-11  403  	 * needs to be specified using "little-endian" property.
15e7064e8793352 Calvin Johnson    2021-06-11  404  	 */
229f4bb47512ece Calvin Johnson    2020-06-22  405  	priv->is_little_endian = device_property_read_bool(&pdev->dev,
07bf2e11ad05868 Julia Lawall      2016-08-05  406  							   "little-endian");
73ee5442978b2dd Shaohui Xie       2015-03-16  407  
6198c722019774d Tobias Waldekranz 2022-01-18  408  	priv->has_a009885 = device_property_read_bool(&pdev->dev,
6198c722019774d Tobias Waldekranz 2022-01-18  409  						      "fsl,erratum-a009885");
229f4bb47512ece Calvin Johnson    2020-06-22  410  	priv->has_a011043 = device_property_read_bool(&pdev->dev,
1d3ca681b9d9575 Madalin Bucur     2020-01-22  411  						      "fsl,erratum-a011043");
1d3ca681b9d9575 Madalin Bucur     2020-01-22  412  
909bea73485fab5 Tobias Waldekranz 2022-01-26  413  	xgmac_mdio_set_suppress_preamble(bus);
909bea73485fab5 Tobias Waldekranz 2022-01-26  414  
dd8f467eda72cda Tobias Waldekranz 2022-01-26  415  	ret = xgmac_mdio_set_mdc_freq(bus);
dd8f467eda72cda Tobias Waldekranz 2022-01-26  416  	if (ret)
dd8f467eda72cda Tobias Waldekranz 2022-01-26  417  		return ret;
dd8f467eda72cda Tobias Waldekranz 2022-01-26  418  
105b0468d7b2e67 zhaoxiao          2022-08-18  419  	fwnode = dev_fwnode(&pdev->dev);
ac53c26433b51f1 Marcin Wojtas     2021-06-25  420  	if (is_of_node(fwnode))
ac53c26433b51f1 Marcin Wojtas     2021-06-25  421  		ret = of_mdiobus_register(bus, to_of_node(fwnode));
ac53c26433b51f1 Marcin Wojtas     2021-06-25  422  	else if (is_acpi_node(fwnode))
ac53c26433b51f1 Marcin Wojtas     2021-06-25  423  		ret = acpi_mdiobus_register(bus, fwnode);
ac53c26433b51f1 Marcin Wojtas     2021-06-25  424  	else
ac53c26433b51f1 Marcin Wojtas     2021-06-25  425  		ret = -EINVAL;
9f35a7342cff0be Timur Tabi        2012-08-20  426  	if (ret) {
9f35a7342cff0be Timur Tabi        2012-08-20  427  		dev_err(&pdev->dev, "cannot register MDIO bus\n");
9f35a7342cff0be Timur Tabi        2012-08-20  428  		return ret;
9f35a7342cff0be Timur Tabi        2012-08-20  429  	}
9f35a7342cff0be Timur Tabi        2012-08-20  430  
1d14eb15dc2c396 Tobias Waldekranz 2022-01-26  431  	platform_set_drvdata(pdev, bus);
9f35a7342cff0be Timur Tabi        2012-08-20  432  
9f35a7342cff0be Timur Tabi        2012-08-20  433  	return 0;
9f35a7342cff0be Timur Tabi        2012-08-20  434  }
9f35a7342cff0be Timur Tabi        2012-08-20  435  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: modernize ioremap in probe
  2024-11-09 23:36 [PATCH] net: modernize ioremap in probe Rosen Penev
  2024-11-10 14:18 ` Markus Elfring
  2024-11-10 20:28 ` kernel test robot
@ 2024-11-11  9:38 ` Dan Carpenter
  2 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-11-11  9:38 UTC (permalink / raw)
  To: oe-kbuild, Rosen Penev, netdev
  Cc: lkp, oe-kbuild-all, Chandrasekar Ramakrishnan, Marc Kleine-Budde,
	Vincent Mailhol, Andrew Lunn, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Kurt Kanzenbach, Vladimir Oltean, Chris Snook,
	Marcin Wojtas, Russell King, Horatiu Vultur, UNGLinuxDriver,
	Yoshihiro Shimoda, Niklas Söderlund, Doug Berger,
	Florian Fainelli, Broadcom internal kernel review list,
	Heiner Kallweit, Richard Cochran, linux-can, linux-kernel,
	linux-renesas-soc

Hi Rosen,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/net-modernize-ioremap-in-probe/20241110-073751
base:   net-next/main
patch link:    https://lore.kernel.org/r/20241109233641.8313-1-rosenp%40gmail.com
patch subject: [PATCH] net: modernize ioremap in probe
config: arm-randconfig-r071-20241110 (https://download.01.org/0day-ci/archive/20241111/202411110835.tTxOya6U-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 14.2.0

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>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202411110835.tTxOya6U-lkp@intel.com/

smatch warnings:
drivers/net/ethernet/freescale/xgmac_mdio.c:395 xgmac_mdio_probe() error: uninitialized symbol 'res'.

vim +/res +395 drivers/net/ethernet/freescale/xgmac_mdio.c

33897cc869eef8 Bill Pemberton    2012-12-03  371  static int xgmac_mdio_probe(struct platform_device *pdev)
9f35a7342cff0b Timur Tabi        2012-08-20  372  {
ac53c26433b51f Marcin Wojtas     2021-06-25  373  	struct fwnode_handle *fwnode;
73ee5442978b2d Shaohui Xie       2015-03-16  374  	struct mdio_fsl_priv *priv;
15e7064e879335 Calvin Johnson    2021-06-11  375  	struct resource *res;
15e7064e879335 Calvin Johnson    2021-06-11  376  	struct mii_bus *bus;
9f35a7342cff0b Timur Tabi        2012-08-20  377  	int ret;
9f35a7342cff0b Timur Tabi        2012-08-20  378  
229f4bb47512ec Calvin Johnson    2020-06-22  379  	/* In DPAA-1, MDIO is one of the many FMan sub-devices. The FMan
229f4bb47512ec Calvin Johnson    2020-06-22  380  	 * defines a register space that spans a large area, covering all the
229f4bb47512ec Calvin Johnson    2020-06-22  381  	 * subdevice areas. Therefore, MDIO cannot claim exclusive access to
229f4bb47512ec Calvin Johnson    2020-06-22  382  	 * this register area.
229f4bb47512ec Calvin Johnson    2020-06-22  383  	 */
9f35a7342cff0b Timur Tabi        2012-08-20  384  
1d14eb15dc2c39 Tobias Waldekranz 2022-01-26  385  	bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(struct mdio_fsl_priv));
9f35a7342cff0b Timur Tabi        2012-08-20  386  	if (!bus)
9f35a7342cff0b Timur Tabi        2012-08-20  387  		return -ENOMEM;
9f35a7342cff0b Timur Tabi        2012-08-20  388  
9f35a7342cff0b Timur Tabi        2012-08-20  389  	bus->name = "Freescale XGMAC MDIO Bus";
c0fc8e6dcee40c Andrew Lunn       2023-01-09  390  	bus->read = xgmac_mdio_read_c22;
c0fc8e6dcee40c Andrew Lunn       2023-01-09  391  	bus->write = xgmac_mdio_write_c22;
c0fc8e6dcee40c Andrew Lunn       2023-01-09  392  	bus->read_c45 = xgmac_mdio_read_c45;
c0fc8e6dcee40c Andrew Lunn       2023-01-09  393  	bus->write_c45 = xgmac_mdio_write_c45;
9f35a7342cff0b Timur Tabi        2012-08-20  394  	bus->parent = &pdev->dev;
229f4bb47512ec Calvin Johnson    2020-06-22 @395  	snprintf(bus->id, MII_BUS_ID_SIZE, "%pa", &res->start);
                                                                                                   ^^^
res isn't initialized.

9f35a7342cff0b Timur Tabi        2012-08-20  396  
73ee5442978b2d Shaohui Xie       2015-03-16  397  	priv = bus->priv;
865bbb2945a161 Rosen Penev       2024-11-09  398  	priv->mdio_base = devm_platform_ioremap_resource(pdev, 0);
865bbb2945a161 Rosen Penev       2024-11-09  399  	if (IS_ERR(priv->mdio_base))
865bbb2945a161 Rosen Penev       2024-11-09  400  		return PTR_ERR(priv->mdio_base);
9f35a7342cff0b Timur Tabi        2012-08-20  401  
15e7064e879335 Calvin Johnson    2021-06-11  402  	/* For both ACPI and DT cases, endianness of MDIO controller
15e7064e879335 Calvin Johnson    2021-06-11  403  	 * needs to be specified using "little-endian" property.
15e7064e879335 Calvin Johnson    2021-06-11  404  	 */
229f4bb47512ec Calvin Johnson    2020-06-22  405  	priv->is_little_endian = device_property_read_bool(&pdev->dev,
07bf2e11ad0586 Julia Lawall      2016-08-05  406  							   "little-endian");
73ee5442978b2d Shaohui Xie       2015-03-16  407  
6198c722019774 Tobias Waldekranz 2022-01-18  408  	priv->has_a009885 = device_property_read_bool(&pdev->dev,
6198c722019774 Tobias Waldekranz 2022-01-18  409  						      "fsl,erratum-a009885");
229f4bb47512ec Calvin Johnson    2020-06-22  410  	priv->has_a011043 = device_property_read_bool(&pdev->dev,
1d3ca681b9d957 Madalin Bucur     2020-01-22  411  						      "fsl,erratum-a011043");
1d3ca681b9d957 Madalin Bucur     2020-01-22  412  
909bea73485fab Tobias Waldekranz 2022-01-26  413  	xgmac_mdio_set_suppress_preamble(bus);
909bea73485fab Tobias Waldekranz 2022-01-26  414  
dd8f467eda72cd Tobias Waldekranz 2022-01-26  415  	ret = xgmac_mdio_set_mdc_freq(bus);
dd8f467eda72cd Tobias Waldekranz 2022-01-26  416  	if (ret)
dd8f467eda72cd Tobias Waldekranz 2022-01-26  417  		return ret;
dd8f467eda72cd Tobias Waldekranz 2022-01-26  418  
105b0468d7b2e6 zhaoxiao          2022-08-18  419  	fwnode = dev_fwnode(&pdev->dev);
ac53c26433b51f Marcin Wojtas     2021-06-25  420  	if (is_of_node(fwnode))
ac53c26433b51f Marcin Wojtas     2021-06-25  421  		ret = of_mdiobus_register(bus, to_of_node(fwnode));
ac53c26433b51f Marcin Wojtas     2021-06-25  422  	else if (is_acpi_node(fwnode))
ac53c26433b51f Marcin Wojtas     2021-06-25  423  		ret = acpi_mdiobus_register(bus, fwnode);
ac53c26433b51f Marcin Wojtas     2021-06-25  424  	else
ac53c26433b51f Marcin Wojtas     2021-06-25  425  		ret = -EINVAL;
9f35a7342cff0b Timur Tabi        2012-08-20  426  	if (ret) {
9f35a7342cff0b Timur Tabi        2012-08-20  427  		dev_err(&pdev->dev, "cannot register MDIO bus\n");
9f35a7342cff0b Timur Tabi        2012-08-20  428  		return ret;
9f35a7342cff0b Timur Tabi        2012-08-20  429  	}
9f35a7342cff0b Timur Tabi        2012-08-20  430  
1d14eb15dc2c39 Tobias Waldekranz 2022-01-26  431  	platform_set_drvdata(pdev, bus);
9f35a7342cff0b Timur Tabi        2012-08-20  432  
9f35a7342cff0b Timur Tabi        2012-08-20  433  	return 0;
9f35a7342cff0b Timur Tabi        2012-08-20  434  }

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-11-11  9:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-09 23:36 [PATCH] net: modernize ioremap in probe Rosen Penev
2024-11-10 14:18 ` Markus Elfring
2024-11-10 20:28 ` kernel test robot
2024-11-11  9:38 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox