[PATCH 1/3] i2c: set adapter.nr explicitly to -1

Sascha Hauer s.hauer at pengutronix.de
Fri Oct 25 00:30:24 PDT 2024


dev->id will always be -1 for device tree instantiated devices. Instead
of setting adapter.nr to dev->id, set it to -1 explicitly for all I2C
bus drivers that are purely instantiated from device tree.

This is done for clarity just to show that all I2C bus numbers are
really dynamically assigned.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/i2c/busses/i2c-at91.c       | 2 +-
 drivers/i2c/busses/i2c-bcm283x.c    | 2 +-
 drivers/i2c/busses/i2c-cadence.c    | 2 +-
 drivers/i2c/busses/i2c-designware.c | 2 +-
 drivers/i2c/busses/i2c-imx.c        | 2 +-
 drivers/i2c/busses/i2c-mv64xxx.c    | 2 +-
 drivers/i2c/busses/i2c-rockchip.c   | 2 +-
 drivers/i2c/busses/i2c-stm32.c      | 2 +-
 drivers/i2c/busses/i2c-tegra.c      | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 5b1f456187..dbc5aa4ddf 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -558,7 +558,7 @@ static int at91_twi_probe(struct device *dev)
 
 	i2c_at91->adapter.master_xfer = at91_twi_xfer;
 	i2c_at91->adapter.dev.parent = dev;
-	i2c_at91->adapter.nr = dev->id;
+	i2c_at91->adapter.nr = -1;
 	i2c_at91->adapter.dev.of_node = dev->of_node;
 
 	rc = i2c_add_numbered_adapter(&i2c_at91->adapter);
diff --git a/drivers/i2c/busses/i2c-bcm283x.c b/drivers/i2c/busses/i2c-bcm283x.c
index b40918932f..fb69515825 100644
--- a/drivers/i2c/busses/i2c-bcm283x.c
+++ b/drivers/i2c/busses/i2c-bcm283x.c
@@ -306,7 +306,7 @@ static int bcm283x_i2c_probe(struct device *dev)
 	}
 
 	bcm_i2c->adapter.master_xfer = bcm283x_i2c_xfer;
-	bcm_i2c->adapter.nr = dev->id;
+	bcm_i2c->adapter.nr = -1;
 	bcm_i2c->adapter.dev.parent = dev;
 	bcm_i2c->adapter.dev.of_node = np;
 
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index bf9ec30994..8551cd05da 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -422,7 +422,7 @@ static int cdns_i2c_probe(struct device *dev)
 		return err;
 
 	i2c->adapter.master_xfer = cdns_i2c_xfer;
-	i2c->adapter.nr = dev->id;
+	i2c->adapter.nr = -1;
 	i2c->adapter.dev.parent = dev;
 	i2c->adapter.dev.of_node = np;
 
diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
index 152b795c37..3ba10e172a 100644
--- a/drivers/i2c/busses/i2c-designware.c
+++ b/drivers/i2c/busses/i2c-designware.c
@@ -525,7 +525,7 @@ static int i2c_dw_probe(struct device *pdev)
 	}
 
 	dw->adapter.master_xfer = i2c_dw_xfer;
-	dw->adapter.nr = pdev->id;
+	dw->adapter.nr = -1;
 	dw->adapter.dev.parent = pdev;
 	dw->adapter.dev.of_node = pdev->of_node;
 
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 981db015ea..eabb8252ae 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -592,7 +592,7 @@ static int __init i2c_fsl_probe(struct device *pdev)
 
 	/* Setup i2c_fsl driver structure */
 	i2c_fsl->adapter.master_xfer = i2c_fsl_xfer;
-	i2c_fsl->adapter.nr = pdev->id;
+	i2c_fsl->adapter.nr = -1;
 	i2c_fsl->adapter.dev.parent = pdev;
 	i2c_fsl->adapter.dev.of_node = pdev->of_node;
 	iores = dev_request_mem_resource(pdev, 0);
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index 44f1fd4ce6..6629e65b48 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -625,7 +625,7 @@ mv64xxx_i2c_probe(struct device *pd)
 
 	drv_data->adapter.master_xfer = mv64xxx_i2c_xfer;
 	drv_data->adapter.dev.parent = pd;
-	drv_data->adapter.nr = pd->id;
+	drv_data->adapter.nr = -1;
 	drv_data->adapter.dev.of_node = pd->of_node;
 
 	mv64xxx_i2c_hw_init(drv_data);
diff --git a/drivers/i2c/busses/i2c-rockchip.c b/drivers/i2c/busses/i2c-rockchip.c
index ce029d148f..a7bd66781f 100644
--- a/drivers/i2c/busses/i2c-rockchip.c
+++ b/drivers/i2c/busses/i2c-rockchip.c
@@ -432,7 +432,7 @@ static int rk_i2c_probe(struct device *dev)
 		return dev_err_probe(dev, PTR_ERR(i2c->clk), "Can't get bus clk\n");
 
 	i2c->adapter.master_xfer = rockchip_i2c_xfer;
-	i2c->adapter.nr = dev->id;
+	i2c->adapter.nr = -1;
 	i2c->adapter.dev.parent = dev;
 	i2c->adapter.dev.of_node = np;
 
diff --git a/drivers/i2c/busses/i2c-stm32.c b/drivers/i2c/busses/i2c-stm32.c
index 1be52b3dd9..4d40ca3b51 100644
--- a/drivers/i2c/busses/i2c-stm32.c
+++ b/drivers/i2c/busses/i2c-stm32.c
@@ -941,7 +941,7 @@ static int __init stm32_i2c_probe(struct device *dev)
 
 	/* Setup stm32_i2c driver structure */
 	stm32_i2c->adapter.master_xfer = stm32_i2c_xfer;
-	stm32_i2c->adapter.nr = dev->id;
+	stm32_i2c->adapter.nr = -1;
 	stm32_i2c->adapter.dev.parent = dev;
 	stm32_i2c->adapter.dev.of_node = dev->of_node;
 
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index f86f64f573..4271a22f83 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -654,7 +654,7 @@ static int tegra_i2c_probe(struct device *dev)
 
 	i2c_dev->adapter.master_xfer = tegra_i2c_xfer;
 	i2c_dev->adapter.dev.parent = dev;
-	i2c_dev->adapter.nr = dev->id;
+	i2c_dev->adapter.nr = -1;
 	i2c_dev->adapter.dev.of_node = dev->of_node;
 
 	ret = i2c_add_numbered_adapter(&i2c_dev->adapter);

-- 
2.39.5




More information about the barebox mailing list