All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Move OF i2c functions into i2c core
@ 2011-08-05 21:24 ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-05 21:24 UTC (permalink / raw)
  To: Grant Likely; +Cc: linux-kernel, linux-i2c, Rob Herring

From: Rob Herring <rob.herring@calxeda.com>

As suggested by Grant, this series moves OF i2c functions in of_i2c.c into
i2c-core.c. This simplifies OF i2c drivers slightly. Combining the
functions is necessary to avoid a module circular dependency between
i2c-core.ko and of_i2c.ko.

Compile tested on ARM (DT/non-DT VExpress) and PowerPC (8xxx and 44x).

Rob

Rob Herring (3):
  i2c: move of_i2c_register_devices call into core
  i2c: move OF i2c related functions into i2c core
  i2c-designware: add OF binding support

 Documentation/devicetree/bindings/i2c/dw-i2c.txt |   23 +++++
 arch/powerpc/platforms/44x/warp.c                |    1 -
 drivers/i2c/busses/i2c-cpm.c                     |    6 --
 drivers/i2c/busses/i2c-designware.c              |    8 ++
 drivers/i2c/busses/i2c-ibm_iic.c                 |    4 -
 drivers/i2c/busses/i2c-mpc.c                     |    2 -
 drivers/i2c/busses/i2c-pxa.c                     |    2 -
 drivers/i2c/busses/i2c-tegra.c                   |    3 -
 drivers/i2c/i2c-core.c                           |   87 +++++++++++++++++++-
 drivers/of/Makefile                              |    1 -
 drivers/of/of_i2c.c                              |   97 ----------------------
 include/linux/i2c.h                              |    4 +
 include/linux/of_i2c.h                           |   30 -------
 13 files changed, 121 insertions(+), 147 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/dw-i2c.txt
 delete mode 100644 drivers/of/of_i2c.c
 delete mode 100644 include/linux/of_i2c.h

-- 
1.7.4.1


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

* [PATCH 0/3] Move OF i2c functions into i2c core
@ 2011-08-05 21:24 ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-05 21:24 UTC (permalink / raw)
  To: Grant Likely
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Rob Herring

From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>

As suggested by Grant, this series moves OF i2c functions in of_i2c.c into
i2c-core.c. This simplifies OF i2c drivers slightly. Combining the
functions is necessary to avoid a module circular dependency between
i2c-core.ko and of_i2c.ko.

Compile tested on ARM (DT/non-DT VExpress) and PowerPC (8xxx and 44x).

Rob

Rob Herring (3):
  i2c: move of_i2c_register_devices call into core
  i2c: move OF i2c related functions into i2c core
  i2c-designware: add OF binding support

 Documentation/devicetree/bindings/i2c/dw-i2c.txt |   23 +++++
 arch/powerpc/platforms/44x/warp.c                |    1 -
 drivers/i2c/busses/i2c-cpm.c                     |    6 --
 drivers/i2c/busses/i2c-designware.c              |    8 ++
 drivers/i2c/busses/i2c-ibm_iic.c                 |    4 -
 drivers/i2c/busses/i2c-mpc.c                     |    2 -
 drivers/i2c/busses/i2c-pxa.c                     |    2 -
 drivers/i2c/busses/i2c-tegra.c                   |    3 -
 drivers/i2c/i2c-core.c                           |   87 +++++++++++++++++++-
 drivers/of/Makefile                              |    1 -
 drivers/of/of_i2c.c                              |   97 ----------------------
 include/linux/i2c.h                              |    4 +
 include/linux/of_i2c.h                           |   30 -------
 13 files changed, 121 insertions(+), 147 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/dw-i2c.txt
 delete mode 100644 drivers/of/of_i2c.c
 delete mode 100644 include/linux/of_i2c.h

-- 
1.7.4.1

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

* [PATCH 1/3] i2c: move of_i2c_register_devices call into core
  2011-08-05 21:24 ` Rob Herring
@ 2011-08-05 21:24   ` Rob Herring
  -1 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-05 21:24 UTC (permalink / raw)
  To: Grant Likely
  Cc: linux-kernel, linux-i2c, Rob Herring, Jochen Friedrich,
	Jean Delvare, Ben Dooks, Sebastian Andrzej Siewior,
	Dirk Brandewie, Stephen Warren, linuxppc-dev

From: Rob Herring <rob.herring@calxeda.com>

All callers of of_i2c_register_devices are immediately preceded by a call
to i2c_add_adapter or i2c_add_numbered_adapter. Add call to
of_i2c_register_devices and remove all other callers.

This causes a module dependency loop that is resolved by the next commit.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Jochen Friedrich <jochen@scram.de>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Dirk Brandewie <dirk.brandewie@gmail.com>
Cc: Stephen Warren <swarren@nvidia.com>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-i2c@vger.kernel.org
---
 drivers/i2c/busses/i2c-cpm.c     |    6 ------
 drivers/i2c/busses/i2c-ibm_iic.c |    4 ----
 drivers/i2c/busses/i2c-mpc.c     |    2 --
 drivers/i2c/busses/i2c-pxa.c     |    2 --
 drivers/i2c/busses/i2c-tegra.c   |    3 ---
 drivers/i2c/i2c-core.c           |    4 ++++
 6 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
index b1d9cd2..7cbc82a 100644
--- a/drivers/i2c/busses/i2c-cpm.c
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -42,7 +42,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
-#include <linux/of_i2c.h>
 #include <sysdev/fsl_soc.h>
 #include <asm/cpm.h>
 
@@ -673,11 +672,6 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev)
 	dev_dbg(&ofdev->dev, "hw routines for %s registered.\n",
 		cpm->adap.name);
 
-	/*
-	 * register OF I2C devices
-	 */
-	of_i2c_register_devices(&cpm->adap);
-
 	return 0;
 out_shut:
 	cpm_i2c_shutdown(cpm);
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 3c110fb..5ba15ba 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -42,7 +42,6 @@
 #include <linux/io.h>
 #include <linux/i2c.h>
 #include <linux/of_platform.h>
-#include <linux/of_i2c.h>
 
 #include "i2c-ibm_iic.h"
 
@@ -759,9 +758,6 @@ static int __devinit iic_probe(struct platform_device *ofdev)
 	dev_info(&ofdev->dev, "using %s mode\n",
 		 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
 
-	/* Now register all the child nodes */
-	of_i2c_register_devices(adap);
-
 	return 0;
 
 error_cleanup:
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 107397a..a433f59 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -18,7 +18,6 @@
 #include <linux/sched.h>
 #include <linux/init.h>
 #include <linux/of_platform.h>
-#include <linux/of_i2c.h>
 #include <linux/slab.h>
 
 #include <linux/io.h>
@@ -637,7 +636,6 @@ static int __devinit fsl_i2c_probe(struct platform_device *op)
 		dev_err(i2c->dev, "failed to add adapter\n");
 		goto fail_add;
 	}
-	of_i2c_register_devices(&i2c->adap);
 
 	return result;
 
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index d603646..c1c2885 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -29,7 +29,6 @@
 #include <linux/errno.h>
 #include <linux/interrupt.h>
 #include <linux/i2c-pxa.h>
-#include <linux/of_i2c.h>
 #include <linux/platform_device.h>
 #include <linux/err.h>
 #include <linux/clk.h>
@@ -1147,7 +1146,6 @@ static int i2c_pxa_probe(struct platform_device *dev)
 		printk(KERN_INFO "I2C: Failed to add bus\n");
 		goto eadapt;
 	}
-	of_i2c_register_devices(&i2c->adap);
 
 	platform_set_drvdata(dev, i2c);
 
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 2440b74..9ec0a58 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -26,7 +26,6 @@
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/i2c-tegra.h>
-#include <linux/of_i2c.h>
 
 #include <asm/unaligned.h>
 
@@ -653,8 +652,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
 		goto err_free_irq;
 	}
 
-	of_i2c_register_devices(&i2c_dev->adapter);
-
 	return 0;
 err_free_irq:
 	free_irq(i2c_dev->irq, i2c_dev);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 131079a..011e195 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -32,6 +32,7 @@
 #include <linux/init.h>
 #include <linux/idr.h>
 #include <linux/mutex.h>
+#include <linux/of_i2c.h>
 #include <linux/of_device.h>
 #include <linux/completion.h>
 #include <linux/hardirq.h>
@@ -863,6 +864,9 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
 	if (adap->nr < __i2c_first_dynamic_bus_num)
 		i2c_scan_static_board_info(adap);
 
+	/* Register devices from the device tree */
+	of_i2c_register_devices(adap);
+
 	/* Notify drivers */
 	mutex_lock(&core_lock);
 	bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);
-- 
1.7.4.1


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

* [PATCH 1/3] i2c: move of_i2c_register_devices call into core
@ 2011-08-05 21:24   ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-05 21:24 UTC (permalink / raw)
  To: Grant Likely
  Cc: Stephen Warren, Sebastian Andrzej Siewior, Rob Herring,
	linux-kernel, Dirk Brandewie, linux-i2c, Ben Dooks, Jean Delvare,
	linuxppc-dev

From: Rob Herring <rob.herring@calxeda.com>

All callers of of_i2c_register_devices are immediately preceded by a call
to i2c_add_adapter or i2c_add_numbered_adapter. Add call to
of_i2c_register_devices and remove all other callers.

This causes a module dependency loop that is resolved by the next commit.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Jochen Friedrich <jochen@scram.de>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Dirk Brandewie <dirk.brandewie@gmail.com>
Cc: Stephen Warren <swarren@nvidia.com>
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-i2c@vger.kernel.org
---
 drivers/i2c/busses/i2c-cpm.c     |    6 ------
 drivers/i2c/busses/i2c-ibm_iic.c |    4 ----
 drivers/i2c/busses/i2c-mpc.c     |    2 --
 drivers/i2c/busses/i2c-pxa.c     |    2 --
 drivers/i2c/busses/i2c-tegra.c   |    3 ---
 drivers/i2c/i2c-core.c           |    4 ++++
 6 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
index b1d9cd2..7cbc82a 100644
--- a/drivers/i2c/busses/i2c-cpm.c
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -42,7 +42,6 @@
 #include <linux/dma-mapping.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
-#include <linux/of_i2c.h>
 #include <sysdev/fsl_soc.h>
 #include <asm/cpm.h>
 
@@ -673,11 +672,6 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev)
 	dev_dbg(&ofdev->dev, "hw routines for %s registered.\n",
 		cpm->adap.name);
 
-	/*
-	 * register OF I2C devices
-	 */
-	of_i2c_register_devices(&cpm->adap);
-
 	return 0;
 out_shut:
 	cpm_i2c_shutdown(cpm);
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 3c110fb..5ba15ba 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -42,7 +42,6 @@
 #include <linux/io.h>
 #include <linux/i2c.h>
 #include <linux/of_platform.h>
-#include <linux/of_i2c.h>
 
 #include "i2c-ibm_iic.h"
 
@@ -759,9 +758,6 @@ static int __devinit iic_probe(struct platform_device *ofdev)
 	dev_info(&ofdev->dev, "using %s mode\n",
 		 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
 
-	/* Now register all the child nodes */
-	of_i2c_register_devices(adap);
-
 	return 0;
 
 error_cleanup:
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index 107397a..a433f59 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -18,7 +18,6 @@
 #include <linux/sched.h>
 #include <linux/init.h>
 #include <linux/of_platform.h>
-#include <linux/of_i2c.h>
 #include <linux/slab.h>
 
 #include <linux/io.h>
@@ -637,7 +636,6 @@ static int __devinit fsl_i2c_probe(struct platform_device *op)
 		dev_err(i2c->dev, "failed to add adapter\n");
 		goto fail_add;
 	}
-	of_i2c_register_devices(&i2c->adap);
 
 	return result;
 
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index d603646..c1c2885 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -29,7 +29,6 @@
 #include <linux/errno.h>
 #include <linux/interrupt.h>
 #include <linux/i2c-pxa.h>
-#include <linux/of_i2c.h>
 #include <linux/platform_device.h>
 #include <linux/err.h>
 #include <linux/clk.h>
@@ -1147,7 +1146,6 @@ static int i2c_pxa_probe(struct platform_device *dev)
 		printk(KERN_INFO "I2C: Failed to add bus\n");
 		goto eadapt;
 	}
-	of_i2c_register_devices(&i2c->adap);
 
 	platform_set_drvdata(dev, i2c);
 
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 2440b74..9ec0a58 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -26,7 +26,6 @@
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/i2c-tegra.h>
-#include <linux/of_i2c.h>
 
 #include <asm/unaligned.h>
 
@@ -653,8 +652,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
 		goto err_free_irq;
 	}
 
-	of_i2c_register_devices(&i2c_dev->adapter);
-
 	return 0;
 err_free_irq:
 	free_irq(i2c_dev->irq, i2c_dev);
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 131079a..011e195 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -32,6 +32,7 @@
 #include <linux/init.h>
 #include <linux/idr.h>
 #include <linux/mutex.h>
+#include <linux/of_i2c.h>
 #include <linux/of_device.h>
 #include <linux/completion.h>
 #include <linux/hardirq.h>
@@ -863,6 +864,9 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
 	if (adap->nr < __i2c_first_dynamic_bus_num)
 		i2c_scan_static_board_info(adap);
 
+	/* Register devices from the device tree */
+	of_i2c_register_devices(adap);
+
 	/* Notify drivers */
 	mutex_lock(&core_lock);
 	bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);
-- 
1.7.4.1

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

* [PATCH 2/3] i2c: move OF i2c related functions into i2c core
  2011-08-05 21:24 ` Rob Herring
  (?)
  (?)
@ 2011-08-05 21:24 ` Rob Herring
  2011-08-05 22:56     ` Grant Likely
  -1 siblings, 1 reply; 24+ messages in thread
From: Rob Herring @ 2011-08-05 21:24 UTC (permalink / raw)
  To: Grant Likely
  Cc: linux-kernel, linux-i2c, Rob Herring, Jean Delvare, Ben Dooks

From: Rob Herring <rob.herring@calxeda.com>

This simplifies i2c drivers by removing calls to of_i2c_register_devices
and resolves a module circular dependency between i2c-core and of_i2c.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: linux-i2c@vger.kernel.org
---
 arch/powerpc/platforms/44x/warp.c |    1 -
 drivers/i2c/i2c-core.c            |   85 +++++++++++++++++++++++++++++++-
 drivers/of/Makefile               |    1 -
 drivers/of/of_i2c.c               |   97 -------------------------------------
 include/linux/i2c.h               |    4 ++
 include/linux/of_i2c.h            |   30 -----------
 6 files changed, 87 insertions(+), 131 deletions(-)
 delete mode 100644 drivers/of/of_i2c.c
 delete mode 100644 include/linux/of_i2c.h

diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
index 8f77139..9327ccf 100644
--- a/arch/powerpc/platforms/44x/warp.c
+++ b/arch/powerpc/platforms/44x/warp.c
@@ -16,7 +16,6 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/of_gpio.h>
-#include <linux/of_i2c.h>
 #include <linux/slab.h>
 
 #include <asm/machdep.h>
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 011e195..478c7f2 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -22,7 +22,10 @@
    SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> and
    Jean Delvare <khali@linux-fr.org>
    Mux support by Rodolfo Giometti <giometti@enneenne.com> and
-   Michael Lawnick <michael.lawnick.ext@nsn.com> */
+   Michael Lawnick <michael.lawnick.ext@nsn.com>
+   OF support by Jochen Friedrich <jochen@scram.de> and
+   Jon Smirl <jonsmirl@gmail.com>
+   */
 
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -32,7 +35,6 @@
 #include <linux/init.h>
 #include <linux/idr.h>
 #include <linux/mutex.h>
-#include <linux/of_i2c.h>
 #include <linux/of_device.h>
 #include <linux/completion.h>
 #include <linux/hardirq.h>
@@ -790,6 +792,85 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter)
 	up_read(&__i2c_board_lock);
 }
 
+#ifdef CONFIG_OF_I2C
+static void of_i2c_register_devices(struct i2c_adapter *adap)
+{
+	void *result;
+	struct device_node *node;
+
+	/* Only register child devices if the adapter has a node pointer set */
+	if (!adap->dev.of_node)
+		return;
+
+	dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
+
+	for_each_child_of_node(adap->dev.of_node, node) {
+		struct i2c_board_info info = {};
+		struct dev_archdata dev_ad = {};
+		const __be32 *addr;
+		int len;
+
+		dev_dbg(&adap->dev, "of_i2c: register %s\n", node->full_name);
+
+		if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
+			dev_err(&adap->dev, "of_i2c: modalias failure on %s\n",
+				node->full_name);
+			continue;
+		}
+
+		addr = of_get_property(node, "reg", &len);
+		if (!addr || (len < sizeof(int))) {
+			dev_err(&adap->dev, "of_i2c: invalid reg on %s\n",
+				node->full_name);
+			continue;
+		}
+
+		info.addr = be32_to_cpup(addr);
+		if (info.addr > (1 << 10) - 1) {
+			dev_err(&adap->dev, "of_i2c: invalid addr=%x on %s\n",
+				info.addr, node->full_name);
+			continue;
+		}
+
+		info.irq = irq_of_parse_and_map(node, 0);
+		info.of_node = of_node_get(node);
+		info.archdata = &dev_ad;
+
+		request_module("%s%s", I2C_MODULE_PREFIX, info.type);
+
+		result = i2c_new_device(adap, &info);
+		if (result == NULL) {
+			dev_err(&adap->dev, "of_i2c: Failure registering %s\n",
+			        node->full_name);
+			of_node_put(node);
+			irq_dispose_mapping(info.irq);
+			continue;
+		}
+	}
+}
+
+static int of_dev_node_match(struct device *dev, void *data)
+{
+        return dev->of_node == data;
+}
+
+/* must call put_device() when done with returned i2c_client device */
+struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
+{
+	struct device *dev;
+
+	dev = bus_find_device(&i2c_bus_type, NULL, node,
+					 of_dev_node_match);
+	if (!dev)
+		return NULL;
+
+	return to_i2c_client(dev);
+}
+EXPORT_SYMBOL(of_find_i2c_device_by_node);
+#else
+static void of_i2c_register_devices(struct i2c_adapter *adap) {}
+#endif
+
 static int i2c_do_add_adapter(struct i2c_driver *driver,
 			      struct i2c_adapter *adap)
 {
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index dccb117..faa007c 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -5,7 +5,6 @@ obj-$(CONFIG_OF_ADDRESS)  += address.o
 obj-$(CONFIG_OF_IRQ)    += irq.o
 obj-$(CONFIG_OF_DEVICE) += device.o platform.o
 obj-$(CONFIG_OF_GPIO)   += gpio.o
-obj-$(CONFIG_OF_I2C)	+= of_i2c.o
 obj-$(CONFIG_OF_NET)	+= of_net.o
 obj-$(CONFIG_OF_SPI)	+= of_spi.o
 obj-$(CONFIG_OF_MDIO)	+= of_mdio.o
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
deleted file mode 100644
index f37fbeb..0000000
--- a/drivers/of/of_i2c.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * OF helpers for the I2C API
- *
- * Copyright (c) 2008 Jochen Friedrich <jochen@scram.de>
- *
- * Based on a previous patch from Jon Smirl <jonsmirl@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#include <linux/i2c.h>
-#include <linux/irq.h>
-#include <linux/of.h>
-#include <linux/of_i2c.h>
-#include <linux/of_irq.h>
-#include <linux/module.h>
-
-void of_i2c_register_devices(struct i2c_adapter *adap)
-{
-	void *result;
-	struct device_node *node;
-
-	/* Only register child devices if the adapter has a node pointer set */
-	if (!adap->dev.of_node)
-		return;
-
-	dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
-
-	for_each_child_of_node(adap->dev.of_node, node) {
-		struct i2c_board_info info = {};
-		struct dev_archdata dev_ad = {};
-		const __be32 *addr;
-		int len;
-
-		dev_dbg(&adap->dev, "of_i2c: register %s\n", node->full_name);
-
-		if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
-			dev_err(&adap->dev, "of_i2c: modalias failure on %s\n",
-				node->full_name);
-			continue;
-		}
-
-		addr = of_get_property(node, "reg", &len);
-		if (!addr || (len < sizeof(int))) {
-			dev_err(&adap->dev, "of_i2c: invalid reg on %s\n",
-				node->full_name);
-			continue;
-		}
-
-		info.addr = be32_to_cpup(addr);
-		if (info.addr > (1 << 10) - 1) {
-			dev_err(&adap->dev, "of_i2c: invalid addr=%x on %s\n",
-				info.addr, node->full_name);
-			continue;
-		}
-
-		info.irq = irq_of_parse_and_map(node, 0);
-		info.of_node = of_node_get(node);
-		info.archdata = &dev_ad;
-
-		request_module("%s%s", I2C_MODULE_PREFIX, info.type);
-
-		result = i2c_new_device(adap, &info);
-		if (result == NULL) {
-			dev_err(&adap->dev, "of_i2c: Failure registering %s\n",
-			        node->full_name);
-			of_node_put(node);
-			irq_dispose_mapping(info.irq);
-			continue;
-		}
-	}
-}
-EXPORT_SYMBOL(of_i2c_register_devices);
-
-static int of_dev_node_match(struct device *dev, void *data)
-{
-        return dev->of_node == data;
-}
-
-/* must call put_device() when done with returned i2c_client device */
-struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
-{
-	struct device *dev;
-
-	dev = bus_find_device(&i2c_bus_type, NULL, node,
-					 of_dev_node_match);
-	if (!dev)
-		return NULL;
-
-	return to_i2c_client(dev);
-}
-EXPORT_SYMBOL(of_find_i2c_device_by_node);
-
-MODULE_LICENSE("GPL");
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index a6c652e..830397b 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -468,6 +468,10 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap)
 {
 	return adap->nr;
 }
+
+/* must call put_device() when done with returned i2c_client device */
+extern struct i2c_client *of_find_i2c_device_by_node(struct device_node *node);
+
 #endif /* I2C */
 #endif /* __KERNEL__ */
 
diff --git a/include/linux/of_i2c.h b/include/linux/of_i2c.h
deleted file mode 100644
index 0efe8d4..0000000
--- a/include/linux/of_i2c.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Generic I2C API implementation for PowerPC.
- *
- * Copyright (c) 2008 Jochen Friedrich <jochen@scram.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- */
-
-#ifndef __LINUX_OF_I2C_H
-#define __LINUX_OF_I2C_H
-
-#if defined(CONFIG_OF_I2C) || defined(CONFIG_OF_I2C_MODULE)
-#include <linux/i2c.h>
-
-extern void of_i2c_register_devices(struct i2c_adapter *adap);
-
-/* must call put_device() when done with returned i2c_client device */
-extern struct i2c_client *of_find_i2c_device_by_node(struct device_node *node);
-
-#else
-static inline void of_i2c_register_devices(struct i2c_adapter *adap)
-{
-	return;
-}
-#endif /* CONFIG_OF_I2C */
-
-#endif /* __LINUX_OF_I2C_H */
-- 
1.7.4.1


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

* [PATCH 3/3] i2c-designware: add OF binding support
@ 2011-08-05 21:24   ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-05 21:24 UTC (permalink / raw)
  To: Grant Likely
  Cc: linux-kernel, linux-i2c, Rob Herring, devicetree-discuss, Ben Dooks

From: Rob Herring <rob.herring@calxeda.com>

Add of_match_table and DT style i2c registration to designware i2c
driver.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Cc: devicetree-discuss@lists.ozlabs.org
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: linux-i2c@vger.kernel.org
---
 Documentation/devicetree/bindings/i2c/dw-i2c.txt |   23 ++++++++++++++++++++++
 drivers/i2c/busses/i2c-designware.c              |    8 +++++++
 2 files changed, 31 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/dw-i2c.txt

diff --git a/Documentation/devicetree/bindings/i2c/dw-i2c.txt b/Documentation/devicetree/bindings/i2c/dw-i2c.txt
new file mode 100644
index 0000000..cbcb404
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/dw-i2c.txt
@@ -0,0 +1,23 @@
+* Synopsys DesignWare I2C
+
+Required properties :
+
+ - compatible : should be "snps,designware-i2c"
+ - reg : Offset and length of the register set for the device
+ - interrupts : <IRQ> where IRQ is the interrupt number.
+
+Recommended properties :
+
+ - clock-frequency : desired I2C bus clock frequency in Hz.
+
+Example :
+
+	i2c@f0000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "snps,designware-i2c";
+		reg = <0xf0000 0x1000>;
+		interrupts = <11>;
+		clock-frequency = <400000>;
+	};
+
diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
index b7a51c4..0223b98 100644
--- a/drivers/i2c/busses/i2c-designware.c
+++ b/drivers/i2c/busses/i2c-designware.c
@@ -769,6 +769,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
 			sizeof(adap->name));
 	adap->algo = &i2c_dw_algo;
 	adap->dev.parent = &pdev->dev;
+	adap->dev.of_node = pdev->dev.of_node;
 
 	adap->nr = pdev->id;
 	r = i2c_add_numbered_adapter(adap);
@@ -819,6 +820,12 @@ static int __devexit dw_i2c_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct of_device_id dw_i2c_of_match[] = {
+	{ .compatible = "snps,designware-i2c", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
+
 /* work with hotplug and coldplug */
 MODULE_ALIAS("platform:i2c_designware");
 
@@ -827,6 +834,7 @@ static struct platform_driver dw_i2c_driver = {
 	.driver		= {
 		.name	= "i2c_designware",
 		.owner	= THIS_MODULE,
+		.of_match_table = dw_i2c_of_match,
 	},
 };
 
-- 
1.7.4.1


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

* [PATCH 3/3] i2c-designware: add OF binding support
@ 2011-08-05 21:24   ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-05 21:24 UTC (permalink / raw)
  To: Grant Likely
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Rob Herring,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ, Ben Dooks

From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>

Add of_match_table and DT style i2c registration to designware i2c
driver.

Signed-off-by: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
 Documentation/devicetree/bindings/i2c/dw-i2c.txt |   23 ++++++++++++++++++++++
 drivers/i2c/busses/i2c-designware.c              |    8 +++++++
 2 files changed, 31 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/i2c/dw-i2c.txt

diff --git a/Documentation/devicetree/bindings/i2c/dw-i2c.txt b/Documentation/devicetree/bindings/i2c/dw-i2c.txt
new file mode 100644
index 0000000..cbcb404
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/dw-i2c.txt
@@ -0,0 +1,23 @@
+* Synopsys DesignWare I2C
+
+Required properties :
+
+ - compatible : should be "snps,designware-i2c"
+ - reg : Offset and length of the register set for the device
+ - interrupts : <IRQ> where IRQ is the interrupt number.
+
+Recommended properties :
+
+ - clock-frequency : desired I2C bus clock frequency in Hz.
+
+Example :
+
+	i2c@f0000 {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		compatible = "snps,designware-i2c";
+		reg = <0xf0000 0x1000>;
+		interrupts = <11>;
+		clock-frequency = <400000>;
+	};
+
diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
index b7a51c4..0223b98 100644
--- a/drivers/i2c/busses/i2c-designware.c
+++ b/drivers/i2c/busses/i2c-designware.c
@@ -769,6 +769,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
 			sizeof(adap->name));
 	adap->algo = &i2c_dw_algo;
 	adap->dev.parent = &pdev->dev;
+	adap->dev.of_node = pdev->dev.of_node;
 
 	adap->nr = pdev->id;
 	r = i2c_add_numbered_adapter(adap);
@@ -819,6 +820,12 @@ static int __devexit dw_i2c_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static const struct of_device_id dw_i2c_of_match[] = {
+	{ .compatible = "snps,designware-i2c", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
+
 /* work with hotplug and coldplug */
 MODULE_ALIAS("platform:i2c_designware");
 
@@ -827,6 +834,7 @@ static struct platform_driver dw_i2c_driver = {
 	.driver		= {
 		.name	= "i2c_designware",
 		.owner	= THIS_MODULE,
+		.of_match_table = dw_i2c_of_match,
 	},
 };
 
-- 
1.7.4.1

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

* Re: [PATCH 1/3] i2c: move of_i2c_register_devices call into core
@ 2011-08-05 22:54     ` Grant Likely
  0 siblings, 0 replies; 24+ messages in thread
From: Grant Likely @ 2011-08-05 22:54 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel, linux-i2c, Rob Herring, Jochen Friedrich,
	Jean Delvare, Ben Dooks, Sebastian Andrzej Siewior,
	Dirk Brandewie, Stephen Warren, linuxppc-dev

On Fri, Aug 05, 2011 at 04:24:26PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> All callers of of_i2c_register_devices are immediately preceded by a call
> to i2c_add_adapter or i2c_add_numbered_adapter. Add call to
> of_i2c_register_devices and remove all other callers.
> 
> This causes a module dependency loop that is resolved by the next commit.

Wrong way around.  Don't break bisectability.  I'll leave it up to Ben
and Jean on weather or not they want to move this code.  I intend to
do the same thing for spi/gpio, but I maintain those subsystems so I
get to choose.  i2c is not up to me.

g.

> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Jochen Friedrich <jochen@scram.de>
> Cc: Jean Delvare <khali@linux-fr.org>
> Cc: Ben Dooks <ben-linux@fluff.org>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Cc: Dirk Brandewie <dirk.brandewie@gmail.com>
> Cc: Stephen Warren <swarren@nvidia.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-i2c@vger.kernel.org
> ---
>  drivers/i2c/busses/i2c-cpm.c     |    6 ------
>  drivers/i2c/busses/i2c-ibm_iic.c |    4 ----
>  drivers/i2c/busses/i2c-mpc.c     |    2 --
>  drivers/i2c/busses/i2c-pxa.c     |    2 --
>  drivers/i2c/busses/i2c-tegra.c   |    3 ---
>  drivers/i2c/i2c-core.c           |    4 ++++
>  6 files changed, 4 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
> index b1d9cd2..7cbc82a 100644
> --- a/drivers/i2c/busses/i2c-cpm.c
> +++ b/drivers/i2c/busses/i2c-cpm.c
> @@ -42,7 +42,6 @@
>  #include <linux/dma-mapping.h>
>  #include <linux/of_device.h>
>  #include <linux/of_platform.h>
> -#include <linux/of_i2c.h>
>  #include <sysdev/fsl_soc.h>
>  #include <asm/cpm.h>
>  
> @@ -673,11 +672,6 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev)
>  	dev_dbg(&ofdev->dev, "hw routines for %s registered.\n",
>  		cpm->adap.name);
>  
> -	/*
> -	 * register OF I2C devices
> -	 */
> -	of_i2c_register_devices(&cpm->adap);
> -
>  	return 0;
>  out_shut:
>  	cpm_i2c_shutdown(cpm);
> diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
> index 3c110fb..5ba15ba 100644
> --- a/drivers/i2c/busses/i2c-ibm_iic.c
> +++ b/drivers/i2c/busses/i2c-ibm_iic.c
> @@ -42,7 +42,6 @@
>  #include <linux/io.h>
>  #include <linux/i2c.h>
>  #include <linux/of_platform.h>
> -#include <linux/of_i2c.h>
>  
>  #include "i2c-ibm_iic.h"
>  
> @@ -759,9 +758,6 @@ static int __devinit iic_probe(struct platform_device *ofdev)
>  	dev_info(&ofdev->dev, "using %s mode\n",
>  		 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
>  
> -	/* Now register all the child nodes */
> -	of_i2c_register_devices(adap);
> -
>  	return 0;
>  
>  error_cleanup:
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 107397a..a433f59 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -18,7 +18,6 @@
>  #include <linux/sched.h>
>  #include <linux/init.h>
>  #include <linux/of_platform.h>
> -#include <linux/of_i2c.h>
>  #include <linux/slab.h>
>  
>  #include <linux/io.h>
> @@ -637,7 +636,6 @@ static int __devinit fsl_i2c_probe(struct platform_device *op)
>  		dev_err(i2c->dev, "failed to add adapter\n");
>  		goto fail_add;
>  	}
> -	of_i2c_register_devices(&i2c->adap);
>  
>  	return result;
>  
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index d603646..c1c2885 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -29,7 +29,6 @@
>  #include <linux/errno.h>
>  #include <linux/interrupt.h>
>  #include <linux/i2c-pxa.h>
> -#include <linux/of_i2c.h>
>  #include <linux/platform_device.h>
>  #include <linux/err.h>
>  #include <linux/clk.h>
> @@ -1147,7 +1146,6 @@ static int i2c_pxa_probe(struct platform_device *dev)
>  		printk(KERN_INFO "I2C: Failed to add bus\n");
>  		goto eadapt;
>  	}
> -	of_i2c_register_devices(&i2c->adap);
>  
>  	platform_set_drvdata(dev, i2c);
>  
> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
> index 2440b74..9ec0a58 100644
> --- a/drivers/i2c/busses/i2c-tegra.c
> +++ b/drivers/i2c/busses/i2c-tegra.c
> @@ -26,7 +26,6 @@
>  #include <linux/delay.h>
>  #include <linux/slab.h>
>  #include <linux/i2c-tegra.h>
> -#include <linux/of_i2c.h>
>  
>  #include <asm/unaligned.h>
>  
> @@ -653,8 +652,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
>  		goto err_free_irq;
>  	}
>  
> -	of_i2c_register_devices(&i2c_dev->adapter);
> -
>  	return 0;
>  err_free_irq:
>  	free_irq(i2c_dev->irq, i2c_dev);
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 131079a..011e195 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -32,6 +32,7 @@
>  #include <linux/init.h>
>  #include <linux/idr.h>
>  #include <linux/mutex.h>
> +#include <linux/of_i2c.h>
>  #include <linux/of_device.h>
>  #include <linux/completion.h>
>  #include <linux/hardirq.h>
> @@ -863,6 +864,9 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
>  	if (adap->nr < __i2c_first_dynamic_bus_num)
>  		i2c_scan_static_board_info(adap);
>  
> +	/* Register devices from the device tree */
> +	of_i2c_register_devices(adap);
> +
>  	/* Notify drivers */
>  	mutex_lock(&core_lock);
>  	bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);
> -- 
> 1.7.4.1
> 

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

* Re: [PATCH 1/3] i2c: move of_i2c_register_devices call into core
@ 2011-08-05 22:54     ` Grant Likely
  0 siblings, 0 replies; 24+ messages in thread
From: Grant Likely @ 2011-08-05 22:54 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Jochen Friedrich,
	Jean Delvare, Ben Dooks, Sebastian Andrzej Siewior,
	Dirk Brandewie, Stephen Warren,
	linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ

On Fri, Aug 05, 2011 at 04:24:26PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
> 
> All callers of of_i2c_register_devices are immediately preceded by a call
> to i2c_add_adapter or i2c_add_numbered_adapter. Add call to
> of_i2c_register_devices and remove all other callers.
> 
> This causes a module dependency loop that is resolved by the next commit.

Wrong way around.  Don't break bisectability.  I'll leave it up to Ben
and Jean on weather or not they want to move this code.  I intend to
do the same thing for spi/gpio, but I maintain those subsystems so I
get to choose.  i2c is not up to me.

g.

> 
> Signed-off-by: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> Cc: Jochen Friedrich <jochen-NIgtFMG+Po8@public.gmane.org>
> Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
> Cc: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
> Cc: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Cc: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
> Cc: linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> ---
>  drivers/i2c/busses/i2c-cpm.c     |    6 ------
>  drivers/i2c/busses/i2c-ibm_iic.c |    4 ----
>  drivers/i2c/busses/i2c-mpc.c     |    2 --
>  drivers/i2c/busses/i2c-pxa.c     |    2 --
>  drivers/i2c/busses/i2c-tegra.c   |    3 ---
>  drivers/i2c/i2c-core.c           |    4 ++++
>  6 files changed, 4 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
> index b1d9cd2..7cbc82a 100644
> --- a/drivers/i2c/busses/i2c-cpm.c
> +++ b/drivers/i2c/busses/i2c-cpm.c
> @@ -42,7 +42,6 @@
>  #include <linux/dma-mapping.h>
>  #include <linux/of_device.h>
>  #include <linux/of_platform.h>
> -#include <linux/of_i2c.h>
>  #include <sysdev/fsl_soc.h>
>  #include <asm/cpm.h>
>  
> @@ -673,11 +672,6 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev)
>  	dev_dbg(&ofdev->dev, "hw routines for %s registered.\n",
>  		cpm->adap.name);
>  
> -	/*
> -	 * register OF I2C devices
> -	 */
> -	of_i2c_register_devices(&cpm->adap);
> -
>  	return 0;
>  out_shut:
>  	cpm_i2c_shutdown(cpm);
> diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
> index 3c110fb..5ba15ba 100644
> --- a/drivers/i2c/busses/i2c-ibm_iic.c
> +++ b/drivers/i2c/busses/i2c-ibm_iic.c
> @@ -42,7 +42,6 @@
>  #include <linux/io.h>
>  #include <linux/i2c.h>
>  #include <linux/of_platform.h>
> -#include <linux/of_i2c.h>
>  
>  #include "i2c-ibm_iic.h"
>  
> @@ -759,9 +758,6 @@ static int __devinit iic_probe(struct platform_device *ofdev)
>  	dev_info(&ofdev->dev, "using %s mode\n",
>  		 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
>  
> -	/* Now register all the child nodes */
> -	of_i2c_register_devices(adap);
> -
>  	return 0;
>  
>  error_cleanup:
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 107397a..a433f59 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -18,7 +18,6 @@
>  #include <linux/sched.h>
>  #include <linux/init.h>
>  #include <linux/of_platform.h>
> -#include <linux/of_i2c.h>
>  #include <linux/slab.h>
>  
>  #include <linux/io.h>
> @@ -637,7 +636,6 @@ static int __devinit fsl_i2c_probe(struct platform_device *op)
>  		dev_err(i2c->dev, "failed to add adapter\n");
>  		goto fail_add;
>  	}
> -	of_i2c_register_devices(&i2c->adap);
>  
>  	return result;
>  
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index d603646..c1c2885 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -29,7 +29,6 @@
>  #include <linux/errno.h>
>  #include <linux/interrupt.h>
>  #include <linux/i2c-pxa.h>
> -#include <linux/of_i2c.h>
>  #include <linux/platform_device.h>
>  #include <linux/err.h>
>  #include <linux/clk.h>
> @@ -1147,7 +1146,6 @@ static int i2c_pxa_probe(struct platform_device *dev)
>  		printk(KERN_INFO "I2C: Failed to add bus\n");
>  		goto eadapt;
>  	}
> -	of_i2c_register_devices(&i2c->adap);
>  
>  	platform_set_drvdata(dev, i2c);
>  
> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
> index 2440b74..9ec0a58 100644
> --- a/drivers/i2c/busses/i2c-tegra.c
> +++ b/drivers/i2c/busses/i2c-tegra.c
> @@ -26,7 +26,6 @@
>  #include <linux/delay.h>
>  #include <linux/slab.h>
>  #include <linux/i2c-tegra.h>
> -#include <linux/of_i2c.h>
>  
>  #include <asm/unaligned.h>
>  
> @@ -653,8 +652,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
>  		goto err_free_irq;
>  	}
>  
> -	of_i2c_register_devices(&i2c_dev->adapter);
> -
>  	return 0;
>  err_free_irq:
>  	free_irq(i2c_dev->irq, i2c_dev);
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 131079a..011e195 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -32,6 +32,7 @@
>  #include <linux/init.h>
>  #include <linux/idr.h>
>  #include <linux/mutex.h>
> +#include <linux/of_i2c.h>
>  #include <linux/of_device.h>
>  #include <linux/completion.h>
>  #include <linux/hardirq.h>
> @@ -863,6 +864,9 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
>  	if (adap->nr < __i2c_first_dynamic_bus_num)
>  		i2c_scan_static_board_info(adap);
>  
> +	/* Register devices from the device tree */
> +	of_i2c_register_devices(adap);
> +
>  	/* Notify drivers */
>  	mutex_lock(&core_lock);
>  	bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);
> -- 
> 1.7.4.1
> 

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

* Re: [PATCH 1/3] i2c: move of_i2c_register_devices call into core
@ 2011-08-05 22:54     ` Grant Likely
  0 siblings, 0 replies; 24+ messages in thread
From: Grant Likely @ 2011-08-05 22:54 UTC (permalink / raw)
  To: Rob Herring
  Cc: Stephen Warren, Sebastian Andrzej Siewior, Rob Herring,
	linux-kernel, Dirk Brandewie, linux-i2c, Ben Dooks, Jean Delvare,
	linuxppc-dev

On Fri, Aug 05, 2011 at 04:24:26PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> All callers of of_i2c_register_devices are immediately preceded by a call
> to i2c_add_adapter or i2c_add_numbered_adapter. Add call to
> of_i2c_register_devices and remove all other callers.
> 
> This causes a module dependency loop that is resolved by the next commit.

Wrong way around.  Don't break bisectability.  I'll leave it up to Ben
and Jean on weather or not they want to move this code.  I intend to
do the same thing for spi/gpio, but I maintain those subsystems so I
get to choose.  i2c is not up to me.

g.

> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Jochen Friedrich <jochen@scram.de>
> Cc: Jean Delvare <khali@linux-fr.org>
> Cc: Ben Dooks <ben-linux@fluff.org>
> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Cc: Dirk Brandewie <dirk.brandewie@gmail.com>
> Cc: Stephen Warren <swarren@nvidia.com>
> Cc: linuxppc-dev@lists.ozlabs.org
> Cc: linux-i2c@vger.kernel.org
> ---
>  drivers/i2c/busses/i2c-cpm.c     |    6 ------
>  drivers/i2c/busses/i2c-ibm_iic.c |    4 ----
>  drivers/i2c/busses/i2c-mpc.c     |    2 --
>  drivers/i2c/busses/i2c-pxa.c     |    2 --
>  drivers/i2c/busses/i2c-tegra.c   |    3 ---
>  drivers/i2c/i2c-core.c           |    4 ++++
>  6 files changed, 4 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
> index b1d9cd2..7cbc82a 100644
> --- a/drivers/i2c/busses/i2c-cpm.c
> +++ b/drivers/i2c/busses/i2c-cpm.c
> @@ -42,7 +42,6 @@
>  #include <linux/dma-mapping.h>
>  #include <linux/of_device.h>
>  #include <linux/of_platform.h>
> -#include <linux/of_i2c.h>
>  #include <sysdev/fsl_soc.h>
>  #include <asm/cpm.h>
>  
> @@ -673,11 +672,6 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev)
>  	dev_dbg(&ofdev->dev, "hw routines for %s registered.\n",
>  		cpm->adap.name);
>  
> -	/*
> -	 * register OF I2C devices
> -	 */
> -	of_i2c_register_devices(&cpm->adap);
> -
>  	return 0;
>  out_shut:
>  	cpm_i2c_shutdown(cpm);
> diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
> index 3c110fb..5ba15ba 100644
> --- a/drivers/i2c/busses/i2c-ibm_iic.c
> +++ b/drivers/i2c/busses/i2c-ibm_iic.c
> @@ -42,7 +42,6 @@
>  #include <linux/io.h>
>  #include <linux/i2c.h>
>  #include <linux/of_platform.h>
> -#include <linux/of_i2c.h>
>  
>  #include "i2c-ibm_iic.h"
>  
> @@ -759,9 +758,6 @@ static int __devinit iic_probe(struct platform_device *ofdev)
>  	dev_info(&ofdev->dev, "using %s mode\n",
>  		 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
>  
> -	/* Now register all the child nodes */
> -	of_i2c_register_devices(adap);
> -
>  	return 0;
>  
>  error_cleanup:
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index 107397a..a433f59 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -18,7 +18,6 @@
>  #include <linux/sched.h>
>  #include <linux/init.h>
>  #include <linux/of_platform.h>
> -#include <linux/of_i2c.h>
>  #include <linux/slab.h>
>  
>  #include <linux/io.h>
> @@ -637,7 +636,6 @@ static int __devinit fsl_i2c_probe(struct platform_device *op)
>  		dev_err(i2c->dev, "failed to add adapter\n");
>  		goto fail_add;
>  	}
> -	of_i2c_register_devices(&i2c->adap);
>  
>  	return result;
>  
> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
> index d603646..c1c2885 100644
> --- a/drivers/i2c/busses/i2c-pxa.c
> +++ b/drivers/i2c/busses/i2c-pxa.c
> @@ -29,7 +29,6 @@
>  #include <linux/errno.h>
>  #include <linux/interrupt.h>
>  #include <linux/i2c-pxa.h>
> -#include <linux/of_i2c.h>
>  #include <linux/platform_device.h>
>  #include <linux/err.h>
>  #include <linux/clk.h>
> @@ -1147,7 +1146,6 @@ static int i2c_pxa_probe(struct platform_device *dev)
>  		printk(KERN_INFO "I2C: Failed to add bus\n");
>  		goto eadapt;
>  	}
> -	of_i2c_register_devices(&i2c->adap);
>  
>  	platform_set_drvdata(dev, i2c);
>  
> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
> index 2440b74..9ec0a58 100644
> --- a/drivers/i2c/busses/i2c-tegra.c
> +++ b/drivers/i2c/busses/i2c-tegra.c
> @@ -26,7 +26,6 @@
>  #include <linux/delay.h>
>  #include <linux/slab.h>
>  #include <linux/i2c-tegra.h>
> -#include <linux/of_i2c.h>
>  
>  #include <asm/unaligned.h>
>  
> @@ -653,8 +652,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
>  		goto err_free_irq;
>  	}
>  
> -	of_i2c_register_devices(&i2c_dev->adapter);
> -
>  	return 0;
>  err_free_irq:
>  	free_irq(i2c_dev->irq, i2c_dev);
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 131079a..011e195 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -32,6 +32,7 @@
>  #include <linux/init.h>
>  #include <linux/idr.h>
>  #include <linux/mutex.h>
> +#include <linux/of_i2c.h>
>  #include <linux/of_device.h>
>  #include <linux/completion.h>
>  #include <linux/hardirq.h>
> @@ -863,6 +864,9 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
>  	if (adap->nr < __i2c_first_dynamic_bus_num)
>  		i2c_scan_static_board_info(adap);
>  
> +	/* Register devices from the device tree */
> +	of_i2c_register_devices(adap);
> +
>  	/* Notify drivers */
>  	mutex_lock(&core_lock);
>  	bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);
> -- 
> 1.7.4.1
> 

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

* Re: [PATCH 2/3] i2c: move OF i2c related functions into i2c core
@ 2011-08-05 22:56     ` Grant Likely
  0 siblings, 0 replies; 24+ messages in thread
From: Grant Likely @ 2011-08-05 22:56 UTC (permalink / raw)
  To: Rob Herring; +Cc: linux-kernel, linux-i2c, Rob Herring, Jean Delvare, Ben Dooks

On Fri, Aug 05, 2011 at 04:24:27PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> This simplifies i2c drivers by removing calls to of_i2c_register_devices
> and resolves a module circular dependency between i2c-core and of_i2c.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Cc: Grant Likely <grant.likely@secretlab.ca>
> Cc: Jean Delvare <khali@linux-fr.org>
> Cc: Ben Dooks <ben-linux@fluff.org>
> Cc: linux-i2c@vger.kernel.org
> ---
>  arch/powerpc/platforms/44x/warp.c |    1 -
>  drivers/i2c/i2c-core.c            |   85 +++++++++++++++++++++++++++++++-
>  drivers/of/Makefile               |    1 -
>  drivers/of/of_i2c.c               |   97 -------------------------------------
>  include/linux/i2c.h               |    4 ++
>  include/linux/of_i2c.h            |   30 -----------
>  6 files changed, 87 insertions(+), 131 deletions(-)
>  delete mode 100644 drivers/of/of_i2c.c
>  delete mode 100644 include/linux/of_i2c.h
> 
> diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
> index 8f77139..9327ccf 100644
> --- a/arch/powerpc/platforms/44x/warp.c
> +++ b/arch/powerpc/platforms/44x/warp.c
> @@ -16,7 +16,6 @@
>  #include <linux/interrupt.h>
>  #include <linux/delay.h>
>  #include <linux/of_gpio.h>
> -#include <linux/of_i2c.h>
>  #include <linux/slab.h>
>  
>  #include <asm/machdep.h>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 011e195..478c7f2 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -22,7 +22,10 @@
>     SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> and
>     Jean Delvare <khali@linux-fr.org>
>     Mux support by Rodolfo Giometti <giometti@enneenne.com> and
> -   Michael Lawnick <michael.lawnick.ext@nsn.com> */
> +   Michael Lawnick <michael.lawnick.ext@nsn.com>
> +   OF support by Jochen Friedrich <jochen@scram.de> and
> +   Jon Smirl <jonsmirl@gmail.com>
> +   */
>  
>  #include <linux/module.h>
>  #include <linux/kernel.h>
> @@ -32,7 +35,6 @@
>  #include <linux/init.h>
>  #include <linux/idr.h>
>  #include <linux/mutex.h>
> -#include <linux/of_i2c.h>
>  #include <linux/of_device.h>
>  #include <linux/completion.h>
>  #include <linux/hardirq.h>
> @@ -790,6 +792,85 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter)
>  	up_read(&__i2c_board_lock);
>  }
>  
> +#ifdef CONFIG_OF_I2C

I think this becomes simply "#ifdef CONFIG_OF" since CONFIG_I2C is implied at this point.

> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index a6c652e..830397b 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -468,6 +468,10 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap)
>  {
>  	return adap->nr;
>  }
> +
> +/* must call put_device() when done with returned i2c_client device */
> +extern struct i2c_client *of_find_i2c_device_by_node(struct device_node *node);
> +

This shouldn't be defined if !CONFIG_OF

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

* Re: [PATCH 2/3] i2c: move OF i2c related functions into i2c core
@ 2011-08-05 22:56     ` Grant Likely
  0 siblings, 0 replies; 24+ messages in thread
From: Grant Likely @ 2011-08-05 22:56 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Jean Delvare,
	Ben Dooks

On Fri, Aug 05, 2011 at 04:24:27PM -0500, Rob Herring wrote:
> From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
> 
> This simplifies i2c drivers by removing calls to of_i2c_register_devices
> and resolves a module circular dependency between i2c-core and of_i2c.
> 
> Signed-off-by: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
> Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> ---
>  arch/powerpc/platforms/44x/warp.c |    1 -
>  drivers/i2c/i2c-core.c            |   85 +++++++++++++++++++++++++++++++-
>  drivers/of/Makefile               |    1 -
>  drivers/of/of_i2c.c               |   97 -------------------------------------
>  include/linux/i2c.h               |    4 ++
>  include/linux/of_i2c.h            |   30 -----------
>  6 files changed, 87 insertions(+), 131 deletions(-)
>  delete mode 100644 drivers/of/of_i2c.c
>  delete mode 100644 include/linux/of_i2c.h
> 
> diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
> index 8f77139..9327ccf 100644
> --- a/arch/powerpc/platforms/44x/warp.c
> +++ b/arch/powerpc/platforms/44x/warp.c
> @@ -16,7 +16,6 @@
>  #include <linux/interrupt.h>
>  #include <linux/delay.h>
>  #include <linux/of_gpio.h>
> -#include <linux/of_i2c.h>
>  #include <linux/slab.h>
>  
>  #include <asm/machdep.h>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 011e195..478c7f2 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -22,7 +22,10 @@
>     SMBus 2.0 support by Mark Studebaker <mdsxyz123-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> and
>     Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
>     Mux support by Rodolfo Giometti <giometti-AVVDYK/kqiJWk0Htik3J/w@public.gmane.org> and
> -   Michael Lawnick <michael.lawnick.ext-OYasijW0DpE@public.gmane.org> */
> +   Michael Lawnick <michael.lawnick.ext-OYasijW0DpE@public.gmane.org>
> +   OF support by Jochen Friedrich <jochen-NIgtFMG+Po8@public.gmane.org> and
> +   Jon Smirl <jonsmirl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> +   */
>  
>  #include <linux/module.h>
>  #include <linux/kernel.h>
> @@ -32,7 +35,6 @@
>  #include <linux/init.h>
>  #include <linux/idr.h>
>  #include <linux/mutex.h>
> -#include <linux/of_i2c.h>
>  #include <linux/of_device.h>
>  #include <linux/completion.h>
>  #include <linux/hardirq.h>
> @@ -790,6 +792,85 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter)
>  	up_read(&__i2c_board_lock);
>  }
>  
> +#ifdef CONFIG_OF_I2C

I think this becomes simply "#ifdef CONFIG_OF" since CONFIG_I2C is implied at this point.

> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index a6c652e..830397b 100644
> --- a/include/linux/i2c.h
> +++ b/include/linux/i2c.h
> @@ -468,6 +468,10 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap)
>  {
>  	return adap->nr;
>  }
> +
> +/* must call put_device() when done with returned i2c_client device */
> +extern struct i2c_client *of_find_i2c_device_by_node(struct device_node *node);
> +

This shouldn't be defined if !CONFIG_OF

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

* Re: [PATCH 2/3] i2c: move OF i2c related functions into i2c core
@ 2011-08-05 23:15       ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-05 23:15 UTC (permalink / raw)
  To: Grant Likely
  Cc: linux-kernel, linux-i2c, Rob Herring, Jean Delvare, Ben Dooks

Grant,

On 08/05/2011 05:56 PM, Grant Likely wrote:
> On Fri, Aug 05, 2011 at 04:24:27PM -0500, Rob Herring wrote:
>> From: Rob Herring <rob.herring@calxeda.com>
>>
>> This simplifies i2c drivers by removing calls to of_i2c_register_devices
>> and resolves a module circular dependency between i2c-core and of_i2c.
>>
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>> Cc: Grant Likely <grant.likely@secretlab.ca>
>> Cc: Jean Delvare <khali@linux-fr.org>
>> Cc: Ben Dooks <ben-linux@fluff.org>
>> Cc: linux-i2c@vger.kernel.org
>> ---
>>  arch/powerpc/platforms/44x/warp.c |    1 -
>>  drivers/i2c/i2c-core.c            |   85 +++++++++++++++++++++++++++++++-
>>  drivers/of/Makefile               |    1 -
>>  drivers/of/of_i2c.c               |   97 -------------------------------------
>>  include/linux/i2c.h               |    4 ++
>>  include/linux/of_i2c.h            |   30 -----------
>>  6 files changed, 87 insertions(+), 131 deletions(-)
>>  delete mode 100644 drivers/of/of_i2c.c
>>  delete mode 100644 include/linux/of_i2c.h
>>
>> diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
>> index 8f77139..9327ccf 100644
>> --- a/arch/powerpc/platforms/44x/warp.c
>> +++ b/arch/powerpc/platforms/44x/warp.c
>> @@ -16,7 +16,6 @@
>>  #include <linux/interrupt.h>
>>  #include <linux/delay.h>
>>  #include <linux/of_gpio.h>
>> -#include <linux/of_i2c.h>
>>  #include <linux/slab.h>
>>  
>>  #include <asm/machdep.h>
>> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
>> index 011e195..478c7f2 100644
>> --- a/drivers/i2c/i2c-core.c
>> +++ b/drivers/i2c/i2c-core.c
>> @@ -22,7 +22,10 @@
>>     SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> and
>>     Jean Delvare <khali@linux-fr.org>
>>     Mux support by Rodolfo Giometti <giometti@enneenne.com> and
>> -   Michael Lawnick <michael.lawnick.ext@nsn.com> */
>> +   Michael Lawnick <michael.lawnick.ext@nsn.com>
>> +   OF support by Jochen Friedrich <jochen@scram.de> and
>> +   Jon Smirl <jonsmirl@gmail.com>
>> +   */
>>  
>>  #include <linux/module.h>
>>  #include <linux/kernel.h>
>> @@ -32,7 +35,6 @@
>>  #include <linux/init.h>
>>  #include <linux/idr.h>
>>  #include <linux/mutex.h>
>> -#include <linux/of_i2c.h>
>>  #include <linux/of_device.h>
>>  #include <linux/completion.h>
>>  #include <linux/hardirq.h>
>> @@ -790,6 +792,85 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter)
>>  	up_read(&__i2c_board_lock);
>>  }
>>  
>> +#ifdef CONFIG_OF_I2C
> 
> I think this becomes simply "#ifdef CONFIG_OF" since CONFIG_I2C is implied at this point.

I was going to remove CONFIG_OF_I2C altogether, but it depends on !SPARC
so I thought it should be kept.

> 
>> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
>> index a6c652e..830397b 100644
>> --- a/include/linux/i2c.h
>> +++ b/include/linux/i2c.h
>> @@ -468,6 +468,10 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap)
>>  {
>>  	return adap->nr;
>>  }
>> +
>> +/* must call put_device() when done with returned i2c_client device */
>> +extern struct i2c_client *of_find_i2c_device_by_node(struct device_node *node);
>> +
> 
> This shouldn't be defined if !CONFIG_OF

There is no empty version today and externs don't need to be ifdef'ed in
that case.

Rob


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

* Re: [PATCH 2/3] i2c: move OF i2c related functions into i2c core
@ 2011-08-05 23:15       ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-05 23:15 UTC (permalink / raw)
  To: Grant Likely
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Jean Delvare,
	Ben Dooks

Grant,

On 08/05/2011 05:56 PM, Grant Likely wrote:
> On Fri, Aug 05, 2011 at 04:24:27PM -0500, Rob Herring wrote:
>> From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
>>
>> This simplifies i2c drivers by removing calls to of_i2c_register_devices
>> and resolves a module circular dependency between i2c-core and of_i2c.
>>
>> Signed-off-by: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
>> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
>> Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
>> Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
>> Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> ---
>>  arch/powerpc/platforms/44x/warp.c |    1 -
>>  drivers/i2c/i2c-core.c            |   85 +++++++++++++++++++++++++++++++-
>>  drivers/of/Makefile               |    1 -
>>  drivers/of/of_i2c.c               |   97 -------------------------------------
>>  include/linux/i2c.h               |    4 ++
>>  include/linux/of_i2c.h            |   30 -----------
>>  6 files changed, 87 insertions(+), 131 deletions(-)
>>  delete mode 100644 drivers/of/of_i2c.c
>>  delete mode 100644 include/linux/of_i2c.h
>>
>> diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
>> index 8f77139..9327ccf 100644
>> --- a/arch/powerpc/platforms/44x/warp.c
>> +++ b/arch/powerpc/platforms/44x/warp.c
>> @@ -16,7 +16,6 @@
>>  #include <linux/interrupt.h>
>>  #include <linux/delay.h>
>>  #include <linux/of_gpio.h>
>> -#include <linux/of_i2c.h>
>>  #include <linux/slab.h>
>>  
>>  #include <asm/machdep.h>
>> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
>> index 011e195..478c7f2 100644
>> --- a/drivers/i2c/i2c-core.c
>> +++ b/drivers/i2c/i2c-core.c
>> @@ -22,7 +22,10 @@
>>     SMBus 2.0 support by Mark Studebaker <mdsxyz123-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> and
>>     Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
>>     Mux support by Rodolfo Giometti <giometti-AVVDYK/kqiJWk0Htik3J/w@public.gmane.org> and
>> -   Michael Lawnick <michael.lawnick.ext-OYasijW0DpE@public.gmane.org> */
>> +   Michael Lawnick <michael.lawnick.ext-OYasijW0DpE@public.gmane.org>
>> +   OF support by Jochen Friedrich <jochen-NIgtFMG+Po8@public.gmane.org> and
>> +   Jon Smirl <jonsmirl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> +   */
>>  
>>  #include <linux/module.h>
>>  #include <linux/kernel.h>
>> @@ -32,7 +35,6 @@
>>  #include <linux/init.h>
>>  #include <linux/idr.h>
>>  #include <linux/mutex.h>
>> -#include <linux/of_i2c.h>
>>  #include <linux/of_device.h>
>>  #include <linux/completion.h>
>>  #include <linux/hardirq.h>
>> @@ -790,6 +792,85 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter)
>>  	up_read(&__i2c_board_lock);
>>  }
>>  
>> +#ifdef CONFIG_OF_I2C
> 
> I think this becomes simply "#ifdef CONFIG_OF" since CONFIG_I2C is implied at this point.

I was going to remove CONFIG_OF_I2C altogether, but it depends on !SPARC
so I thought it should be kept.

> 
>> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
>> index a6c652e..830397b 100644
>> --- a/include/linux/i2c.h
>> +++ b/include/linux/i2c.h
>> @@ -468,6 +468,10 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap)
>>  {
>>  	return adap->nr;
>>  }
>> +
>> +/* must call put_device() when done with returned i2c_client device */
>> +extern struct i2c_client *of_find_i2c_device_by_node(struct device_node *node);
>> +
> 
> This shouldn't be defined if !CONFIG_OF

There is no empty version today and externs don't need to be ifdef'ed in
that case.

Rob

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

* Re: [PATCH 1/3] i2c: move of_i2c_register_devices call into core
@ 2011-08-05 23:22       ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-05 23:22 UTC (permalink / raw)
  To: Grant Likely
  Cc: linux-kernel, linux-i2c, Jochen Friedrich, Jean Delvare,
	Ben Dooks, Sebastian Andrzej Siewior, Dirk Brandewie,
	Stephen Warren, linuxppc-dev

Grant,

On 08/05/2011 05:54 PM, Grant Likely wrote:
> On Fri, Aug 05, 2011 at 04:24:26PM -0500, Rob Herring wrote:
>> From: Rob Herring <rob.herring@calxeda.com>
>>
>> All callers of of_i2c_register_devices are immediately preceded by a call
>> to i2c_add_adapter or i2c_add_numbered_adapter. Add call to
>> of_i2c_register_devices and remove all other callers.
>>
>> This causes a module dependency loop that is resolved by the next commit.
> 
> Wrong way around.  Don't break bisectability.  I'll leave it up to Ben
> and Jean on weather or not they want to move this code.  I intend to
> do the same thing for spi/gpio, but I maintain those subsystems so I
> get to choose.  i2c is not up to me.
> 

Well, I know, but it's only broken for bisect in the case of both being
modules. So it's only run-time brokenness. That's better than the 3
months it was broken before. I couldn't come up with a better way. The
choices I thought of were:

-temporarily exporting and adding of_i2c_register_devices to i2c.h and
then removing it. I'm not a fan of adding that churn.
-just combining it all into 1 patch.
-reverse the order and leave i2c device registration broken for 1
commit. Thinking some more about it, perhaps that is a bit better than
broken module loading. Guess it depends if you are doing modules or
built-in.

Rob

> g.
> 
>>
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>> Cc: Grant Likely <grant.likely@secretlab.ca>
>> Cc: Jochen Friedrich <jochen@scram.de>
>> Cc: Jean Delvare <khali@linux-fr.org>
>> Cc: Ben Dooks <ben-linux@fluff.org>
>> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>> Cc: Dirk Brandewie <dirk.brandewie@gmail.com>
>> Cc: Stephen Warren <swarren@nvidia.com>
>> Cc: linuxppc-dev@lists.ozlabs.org
>> Cc: linux-i2c@vger.kernel.org
>> ---
>>  drivers/i2c/busses/i2c-cpm.c     |    6 ------
>>  drivers/i2c/busses/i2c-ibm_iic.c |    4 ----
>>  drivers/i2c/busses/i2c-mpc.c     |    2 --
>>  drivers/i2c/busses/i2c-pxa.c     |    2 --
>>  drivers/i2c/busses/i2c-tegra.c   |    3 ---
>>  drivers/i2c/i2c-core.c           |    4 ++++
>>  6 files changed, 4 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
>> index b1d9cd2..7cbc82a 100644
>> --- a/drivers/i2c/busses/i2c-cpm.c
>> +++ b/drivers/i2c/busses/i2c-cpm.c
>> @@ -42,7 +42,6 @@
>>  #include <linux/dma-mapping.h>
>>  #include <linux/of_device.h>
>>  #include <linux/of_platform.h>
>> -#include <linux/of_i2c.h>
>>  #include <sysdev/fsl_soc.h>
>>  #include <asm/cpm.h>
>>  
>> @@ -673,11 +672,6 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev)
>>  	dev_dbg(&ofdev->dev, "hw routines for %s registered.\n",
>>  		cpm->adap.name);
>>  
>> -	/*
>> -	 * register OF I2C devices
>> -	 */
>> -	of_i2c_register_devices(&cpm->adap);
>> -
>>  	return 0;
>>  out_shut:
>>  	cpm_i2c_shutdown(cpm);
>> diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
>> index 3c110fb..5ba15ba 100644
>> --- a/drivers/i2c/busses/i2c-ibm_iic.c
>> +++ b/drivers/i2c/busses/i2c-ibm_iic.c
>> @@ -42,7 +42,6 @@
>>  #include <linux/io.h>
>>  #include <linux/i2c.h>
>>  #include <linux/of_platform.h>
>> -#include <linux/of_i2c.h>
>>  
>>  #include "i2c-ibm_iic.h"
>>  
>> @@ -759,9 +758,6 @@ static int __devinit iic_probe(struct platform_device *ofdev)
>>  	dev_info(&ofdev->dev, "using %s mode\n",
>>  		 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
>>  
>> -	/* Now register all the child nodes */
>> -	of_i2c_register_devices(adap);
>> -
>>  	return 0;
>>  
>>  error_cleanup:
>> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
>> index 107397a..a433f59 100644
>> --- a/drivers/i2c/busses/i2c-mpc.c
>> +++ b/drivers/i2c/busses/i2c-mpc.c
>> @@ -18,7 +18,6 @@
>>  #include <linux/sched.h>
>>  #include <linux/init.h>
>>  #include <linux/of_platform.h>
>> -#include <linux/of_i2c.h>
>>  #include <linux/slab.h>
>>  
>>  #include <linux/io.h>
>> @@ -637,7 +636,6 @@ static int __devinit fsl_i2c_probe(struct platform_device *op)
>>  		dev_err(i2c->dev, "failed to add adapter\n");
>>  		goto fail_add;
>>  	}
>> -	of_i2c_register_devices(&i2c->adap);
>>  
>>  	return result;
>>  
>> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
>> index d603646..c1c2885 100644
>> --- a/drivers/i2c/busses/i2c-pxa.c
>> +++ b/drivers/i2c/busses/i2c-pxa.c
>> @@ -29,7 +29,6 @@
>>  #include <linux/errno.h>
>>  #include <linux/interrupt.h>
>>  #include <linux/i2c-pxa.h>
>> -#include <linux/of_i2c.h>
>>  #include <linux/platform_device.h>
>>  #include <linux/err.h>
>>  #include <linux/clk.h>
>> @@ -1147,7 +1146,6 @@ static int i2c_pxa_probe(struct platform_device *dev)
>>  		printk(KERN_INFO "I2C: Failed to add bus\n");
>>  		goto eadapt;
>>  	}
>> -	of_i2c_register_devices(&i2c->adap);
>>  
>>  	platform_set_drvdata(dev, i2c);
>>  
>> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
>> index 2440b74..9ec0a58 100644
>> --- a/drivers/i2c/busses/i2c-tegra.c
>> +++ b/drivers/i2c/busses/i2c-tegra.c
>> @@ -26,7 +26,6 @@
>>  #include <linux/delay.h>
>>  #include <linux/slab.h>
>>  #include <linux/i2c-tegra.h>
>> -#include <linux/of_i2c.h>
>>  
>>  #include <asm/unaligned.h>
>>  
>> @@ -653,8 +652,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
>>  		goto err_free_irq;
>>  	}
>>  
>> -	of_i2c_register_devices(&i2c_dev->adapter);
>> -
>>  	return 0;
>>  err_free_irq:
>>  	free_irq(i2c_dev->irq, i2c_dev);
>> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
>> index 131079a..011e195 100644
>> --- a/drivers/i2c/i2c-core.c
>> +++ b/drivers/i2c/i2c-core.c
>> @@ -32,6 +32,7 @@
>>  #include <linux/init.h>
>>  #include <linux/idr.h>
>>  #include <linux/mutex.h>
>> +#include <linux/of_i2c.h>
>>  #include <linux/of_device.h>
>>  #include <linux/completion.h>
>>  #include <linux/hardirq.h>
>> @@ -863,6 +864,9 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
>>  	if (adap->nr < __i2c_first_dynamic_bus_num)
>>  		i2c_scan_static_board_info(adap);
>>  
>> +	/* Register devices from the device tree */
>> +	of_i2c_register_devices(adap);
>> +
>>  	/* Notify drivers */
>>  	mutex_lock(&core_lock);
>>  	bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);
>> -- 
>> 1.7.4.1
>>


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

* Re: [PATCH 1/3] i2c: move of_i2c_register_devices call into core
@ 2011-08-05 23:22       ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-05 23:22 UTC (permalink / raw)
  To: Grant Likely
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Jochen Friedrich, Jean Delvare,
	Ben Dooks, Sebastian Andrzej Siewior, Dirk Brandewie,
	Stephen Warren, linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ

Grant,

On 08/05/2011 05:54 PM, Grant Likely wrote:
> On Fri, Aug 05, 2011 at 04:24:26PM -0500, Rob Herring wrote:
>> From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
>>
>> All callers of of_i2c_register_devices are immediately preceded by a call
>> to i2c_add_adapter or i2c_add_numbered_adapter. Add call to
>> of_i2c_register_devices and remove all other callers.
>>
>> This causes a module dependency loop that is resolved by the next commit.
> 
> Wrong way around.  Don't break bisectability.  I'll leave it up to Ben
> and Jean on weather or not they want to move this code.  I intend to
> do the same thing for spi/gpio, but I maintain those subsystems so I
> get to choose.  i2c is not up to me.
> 

Well, I know, but it's only broken for bisect in the case of both being
modules. So it's only run-time brokenness. That's better than the 3
months it was broken before. I couldn't come up with a better way. The
choices I thought of were:

-temporarily exporting and adding of_i2c_register_devices to i2c.h and
then removing it. I'm not a fan of adding that churn.
-just combining it all into 1 patch.
-reverse the order and leave i2c device registration broken for 1
commit. Thinking some more about it, perhaps that is a bit better than
broken module loading. Guess it depends if you are doing modules or
built-in.

Rob

> g.
> 
>>
>> Signed-off-by: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
>> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
>> Cc: Jochen Friedrich <jochen-NIgtFMG+Po8@public.gmane.org>
>> Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
>> Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
>> Cc: Sebastian Andrzej Siewior <bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
>> Cc: Dirk Brandewie <dirk.brandewie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>> Cc: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
>> Cc: linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
>> Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> ---
>>  drivers/i2c/busses/i2c-cpm.c     |    6 ------
>>  drivers/i2c/busses/i2c-ibm_iic.c |    4 ----
>>  drivers/i2c/busses/i2c-mpc.c     |    2 --
>>  drivers/i2c/busses/i2c-pxa.c     |    2 --
>>  drivers/i2c/busses/i2c-tegra.c   |    3 ---
>>  drivers/i2c/i2c-core.c           |    4 ++++
>>  6 files changed, 4 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
>> index b1d9cd2..7cbc82a 100644
>> --- a/drivers/i2c/busses/i2c-cpm.c
>> +++ b/drivers/i2c/busses/i2c-cpm.c
>> @@ -42,7 +42,6 @@
>>  #include <linux/dma-mapping.h>
>>  #include <linux/of_device.h>
>>  #include <linux/of_platform.h>
>> -#include <linux/of_i2c.h>
>>  #include <sysdev/fsl_soc.h>
>>  #include <asm/cpm.h>
>>  
>> @@ -673,11 +672,6 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev)
>>  	dev_dbg(&ofdev->dev, "hw routines for %s registered.\n",
>>  		cpm->adap.name);
>>  
>> -	/*
>> -	 * register OF I2C devices
>> -	 */
>> -	of_i2c_register_devices(&cpm->adap);
>> -
>>  	return 0;
>>  out_shut:
>>  	cpm_i2c_shutdown(cpm);
>> diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
>> index 3c110fb..5ba15ba 100644
>> --- a/drivers/i2c/busses/i2c-ibm_iic.c
>> +++ b/drivers/i2c/busses/i2c-ibm_iic.c
>> @@ -42,7 +42,6 @@
>>  #include <linux/io.h>
>>  #include <linux/i2c.h>
>>  #include <linux/of_platform.h>
>> -#include <linux/of_i2c.h>
>>  
>>  #include "i2c-ibm_iic.h"
>>  
>> @@ -759,9 +758,6 @@ static int __devinit iic_probe(struct platform_device *ofdev)
>>  	dev_info(&ofdev->dev, "using %s mode\n",
>>  		 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
>>  
>> -	/* Now register all the child nodes */
>> -	of_i2c_register_devices(adap);
>> -
>>  	return 0;
>>  
>>  error_cleanup:
>> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
>> index 107397a..a433f59 100644
>> --- a/drivers/i2c/busses/i2c-mpc.c
>> +++ b/drivers/i2c/busses/i2c-mpc.c
>> @@ -18,7 +18,6 @@
>>  #include <linux/sched.h>
>>  #include <linux/init.h>
>>  #include <linux/of_platform.h>
>> -#include <linux/of_i2c.h>
>>  #include <linux/slab.h>
>>  
>>  #include <linux/io.h>
>> @@ -637,7 +636,6 @@ static int __devinit fsl_i2c_probe(struct platform_device *op)
>>  		dev_err(i2c->dev, "failed to add adapter\n");
>>  		goto fail_add;
>>  	}
>> -	of_i2c_register_devices(&i2c->adap);
>>  
>>  	return result;
>>  
>> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
>> index d603646..c1c2885 100644
>> --- a/drivers/i2c/busses/i2c-pxa.c
>> +++ b/drivers/i2c/busses/i2c-pxa.c
>> @@ -29,7 +29,6 @@
>>  #include <linux/errno.h>
>>  #include <linux/interrupt.h>
>>  #include <linux/i2c-pxa.h>
>> -#include <linux/of_i2c.h>
>>  #include <linux/platform_device.h>
>>  #include <linux/err.h>
>>  #include <linux/clk.h>
>> @@ -1147,7 +1146,6 @@ static int i2c_pxa_probe(struct platform_device *dev)
>>  		printk(KERN_INFO "I2C: Failed to add bus\n");
>>  		goto eadapt;
>>  	}
>> -	of_i2c_register_devices(&i2c->adap);
>>  
>>  	platform_set_drvdata(dev, i2c);
>>  
>> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
>> index 2440b74..9ec0a58 100644
>> --- a/drivers/i2c/busses/i2c-tegra.c
>> +++ b/drivers/i2c/busses/i2c-tegra.c
>> @@ -26,7 +26,6 @@
>>  #include <linux/delay.h>
>>  #include <linux/slab.h>
>>  #include <linux/i2c-tegra.h>
>> -#include <linux/of_i2c.h>
>>  
>>  #include <asm/unaligned.h>
>>  
>> @@ -653,8 +652,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
>>  		goto err_free_irq;
>>  	}
>>  
>> -	of_i2c_register_devices(&i2c_dev->adapter);
>> -
>>  	return 0;
>>  err_free_irq:
>>  	free_irq(i2c_dev->irq, i2c_dev);
>> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
>> index 131079a..011e195 100644
>> --- a/drivers/i2c/i2c-core.c
>> +++ b/drivers/i2c/i2c-core.c
>> @@ -32,6 +32,7 @@
>>  #include <linux/init.h>
>>  #include <linux/idr.h>
>>  #include <linux/mutex.h>
>> +#include <linux/of_i2c.h>
>>  #include <linux/of_device.h>
>>  #include <linux/completion.h>
>>  #include <linux/hardirq.h>
>> @@ -863,6 +864,9 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
>>  	if (adap->nr < __i2c_first_dynamic_bus_num)
>>  		i2c_scan_static_board_info(adap);
>>  
>> +	/* Register devices from the device tree */
>> +	of_i2c_register_devices(adap);
>> +
>>  	/* Notify drivers */
>>  	mutex_lock(&core_lock);
>>  	bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);
>> -- 
>> 1.7.4.1
>>

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

* Re: [PATCH 1/3] i2c: move of_i2c_register_devices call into core
@ 2011-08-05 23:22       ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-05 23:22 UTC (permalink / raw)
  To: Grant Likely
  Cc: Stephen Warren, Sebastian Andrzej Siewior, linux-kernel,
	Dirk Brandewie, linux-i2c, Ben Dooks, Jean Delvare, linuxppc-dev

Grant,

On 08/05/2011 05:54 PM, Grant Likely wrote:
> On Fri, Aug 05, 2011 at 04:24:26PM -0500, Rob Herring wrote:
>> From: Rob Herring <rob.herring@calxeda.com>
>>
>> All callers of of_i2c_register_devices are immediately preceded by a call
>> to i2c_add_adapter or i2c_add_numbered_adapter. Add call to
>> of_i2c_register_devices and remove all other callers.
>>
>> This causes a module dependency loop that is resolved by the next commit.
> 
> Wrong way around.  Don't break bisectability.  I'll leave it up to Ben
> and Jean on weather or not they want to move this code.  I intend to
> do the same thing for spi/gpio, but I maintain those subsystems so I
> get to choose.  i2c is not up to me.
> 

Well, I know, but it's only broken for bisect in the case of both being
modules. So it's only run-time brokenness. That's better than the 3
months it was broken before. I couldn't come up with a better way. The
choices I thought of were:

-temporarily exporting and adding of_i2c_register_devices to i2c.h and
then removing it. I'm not a fan of adding that churn.
-just combining it all into 1 patch.
-reverse the order and leave i2c device registration broken for 1
commit. Thinking some more about it, perhaps that is a bit better than
broken module loading. Guess it depends if you are doing modules or
built-in.

Rob

> g.
> 
>>
>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>> Cc: Grant Likely <grant.likely@secretlab.ca>
>> Cc: Jochen Friedrich <jochen@scram.de>
>> Cc: Jean Delvare <khali@linux-fr.org>
>> Cc: Ben Dooks <ben-linux@fluff.org>
>> Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>> Cc: Dirk Brandewie <dirk.brandewie@gmail.com>
>> Cc: Stephen Warren <swarren@nvidia.com>
>> Cc: linuxppc-dev@lists.ozlabs.org
>> Cc: linux-i2c@vger.kernel.org
>> ---
>>  drivers/i2c/busses/i2c-cpm.c     |    6 ------
>>  drivers/i2c/busses/i2c-ibm_iic.c |    4 ----
>>  drivers/i2c/busses/i2c-mpc.c     |    2 --
>>  drivers/i2c/busses/i2c-pxa.c     |    2 --
>>  drivers/i2c/busses/i2c-tegra.c   |    3 ---
>>  drivers/i2c/i2c-core.c           |    4 ++++
>>  6 files changed, 4 insertions(+), 17 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
>> index b1d9cd2..7cbc82a 100644
>> --- a/drivers/i2c/busses/i2c-cpm.c
>> +++ b/drivers/i2c/busses/i2c-cpm.c
>> @@ -42,7 +42,6 @@
>>  #include <linux/dma-mapping.h>
>>  #include <linux/of_device.h>
>>  #include <linux/of_platform.h>
>> -#include <linux/of_i2c.h>
>>  #include <sysdev/fsl_soc.h>
>>  #include <asm/cpm.h>
>>  
>> @@ -673,11 +672,6 @@ static int __devinit cpm_i2c_probe(struct platform_device *ofdev)
>>  	dev_dbg(&ofdev->dev, "hw routines for %s registered.\n",
>>  		cpm->adap.name);
>>  
>> -	/*
>> -	 * register OF I2C devices
>> -	 */
>> -	of_i2c_register_devices(&cpm->adap);
>> -
>>  	return 0;
>>  out_shut:
>>  	cpm_i2c_shutdown(cpm);
>> diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
>> index 3c110fb..5ba15ba 100644
>> --- a/drivers/i2c/busses/i2c-ibm_iic.c
>> +++ b/drivers/i2c/busses/i2c-ibm_iic.c
>> @@ -42,7 +42,6 @@
>>  #include <linux/io.h>
>>  #include <linux/i2c.h>
>>  #include <linux/of_platform.h>
>> -#include <linux/of_i2c.h>
>>  
>>  #include "i2c-ibm_iic.h"
>>  
>> @@ -759,9 +758,6 @@ static int __devinit iic_probe(struct platform_device *ofdev)
>>  	dev_info(&ofdev->dev, "using %s mode\n",
>>  		 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
>>  
>> -	/* Now register all the child nodes */
>> -	of_i2c_register_devices(adap);
>> -
>>  	return 0;
>>  
>>  error_cleanup:
>> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
>> index 107397a..a433f59 100644
>> --- a/drivers/i2c/busses/i2c-mpc.c
>> +++ b/drivers/i2c/busses/i2c-mpc.c
>> @@ -18,7 +18,6 @@
>>  #include <linux/sched.h>
>>  #include <linux/init.h>
>>  #include <linux/of_platform.h>
>> -#include <linux/of_i2c.h>
>>  #include <linux/slab.h>
>>  
>>  #include <linux/io.h>
>> @@ -637,7 +636,6 @@ static int __devinit fsl_i2c_probe(struct platform_device *op)
>>  		dev_err(i2c->dev, "failed to add adapter\n");
>>  		goto fail_add;
>>  	}
>> -	of_i2c_register_devices(&i2c->adap);
>>  
>>  	return result;
>>  
>> diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
>> index d603646..c1c2885 100644
>> --- a/drivers/i2c/busses/i2c-pxa.c
>> +++ b/drivers/i2c/busses/i2c-pxa.c
>> @@ -29,7 +29,6 @@
>>  #include <linux/errno.h>
>>  #include <linux/interrupt.h>
>>  #include <linux/i2c-pxa.h>
>> -#include <linux/of_i2c.h>
>>  #include <linux/platform_device.h>
>>  #include <linux/err.h>
>>  #include <linux/clk.h>
>> @@ -1147,7 +1146,6 @@ static int i2c_pxa_probe(struct platform_device *dev)
>>  		printk(KERN_INFO "I2C: Failed to add bus\n");
>>  		goto eadapt;
>>  	}
>> -	of_i2c_register_devices(&i2c->adap);
>>  
>>  	platform_set_drvdata(dev, i2c);
>>  
>> diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
>> index 2440b74..9ec0a58 100644
>> --- a/drivers/i2c/busses/i2c-tegra.c
>> +++ b/drivers/i2c/busses/i2c-tegra.c
>> @@ -26,7 +26,6 @@
>>  #include <linux/delay.h>
>>  #include <linux/slab.h>
>>  #include <linux/i2c-tegra.h>
>> -#include <linux/of_i2c.h>
>>  
>>  #include <asm/unaligned.h>
>>  
>> @@ -653,8 +652,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
>>  		goto err_free_irq;
>>  	}
>>  
>> -	of_i2c_register_devices(&i2c_dev->adapter);
>> -
>>  	return 0;
>>  err_free_irq:
>>  	free_irq(i2c_dev->irq, i2c_dev);
>> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
>> index 131079a..011e195 100644
>> --- a/drivers/i2c/i2c-core.c
>> +++ b/drivers/i2c/i2c-core.c
>> @@ -32,6 +32,7 @@
>>  #include <linux/init.h>
>>  #include <linux/idr.h>
>>  #include <linux/mutex.h>
>> +#include <linux/of_i2c.h>
>>  #include <linux/of_device.h>
>>  #include <linux/completion.h>
>>  #include <linux/hardirq.h>
>> @@ -863,6 +864,9 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
>>  	if (adap->nr < __i2c_first_dynamic_bus_num)
>>  		i2c_scan_static_board_info(adap);
>>  
>> +	/* Register devices from the device tree */
>> +	of_i2c_register_devices(adap);
>> +
>>  	/* Notify drivers */
>>  	mutex_lock(&core_lock);
>>  	bus_for_each_drv(&i2c_bus_type, NULL, adap, __process_new_adapter);
>> -- 
>> 1.7.4.1
>>

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

* Re: [PATCH 2/3] i2c: move OF i2c related functions into i2c core
@ 2011-08-06  8:50         ` Grant Likely
  0 siblings, 0 replies; 24+ messages in thread
From: Grant Likely @ 2011-08-06  8:50 UTC (permalink / raw)
  To: Rob Herring; +Cc: linux-kernel, linux-i2c, Rob Herring, Jean Delvare, Ben Dooks

On Sat, Aug 6, 2011 at 12:15 AM, Rob Herring <robherring2@gmail.com> wrote:
> Grant,
>
> On 08/05/2011 05:56 PM, Grant Likely wrote:
>> On Fri, Aug 05, 2011 at 04:24:27PM -0500, Rob Herring wrote:
>>> From: Rob Herring <rob.herring@calxeda.com>
>>>
>>> This simplifies i2c drivers by removing calls to of_i2c_register_devices
>>> and resolves a module circular dependency between i2c-core and of_i2c.
>>>
>>> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
>>> Cc: Grant Likely <grant.likely@secretlab.ca>
>>> Cc: Jean Delvare <khali@linux-fr.org>
>>> Cc: Ben Dooks <ben-linux@fluff.org>
>>> Cc: linux-i2c@vger.kernel.org
>>> ---
>>>  arch/powerpc/platforms/44x/warp.c |    1 -
>>>  drivers/i2c/i2c-core.c            |   85 +++++++++++++++++++++++++++++++-
>>>  drivers/of/Makefile               |    1 -
>>>  drivers/of/of_i2c.c               |   97 -------------------------------------
>>>  include/linux/i2c.h               |    4 ++
>>>  include/linux/of_i2c.h            |   30 -----------
>>>  6 files changed, 87 insertions(+), 131 deletions(-)
>>>  delete mode 100644 drivers/of/of_i2c.c
>>>  delete mode 100644 include/linux/of_i2c.h
>>>
>>> diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
>>> index 8f77139..9327ccf 100644
>>> --- a/arch/powerpc/platforms/44x/warp.c
>>> +++ b/arch/powerpc/platforms/44x/warp.c
>>> @@ -16,7 +16,6 @@
>>>  #include <linux/interrupt.h>
>>>  #include <linux/delay.h>
>>>  #include <linux/of_gpio.h>
>>> -#include <linux/of_i2c.h>
>>>  #include <linux/slab.h>
>>>
>>>  #include <asm/machdep.h>
>>> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
>>> index 011e195..478c7f2 100644
>>> --- a/drivers/i2c/i2c-core.c
>>> +++ b/drivers/i2c/i2c-core.c
>>> @@ -22,7 +22,10 @@
>>>     SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> and
>>>     Jean Delvare <khali@linux-fr.org>
>>>     Mux support by Rodolfo Giometti <giometti@enneenne.com> and
>>> -   Michael Lawnick <michael.lawnick.ext@nsn.com> */
>>> +   Michael Lawnick <michael.lawnick.ext@nsn.com>
>>> +   OF support by Jochen Friedrich <jochen@scram.de> and
>>> +   Jon Smirl <jonsmirl@gmail.com>
>>> +   */
>>>
>>>  #include <linux/module.h>
>>>  #include <linux/kernel.h>
>>> @@ -32,7 +35,6 @@
>>>  #include <linux/init.h>
>>>  #include <linux/idr.h>
>>>  #include <linux/mutex.h>
>>> -#include <linux/of_i2c.h>
>>>  #include <linux/of_device.h>
>>>  #include <linux/completion.h>
>>>  #include <linux/hardirq.h>
>>> @@ -790,6 +792,85 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter)
>>>      up_read(&__i2c_board_lock);
>>>  }
>>>
>>> +#ifdef CONFIG_OF_I2C
>>
>> I think this becomes simply "#ifdef CONFIG_OF" since CONFIG_I2C is implied at this point.
>
> I was going to remove CONFIG_OF_I2C altogether, but it depends on !SPARC
> so I thought it should be kept.

Good point.  I keep forgetting that SPARC has different behaviour.

g.

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

* Re: [PATCH 2/3] i2c: move OF i2c related functions into i2c core
@ 2011-08-06  8:50         ` Grant Likely
  0 siblings, 0 replies; 24+ messages in thread
From: Grant Likely @ 2011-08-06  8:50 UTC (permalink / raw)
  To: Rob Herring
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Rob Herring, Jean Delvare,
	Ben Dooks

On Sat, Aug 6, 2011 at 12:15 AM, Rob Herring <robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Grant,
>
> On 08/05/2011 05:56 PM, Grant Likely wrote:
>> On Fri, Aug 05, 2011 at 04:24:27PM -0500, Rob Herring wrote:
>>> From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
>>>
>>> This simplifies i2c drivers by removing calls to of_i2c_register_devices
>>> and resolves a module circular dependency between i2c-core and of_i2c.
>>>
>>> Signed-off-by: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
>>> Cc: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
>>> Cc: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
>>> Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
>>> Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>>> ---
>>>  arch/powerpc/platforms/44x/warp.c |    1 -
>>>  drivers/i2c/i2c-core.c            |   85 +++++++++++++++++++++++++++++++-
>>>  drivers/of/Makefile               |    1 -
>>>  drivers/of/of_i2c.c               |   97 -------------------------------------
>>>  include/linux/i2c.h               |    4 ++
>>>  include/linux/of_i2c.h            |   30 -----------
>>>  6 files changed, 87 insertions(+), 131 deletions(-)
>>>  delete mode 100644 drivers/of/of_i2c.c
>>>  delete mode 100644 include/linux/of_i2c.h
>>>
>>> diff --git a/arch/powerpc/platforms/44x/warp.c b/arch/powerpc/platforms/44x/warp.c
>>> index 8f77139..9327ccf 100644
>>> --- a/arch/powerpc/platforms/44x/warp.c
>>> +++ b/arch/powerpc/platforms/44x/warp.c
>>> @@ -16,7 +16,6 @@
>>>  #include <linux/interrupt.h>
>>>  #include <linux/delay.h>
>>>  #include <linux/of_gpio.h>
>>> -#include <linux/of_i2c.h>
>>>  #include <linux/slab.h>
>>>
>>>  #include <asm/machdep.h>
>>> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
>>> index 011e195..478c7f2 100644
>>> --- a/drivers/i2c/i2c-core.c
>>> +++ b/drivers/i2c/i2c-core.c
>>> @@ -22,7 +22,10 @@
>>>     SMBus 2.0 support by Mark Studebaker <mdsxyz123-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> and
>>>     Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
>>>     Mux support by Rodolfo Giometti <giometti-AVVDYK/kqiJWk0Htik3J/w@public.gmane.org> and
>>> -   Michael Lawnick <michael.lawnick.ext-OYasijW0DpE@public.gmane.org> */
>>> +   Michael Lawnick <michael.lawnick.ext-OYasijW0DpE@public.gmane.org>
>>> +   OF support by Jochen Friedrich <jochen-NIgtFMG+Po8@public.gmane.org> and
>>> +   Jon Smirl <jonsmirl-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>>> +   */
>>>
>>>  #include <linux/module.h>
>>>  #include <linux/kernel.h>
>>> @@ -32,7 +35,6 @@
>>>  #include <linux/init.h>
>>>  #include <linux/idr.h>
>>>  #include <linux/mutex.h>
>>> -#include <linux/of_i2c.h>
>>>  #include <linux/of_device.h>
>>>  #include <linux/completion.h>
>>>  #include <linux/hardirq.h>
>>> @@ -790,6 +792,85 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter)
>>>      up_read(&__i2c_board_lock);
>>>  }
>>>
>>> +#ifdef CONFIG_OF_I2C
>>
>> I think this becomes simply "#ifdef CONFIG_OF" since CONFIG_I2C is implied at this point.
>
> I was going to remove CONFIG_OF_I2C altogether, but it depends on !SPARC
> so I thought it should be kept.

Good point.  I keep forgetting that SPARC has different behaviour.

g.

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

* Re: [PATCH 3/3] i2c-designware: add OF binding support
@ 2011-08-24  3:31     ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-24  3:31 UTC (permalink / raw)
  To: Ben Dooks; +Cc: Grant Likely, linux-kernel, linux-i2c, devicetree-discuss

Ben,

On 08/05/2011 04:24 PM, Rob Herring wrote:
> From: Rob Herring <rob.herring@calxeda.com>
> 
> Add of_match_table and DT style i2c registration to designware i2c
> driver.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> Acked-by: Grant Likely <grant.likely@secretlab.ca>
> Cc: devicetree-discuss@lists.ozlabs.org
> Cc: Ben Dooks <ben-linux@fluff.org>
> Cc: linux-i2c@vger.kernel.org
> ---

Any comments on this? If not, will you apply to your tree?

Rob

>  Documentation/devicetree/bindings/i2c/dw-i2c.txt |   23 ++++++++++++++++++++++
>  drivers/i2c/busses/i2c-designware.c              |    8 +++++++
>  2 files changed, 31 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/i2c/dw-i2c.txt
> 
> diff --git a/Documentation/devicetree/bindings/i2c/dw-i2c.txt b/Documentation/devicetree/bindings/i2c/dw-i2c.txt
> new file mode 100644
> index 0000000..cbcb404
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/i2c/dw-i2c.txt
> @@ -0,0 +1,23 @@
> +* Synopsys DesignWare I2C
> +
> +Required properties :
> +
> + - compatible : should be "snps,designware-i2c"
> + - reg : Offset and length of the register set for the device
> + - interrupts : <IRQ> where IRQ is the interrupt number.
> +
> +Recommended properties :
> +
> + - clock-frequency : desired I2C bus clock frequency in Hz.
> +
> +Example :
> +
> +	i2c@f0000 {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +		compatible = "snps,designware-i2c";
> +		reg = <0xf0000 0x1000>;
> +		interrupts = <11>;
> +		clock-frequency = <400000>;
> +	};
> +
> diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
> index b7a51c4..0223b98 100644
> --- a/drivers/i2c/busses/i2c-designware.c
> +++ b/drivers/i2c/busses/i2c-designware.c
> @@ -769,6 +769,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
>  			sizeof(adap->name));
>  	adap->algo = &i2c_dw_algo;
>  	adap->dev.parent = &pdev->dev;
> +	adap->dev.of_node = pdev->dev.of_node;
>  
>  	adap->nr = pdev->id;
>  	r = i2c_add_numbered_adapter(adap);
> @@ -819,6 +820,12 @@ static int __devexit dw_i2c_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static const struct of_device_id dw_i2c_of_match[] = {
> +	{ .compatible = "snps,designware-i2c", },
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
> +
>  /* work with hotplug and coldplug */
>  MODULE_ALIAS("platform:i2c_designware");
>  
> @@ -827,6 +834,7 @@ static struct platform_driver dw_i2c_driver = {
>  	.driver		= {
>  		.name	= "i2c_designware",
>  		.owner	= THIS_MODULE,
> +		.of_match_table = dw_i2c_of_match,
>  	},
>  };
>  


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

* Re: [PATCH 3/3] i2c-designware: add OF binding support
@ 2011-08-24  3:31     ` Rob Herring
  0 siblings, 0 replies; 24+ messages in thread
From: Rob Herring @ 2011-08-24  3:31 UTC (permalink / raw)
  To: Ben Dooks
  Cc: Grant Likely, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ

Ben,

On 08/05/2011 04:24 PM, Rob Herring wrote:
> From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
> 
> Add of_match_table and DT style i2c registration to designware i2c
> driver.
> 
> Signed-off-by: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
> Acked-by: Grant Likely <grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
> Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> Cc: Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
> Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> ---

Any comments on this? If not, will you apply to your tree?

Rob

>  Documentation/devicetree/bindings/i2c/dw-i2c.txt |   23 ++++++++++++++++++++++
>  drivers/i2c/busses/i2c-designware.c              |    8 +++++++
>  2 files changed, 31 insertions(+), 0 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/i2c/dw-i2c.txt
> 
> diff --git a/Documentation/devicetree/bindings/i2c/dw-i2c.txt b/Documentation/devicetree/bindings/i2c/dw-i2c.txt
> new file mode 100644
> index 0000000..cbcb404
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/i2c/dw-i2c.txt
> @@ -0,0 +1,23 @@
> +* Synopsys DesignWare I2C
> +
> +Required properties :
> +
> + - compatible : should be "snps,designware-i2c"
> + - reg : Offset and length of the register set for the device
> + - interrupts : <IRQ> where IRQ is the interrupt number.
> +
> +Recommended properties :
> +
> + - clock-frequency : desired I2C bus clock frequency in Hz.
> +
> +Example :
> +
> +	i2c@f0000 {
> +		#address-cells = <1>;
> +		#size-cells = <0>;
> +		compatible = "snps,designware-i2c";
> +		reg = <0xf0000 0x1000>;
> +		interrupts = <11>;
> +		clock-frequency = <400000>;
> +	};
> +
> diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c
> index b7a51c4..0223b98 100644
> --- a/drivers/i2c/busses/i2c-designware.c
> +++ b/drivers/i2c/busses/i2c-designware.c
> @@ -769,6 +769,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
>  			sizeof(adap->name));
>  	adap->algo = &i2c_dw_algo;
>  	adap->dev.parent = &pdev->dev;
> +	adap->dev.of_node = pdev->dev.of_node;
>  
>  	adap->nr = pdev->id;
>  	r = i2c_add_numbered_adapter(adap);
> @@ -819,6 +820,12 @@ static int __devexit dw_i2c_remove(struct platform_device *pdev)
>  	return 0;
>  }
>  
> +static const struct of_device_id dw_i2c_of_match[] = {
> +	{ .compatible = "snps,designware-i2c", },
> +	{},
> +};
> +MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
> +
>  /* work with hotplug and coldplug */
>  MODULE_ALIAS("platform:i2c_designware");
>  
> @@ -827,6 +834,7 @@ static struct platform_driver dw_i2c_driver = {
>  	.driver		= {
>  		.name	= "i2c_designware",
>  		.owner	= THIS_MODULE,
> +		.of_match_table = dw_i2c_of_match,
>  	},
>  };
>  

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

* Re: [PATCH 1/3] i2c: move of_i2c_register_devices call into core
@ 2011-09-02  9:23         ` Jean Delvare
  0 siblings, 0 replies; 24+ messages in thread
From: Jean Delvare @ 2011-09-02  9:23 UTC (permalink / raw)
  To: Rob Herring
  Cc: Grant Likely, linux-kernel, linux-i2c, Jochen Friedrich,
	Ben Dooks, Sebastian Andrzej Siewior, Dirk Brandewie,
	Stephen Warren, linuxppc-dev

Hi Rob, Grant,

On Fri, 05 Aug 2011 18:22:36 -0500, Rob Herring wrote:
> Grant,
> 
> On 08/05/2011 05:54 PM, Grant Likely wrote:
> > On Fri, Aug 05, 2011 at 04:24:26PM -0500, Rob Herring wrote:
> >> From: Rob Herring <rob.herring@calxeda.com>
> >>
> >> All callers of of_i2c_register_devices are immediately preceded by a call
> >> to i2c_add_adapter or i2c_add_numbered_adapter. Add call to
> >> of_i2c_register_devices and remove all other callers.
> >>
> >> This causes a module dependency loop that is resolved by the next commit.
> > 
> > Wrong way around.  Don't break bisectability.  I'll leave it up to Ben
> > and Jean on weather or not they want to move this code.  I intend to
> > do the same thing for spi/gpio, but I maintain those subsystems so I
> > get to choose.  i2c is not up to me.
> 
> Well, I know, but it's only broken for bisect in the case of both being
> modules. So it's only run-time brokenness. That's better than the 3
> months it was broken before. I couldn't come up with a better way. The
> choices I thought of were:
> 
> -temporarily exporting and adding of_i2c_register_devices to i2c.h and
> then removing it. I'm not a fan of adding that churn.
> -just combining it all into 1 patch.

That would have been the right thing to do, yes. The two patches are
not so large, so the resulting merged patch would still be reasonable.
There's no point in splitting patches if they can't be applied in
sequence, bisected, and rejected, reverted or backported individually;
which is clearly not the case here.

But anyway, I don't buy the whole thing. We currently have a nice
separation between OF and the underlying bus types. Breaking it all
just for the sake of saving one call in 4 drivers (out of ~70 in the
current kernel tree) doesn't seem worth it, at all. It would make
things harder to maintain, too (I definitely do not want to maintain
OF-specific code).

If you are really worried about the extra call to
of_i2c_register_devices(), then maybe the of_i2c implementation is
incorrect, and you should rework it to build on top of
i2c_register_board_info() rather than i2c_new_device().

> -reverse the order and leave i2c device registration broken for 1
> commit. Thinking some more about it, perhaps that is a bit better than
> broken module loading. Guess it depends if you are doing modules or
> built-in.

-- 
Jean Delvare

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

* Re: [PATCH 1/3] i2c: move of_i2c_register_devices call into core
@ 2011-09-02  9:23         ` Jean Delvare
  0 siblings, 0 replies; 24+ messages in thread
From: Jean Delvare @ 2011-09-02  9:23 UTC (permalink / raw)
  To: Rob Herring
  Cc: Grant Likely, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, Jochen Friedrich, Ben Dooks,
	Sebastian Andrzej Siewior, Dirk Brandewie, Stephen Warren,
	linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ

Hi Rob, Grant,

On Fri, 05 Aug 2011 18:22:36 -0500, Rob Herring wrote:
> Grant,
> 
> On 08/05/2011 05:54 PM, Grant Likely wrote:
> > On Fri, Aug 05, 2011 at 04:24:26PM -0500, Rob Herring wrote:
> >> From: Rob Herring <rob.herring-bsGFqQB8/DxBDgjK7y7TUQ@public.gmane.org>
> >>
> >> All callers of of_i2c_register_devices are immediately preceded by a call
> >> to i2c_add_adapter or i2c_add_numbered_adapter. Add call to
> >> of_i2c_register_devices and remove all other callers.
> >>
> >> This causes a module dependency loop that is resolved by the next commit.
> > 
> > Wrong way around.  Don't break bisectability.  I'll leave it up to Ben
> > and Jean on weather or not they want to move this code.  I intend to
> > do the same thing for spi/gpio, but I maintain those subsystems so I
> > get to choose.  i2c is not up to me.
> 
> Well, I know, but it's only broken for bisect in the case of both being
> modules. So it's only run-time brokenness. That's better than the 3
> months it was broken before. I couldn't come up with a better way. The
> choices I thought of were:
> 
> -temporarily exporting and adding of_i2c_register_devices to i2c.h and
> then removing it. I'm not a fan of adding that churn.
> -just combining it all into 1 patch.

That would have been the right thing to do, yes. The two patches are
not so large, so the resulting merged patch would still be reasonable.
There's no point in splitting patches if they can't be applied in
sequence, bisected, and rejected, reverted or backported individually;
which is clearly not the case here.

But anyway, I don't buy the whole thing. We currently have a nice
separation between OF and the underlying bus types. Breaking it all
just for the sake of saving one call in 4 drivers (out of ~70 in the
current kernel tree) doesn't seem worth it, at all. It would make
things harder to maintain, too (I definitely do not want to maintain
OF-specific code).

If you are really worried about the extra call to
of_i2c_register_devices(), then maybe the of_i2c implementation is
incorrect, and you should rework it to build on top of
i2c_register_board_info() rather than i2c_new_device().

> -reverse the order and leave i2c device registration broken for 1
> commit. Thinking some more about it, perhaps that is a bit better than
> broken module loading. Guess it depends if you are doing modules or
> built-in.

-- 
Jean Delvare

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

* Re: [PATCH 1/3] i2c: move of_i2c_register_devices call into core
@ 2011-09-02  9:23         ` Jean Delvare
  0 siblings, 0 replies; 24+ messages in thread
From: Jean Delvare @ 2011-09-02  9:23 UTC (permalink / raw)
  To: Rob Herring
  Cc: Stephen Warren, Sebastian Andrzej Siewior, linux-kernel,
	linux-i2c, Ben Dooks, Dirk Brandewie, linuxppc-dev

Hi Rob, Grant,

On Fri, 05 Aug 2011 18:22:36 -0500, Rob Herring wrote:
> Grant,
> 
> On 08/05/2011 05:54 PM, Grant Likely wrote:
> > On Fri, Aug 05, 2011 at 04:24:26PM -0500, Rob Herring wrote:
> >> From: Rob Herring <rob.herring@calxeda.com>
> >>
> >> All callers of of_i2c_register_devices are immediately preceded by a call
> >> to i2c_add_adapter or i2c_add_numbered_adapter. Add call to
> >> of_i2c_register_devices and remove all other callers.
> >>
> >> This causes a module dependency loop that is resolved by the next commit.
> > 
> > Wrong way around.  Don't break bisectability.  I'll leave it up to Ben
> > and Jean on weather or not they want to move this code.  I intend to
> > do the same thing for spi/gpio, but I maintain those subsystems so I
> > get to choose.  i2c is not up to me.
> 
> Well, I know, but it's only broken for bisect in the case of both being
> modules. So it's only run-time brokenness. That's better than the 3
> months it was broken before. I couldn't come up with a better way. The
> choices I thought of were:
> 
> -temporarily exporting and adding of_i2c_register_devices to i2c.h and
> then removing it. I'm not a fan of adding that churn.
> -just combining it all into 1 patch.

That would have been the right thing to do, yes. The two patches are
not so large, so the resulting merged patch would still be reasonable.
There's no point in splitting patches if they can't be applied in
sequence, bisected, and rejected, reverted or backported individually;
which is clearly not the case here.

But anyway, I don't buy the whole thing. We currently have a nice
separation between OF and the underlying bus types. Breaking it all
just for the sake of saving one call in 4 drivers (out of ~70 in the
current kernel tree) doesn't seem worth it, at all. It would make
things harder to maintain, too (I definitely do not want to maintain
OF-specific code).

If you are really worried about the extra call to
of_i2c_register_devices(), then maybe the of_i2c implementation is
incorrect, and you should rework it to build on top of
i2c_register_board_info() rather than i2c_new_device().

> -reverse the order and leave i2c device registration broken for 1
> commit. Thinking some more about it, perhaps that is a bit better than
> broken module loading. Guess it depends if you are doing modules or
> built-in.

-- 
Jean Delvare

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

end of thread, other threads:[~2011-09-02  9:56 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-05 21:24 [PATCH 0/3] Move OF i2c functions into i2c core Rob Herring
2011-08-05 21:24 ` Rob Herring
2011-08-05 21:24 ` [PATCH 1/3] i2c: move of_i2c_register_devices call into core Rob Herring
2011-08-05 21:24   ` Rob Herring
2011-08-05 22:54   ` Grant Likely
2011-08-05 22:54     ` Grant Likely
2011-08-05 22:54     ` Grant Likely
2011-08-05 23:22     ` Rob Herring
2011-08-05 23:22       ` Rob Herring
2011-08-05 23:22       ` Rob Herring
2011-09-02  9:23       ` Jean Delvare
2011-09-02  9:23         ` Jean Delvare
2011-09-02  9:23         ` Jean Delvare
2011-08-05 21:24 ` [PATCH 2/3] i2c: move OF i2c related functions into i2c core Rob Herring
2011-08-05 22:56   ` Grant Likely
2011-08-05 22:56     ` Grant Likely
2011-08-05 23:15     ` Rob Herring
2011-08-05 23:15       ` Rob Herring
2011-08-06  8:50       ` Grant Likely
2011-08-06  8:50         ` Grant Likely
2011-08-05 21:24 ` [PATCH 3/3] i2c-designware: add OF binding support Rob Herring
2011-08-05 21:24   ` Rob Herring
2011-08-24  3:31   ` Rob Herring
2011-08-24  3:31     ` Rob Herring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.