aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorWolfram Sang <wsa@the-dreams.de>2013-07-11 07:56:15 -0400
committerWolfram Sang <wsa@the-dreams.de>2013-08-23 04:22:20 -0400
commit687b81d083c082bc1e853032e3a2a54f8c251d27 (patch)
tree60ce91a6ecc84a8bfd1968772cd081c0afdce0f8 /drivers
parentc1d15b68aab86f1f3b602fa65e7618c0065d46e6 (diff)
i2c: move OF helpers into the core
I2C of helpers used to live in of_i2c.c but experience (from SPI) shows that it is much cleaner to have this in the core. This also removes a circular dependency between the helpers and the core, and so we can finally register child nodes in the core instead of doing this manually in each driver. So, fix the drivers and documentation, too. Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/tilcdc/tilcdc_slave.c1
-rw-r--r--drivers/gpu/drm/tilcdc/tilcdc_tfp410.c1
-rw-r--r--drivers/gpu/host1x/drm/output.c2
-rw-r--r--drivers/i2c/busses/i2c-at91.c3
-rw-r--r--drivers/i2c/busses/i2c-cpm.c6
-rw-r--r--drivers/i2c/busses/i2c-davinci.c2
-rw-r--r--drivers/i2c/busses/i2c-designware-platdrv.c2
-rw-r--r--drivers/i2c/busses/i2c-gpio.c3
-rw-r--r--drivers/i2c/busses/i2c-i801.c2
-rw-r--r--drivers/i2c/busses/i2c-ibm_iic.c4
-rw-r--r--drivers/i2c/busses/i2c-imx.c3
-rw-r--r--drivers/i2c/busses/i2c-mpc.c2
-rw-r--r--drivers/i2c/busses/i2c-mv64xxx.c3
-rw-r--r--drivers/i2c/busses/i2c-mxs.c3
-rw-r--r--drivers/i2c/busses/i2c-nomadik.c3
-rw-r--r--drivers/i2c/busses/i2c-ocores.c3
-rw-r--r--drivers/i2c/busses/i2c-octeon.c3
-rw-r--r--drivers/i2c/busses/i2c-omap.c3
-rw-r--r--drivers/i2c/busses/i2c-pnx.c3
-rw-r--r--drivers/i2c/busses/i2c-powermac.c9
-rw-r--r--drivers/i2c/busses/i2c-pxa.c2
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c2
-rw-r--r--drivers/i2c/busses/i2c-sh_mobile.c2
-rw-r--r--drivers/i2c/busses/i2c-sirf.c3
-rw-r--r--drivers/i2c/busses/i2c-stu300.c2
-rw-r--r--drivers/i2c/busses/i2c-tegra.c3
-rw-r--r--drivers/i2c/busses/i2c-versatile.c2
-rw-r--r--drivers/i2c/busses/i2c-wmt.c3
-rw-r--r--drivers/i2c/busses/i2c-xiic.c3
-rw-r--r--drivers/i2c/i2c-core.c109
-rw-r--r--drivers/i2c/i2c-mux.c3
-rw-r--r--drivers/i2c/muxes/i2c-arb-gpio-challenge.c1
-rw-r--r--drivers/i2c/muxes/i2c-mux-gpio.c1
-rw-r--r--drivers/i2c/muxes/i2c-mux-pinctrl.c1
-rw-r--r--drivers/media/platform/exynos4-is/fimc-is-i2c.c4
-rw-r--r--drivers/media/platform/exynos4-is/fimc-is.c2
-rw-r--r--drivers/media/platform/exynos4-is/media-dev.c1
-rw-r--r--drivers/of/Kconfig6
-rw-r--r--drivers/of/Makefile1
-rw-r--r--drivers/of/of_i2c.c114
-rw-r--r--drivers/staging/imx-drm/imx-tve.c2
41 files changed, 116 insertions, 212 deletions
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave.c b/drivers/gpu/drm/tilcdc/tilcdc_slave.c
index dfffaf014022..a19f657dfa59 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_slave.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_slave.c
@@ -16,7 +16,6 @@
16 */ 16 */
17 17
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/of_i2c.h>
20#include <linux/pinctrl/pinmux.h> 19#include <linux/pinctrl/pinmux.h>
21#include <linux/pinctrl/consumer.h> 20#include <linux/pinctrl/consumer.h>
22#include <drm/drm_encoder_slave.h> 21#include <drm/drm_encoder_slave.h>
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
index 925c7cddeff9..c38b56b268ac 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
@@ -16,7 +16,6 @@
16 */ 16 */
17 17
18#include <linux/i2c.h> 18#include <linux/i2c.h>
19#include <linux/of_i2c.h>
20#include <linux/gpio.h> 19#include <linux/gpio.h>
21#include <linux/of_gpio.h> 20#include <linux/of_gpio.h>
22#include <linux/pinctrl/pinmux.h> 21#include <linux/pinctrl/pinmux.h>
diff --git a/drivers/gpu/host1x/drm/output.c b/drivers/gpu/host1x/drm/output.c
index 8140fc6c34d8..137ae81ab80e 100644
--- a/drivers/gpu/host1x/drm/output.c
+++ b/drivers/gpu/host1x/drm/output.c
@@ -9,7 +9,7 @@
9 9
10#include <linux/module.h> 10#include <linux/module.h>
11#include <linux/of_gpio.h> 11#include <linux/of_gpio.h>
12#include <linux/of_i2c.h> 12#include <linux/i2c.h>
13 13
14#include "drm.h" 14#include "drm.h"
15 15
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 6bb839b688be..fd059308affa 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -28,7 +28,6 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/of.h> 29#include <linux/of.h>
30#include <linux/of_device.h> 30#include <linux/of_device.h>
31#include <linux/of_i2c.h>
32#include <linux/platform_device.h> 31#include <linux/platform_device.h>
33#include <linux/slab.h> 32#include <linux/slab.h>
34#include <linux/platform_data/dma-atmel.h> 33#include <linux/platform_data/dma-atmel.h>
@@ -775,8 +774,6 @@ static int at91_twi_probe(struct platform_device *pdev)
775 return rc; 774 return rc;
776 } 775 }
777 776
778 of_i2c_register_devices(&dev->adapter);
779
780 dev_info(dev->dev, "AT91 i2c bus driver.\n"); 777 dev_info(dev->dev, "AT91 i2c bus driver.\n");
781 return 0; 778 return 0;
782} 779}
diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
index 2e1f7eb55bf4..b2b8aa9adc0e 100644
--- a/drivers/i2c/busses/i2c-cpm.c
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -42,7 +42,6 @@
42#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
43#include <linux/of_device.h> 43#include <linux/of_device.h>
44#include <linux/of_platform.h> 44#include <linux/of_platform.h>
45#include <linux/of_i2c.h>
46#include <sysdev/fsl_soc.h> 45#include <sysdev/fsl_soc.h>
47#include <asm/cpm.h> 46#include <asm/cpm.h>
48 47
@@ -681,11 +680,6 @@ static int cpm_i2c_probe(struct platform_device *ofdev)
681 dev_dbg(&ofdev->dev, "hw routines for %s registered.\n", 680 dev_dbg(&ofdev->dev, "hw routines for %s registered.\n",
682 cpm->adap.name); 681 cpm->adap.name);
683 682
684 /*
685 * register OF I2C devices
686 */
687 of_i2c_register_devices(&cpm->adap);
688
689 return 0; 683 return 0;
690out_shut: 684out_shut:
691 cpm_i2c_shutdown(cpm); 685 cpm_i2c_shutdown(cpm);
diff --git a/drivers/i2c/busses/i2c-davinci.c b/drivers/i2c/busses/i2c-davinci.c
index cf90bfff9676..57473415be10 100644
--- a/drivers/i2c/busses/i2c-davinci.c
+++ b/drivers/i2c/busses/i2c-davinci.c
@@ -38,7 +38,6 @@
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/cpufreq.h> 39#include <linux/cpufreq.h>
40#include <linux/gpio.h> 40#include <linux/gpio.h>
41#include <linux/of_i2c.h>
42#include <linux/of_device.h> 41#include <linux/of_device.h>
43#include <linux/platform_data/i2c-davinci.h> 42#include <linux/platform_data/i2c-davinci.h>
44 43
@@ -726,7 +725,6 @@ static int davinci_i2c_probe(struct platform_device *pdev)
726 dev_err(&pdev->dev, "failure adding adapter\n"); 725 dev_err(&pdev->dev, "failure adding adapter\n");
727 goto err_unuse_clocks; 726 goto err_unuse_clocks;
728 } 727 }
729 of_i2c_register_devices(adap);
730 728
731 return 0; 729 return 0;
732 730
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 64ffb908641c..ded77c3bd59c 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -35,7 +35,6 @@
35#include <linux/err.h> 35#include <linux/err.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/of.h> 37#include <linux/of.h>
38#include <linux/of_i2c.h>
39#include <linux/platform_device.h> 38#include <linux/platform_device.h>
40#include <linux/pm.h> 39#include <linux/pm.h>
41#include <linux/pm_runtime.h> 40#include <linux/pm_runtime.h>
@@ -172,7 +171,6 @@ static int dw_i2c_probe(struct platform_device *pdev)
172 dev_err(&pdev->dev, "failure adding adapter\n"); 171 dev_err(&pdev->dev, "failure adding adapter\n");
173 return r; 172 return r;
174 } 173 }
175 of_i2c_register_devices(adap);
176 acpi_i2c_register_devices(adap); 174 acpi_i2c_register_devices(adap);
177 175
178 pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); 176 pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index 8cdb4f743e19..bfa02c6c2dda 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -16,7 +16,6 @@
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/gpio.h> 17#include <linux/gpio.h>
18#include <linux/of_gpio.h> 18#include <linux/of_gpio.h>
19#include <linux/of_i2c.h>
20 19
21struct i2c_gpio_private_data { 20struct i2c_gpio_private_data {
22 struct i2c_adapter adap; 21 struct i2c_adapter adap;
@@ -224,8 +223,6 @@ static int i2c_gpio_probe(struct platform_device *pdev)
224 if (ret) 223 if (ret)
225 goto err_add_bus; 224 goto err_add_bus;
226 225
227 of_i2c_register_devices(adap);
228
229 platform_set_drvdata(pdev, priv); 226 platform_set_drvdata(pdev, priv);
230 227
231 dev_info(&pdev->dev, "using pins %u (SDA) and %u (SCL%s)\n", 228 dev_info(&pdev->dev, "using pins %u (SDA) and %u (SCL%s)\n",
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index 4ebceed6bc66..4296d1721272 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -87,7 +87,6 @@
87#include <linux/slab.h> 87#include <linux/slab.h>
88#include <linux/wait.h> 88#include <linux/wait.h>
89#include <linux/err.h> 89#include <linux/err.h>
90#include <linux/of_i2c.h>
91 90
92#if (defined CONFIG_I2C_MUX_GPIO || defined CONFIG_I2C_MUX_GPIO_MODULE) && \ 91#if (defined CONFIG_I2C_MUX_GPIO || defined CONFIG_I2C_MUX_GPIO_MODULE) && \
93 defined CONFIG_DMI 92 defined CONFIG_DMI
@@ -1230,7 +1229,6 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
1230 goto exit_free_irq; 1229 goto exit_free_irq;
1231 } 1230 }
1232 1231
1233 of_i2c_register_devices(&priv->adapter);
1234 i801_probe_optional_slaves(priv); 1232 i801_probe_optional_slaves(priv);
1235 /* We ignore errors - multiplexing is optional */ 1233 /* We ignore errors - multiplexing is optional */
1236 i801_add_mux(priv); 1234 i801_add_mux(priv);
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 973f51688276..ff3caa0c28cd 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -42,7 +42,6 @@
42#include <linux/io.h> 42#include <linux/io.h>
43#include <linux/i2c.h> 43#include <linux/i2c.h>
44#include <linux/of_platform.h> 44#include <linux/of_platform.h>
45#include <linux/of_i2c.h>
46 45
47#include "i2c-ibm_iic.h" 46#include "i2c-ibm_iic.h"
48 47
@@ -759,9 +758,6 @@ static int iic_probe(struct platform_device *ofdev)
759 dev_info(&ofdev->dev, "using %s mode\n", 758 dev_info(&ofdev->dev, "using %s mode\n",
760 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)"); 759 dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
761 760
762 /* Now register all the child nodes */
763 of_i2c_register_devices(adap);
764
765 return 0; 761 return 0;
766 762
767error_cleanup: 763error_cleanup:
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index a231d2fd91ce..ccf46656bdad 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -52,7 +52,6 @@
52#include <linux/slab.h> 52#include <linux/slab.h>
53#include <linux/of.h> 53#include <linux/of.h>
54#include <linux/of_device.h> 54#include <linux/of_device.h>
55#include <linux/of_i2c.h>
56#include <linux/platform_data/i2c-imx.h> 55#include <linux/platform_data/i2c-imx.h>
57 56
58/** Defines ******************************************************************** 57/** Defines ********************************************************************
@@ -682,8 +681,6 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
682 return ret; 681 return ret;
683 } 682 }
684 683
685 of_i2c_register_devices(&i2c_imx->adapter);
686
687 /* Set up platform driver data */ 684 /* Set up platform driver data */
688 platform_set_drvdata(pdev, i2c_imx); 685 platform_set_drvdata(pdev, i2c_imx);
689 clk_disable_unprepare(i2c_imx->clk); 686 clk_disable_unprepare(i2c_imx->clk);
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index ffac2145b94a..f4060939e959 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -18,7 +18,6 @@
18#include <linux/sched.h> 18#include <linux/sched.h>
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/of_platform.h> 20#include <linux/of_platform.h>
21#include <linux/of_i2c.h>
22#include <linux/slab.h> 21#include <linux/slab.h>
23 22
24#include <linux/io.h> 23#include <linux/io.h>
@@ -694,7 +693,6 @@ static int fsl_i2c_probe(struct platform_device *op)
694 dev_err(i2c->dev, "failed to add adapter\n"); 693 dev_err(i2c->dev, "failed to add adapter\n");
695 goto fail_add; 694 goto fail_add;
696 } 695 }
697 of_i2c_register_devices(&i2c->adap);
698 696
699 return result; 697 return result;
700 698
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c
index bc60f9ac7c04..7f3a47443494 100644
--- a/drivers/i2c/busses/i2c-mv64xxx.c
+++ b/drivers/i2c/busses/i2c-mv64xxx.c
@@ -21,7 +21,6 @@
21#include <linux/of.h> 21#include <linux/of.h>
22#include <linux/of_device.h> 22#include <linux/of_device.h>
23#include <linux/of_irq.h> 23#include <linux/of_irq.h>
24#include <linux/of_i2c.h>
25#include <linux/clk.h> 24#include <linux/clk.h>
26#include <linux/err.h> 25#include <linux/err.h>
27#include <linux/delay.h> 26#include <linux/delay.h>
@@ -871,8 +870,6 @@ mv64xxx_i2c_probe(struct platform_device *pd)
871 goto exit_free_irq; 870 goto exit_free_irq;
872 } 871 }
873 872
874 of_i2c_register_devices(&drv_data->adapter);
875
876 return 0; 873 return 0;
877 874
878exit_free_irq: 875exit_free_irq:
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 46cda0b02fd1..f4a01675fa71 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -27,7 +27,6 @@
27#include <linux/stmp_device.h> 27#include <linux/stmp_device.h>
28#include <linux/of.h> 28#include <linux/of.h>
29#include <linux/of_device.h> 29#include <linux/of_device.h>
30#include <linux/of_i2c.h>
31#include <linux/dma-mapping.h> 30#include <linux/dma-mapping.h>
32#include <linux/dmaengine.h> 31#include <linux/dmaengine.h>
33 32
@@ -752,8 +751,6 @@ static int mxs_i2c_probe(struct platform_device *pdev)
752 return err; 751 return err;
753 } 752 }
754 753
755 of_i2c_register_devices(adap);
756
757 return 0; 754 return 0;
758} 755}
759 756
diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 1909e8073541..8bf9ac01301a 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -24,7 +24,6 @@
24#include <linux/pm_runtime.h> 24#include <linux/pm_runtime.h>
25#include <linux/platform_data/i2c-nomadik.h> 25#include <linux/platform_data/i2c-nomadik.h>
26#include <linux/of.h> 26#include <linux/of.h>
27#include <linux/of_i2c.h>
28#include <linux/pinctrl/consumer.h> 27#include <linux/pinctrl/consumer.h>
29 28
30#define DRIVER_NAME "nmk-i2c" 29#define DRIVER_NAME "nmk-i2c"
@@ -1045,8 +1044,6 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
1045 goto err_add_adap; 1044 goto err_add_adap;
1046 } 1045 }
1047 1046
1048 of_i2c_register_devices(adap);
1049
1050 pm_runtime_put(&adev->dev); 1047 pm_runtime_put(&adev->dev);
1051 1048
1052 return 0; 1049 return 0;
diff --git a/drivers/i2c/busses/i2c-ocores.c b/drivers/i2c/busses/i2c-ocores.c
index e14182cd87ff..c61f37a10a07 100644
--- a/drivers/i2c/busses/i2c-ocores.c
+++ b/drivers/i2c/busses/i2c-ocores.c
@@ -24,7 +24,6 @@
24#include <linux/i2c-ocores.h> 24#include <linux/i2c-ocores.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/io.h> 26#include <linux/io.h>
27#include <linux/of_i2c.h>
28#include <linux/log2.h> 27#include <linux/log2.h>
29 28
30struct ocores_i2c { 29struct ocores_i2c {
@@ -432,8 +431,6 @@ static int ocores_i2c_probe(struct platform_device *pdev)
432 if (pdata) { 431 if (pdata) {
433 for (i = 0; i < pdata->num_devices; i++) 432 for (i = 0; i < pdata->num_devices; i++)
434 i2c_new_device(&i2c->adap, pdata->devices + i); 433 i2c_new_device(&i2c->adap, pdata->devices + i);
435 } else {
436 of_i2c_register_devices(&i2c->adap);
437 } 434 }
438 435
439 return 0; 436 return 0;
diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c
index 956fe320f313..b929ba271b47 100644
--- a/drivers/i2c/busses/i2c-octeon.c
+++ b/drivers/i2c/busses/i2c-octeon.c
@@ -15,7 +15,6 @@
15#include <linux/interrupt.h> 15#include <linux/interrupt.h>
16#include <linux/kernel.h> 16#include <linux/kernel.h>
17#include <linux/module.h> 17#include <linux/module.h>
18#include <linux/of_i2c.h>
19#include <linux/delay.h> 18#include <linux/delay.h>
20#include <linux/sched.h> 19#include <linux/sched.h>
21#include <linux/slab.h> 20#include <linux/slab.h>
@@ -599,8 +598,6 @@ static int octeon_i2c_probe(struct platform_device *pdev)
599 } 598 }
600 dev_info(i2c->dev, "version %s\n", DRV_VERSION); 599 dev_info(i2c->dev, "version %s\n", DRV_VERSION);
601 600
602 of_i2c_register_devices(&i2c->adap);
603
604 return 0; 601 return 0;
605 602
606out: 603out:
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 9ccb7b9cb6fc..6d8308d5dc4e 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -38,7 +38,6 @@
38#include <linux/clk.h> 38#include <linux/clk.h>
39#include <linux/io.h> 39#include <linux/io.h>
40#include <linux/of.h> 40#include <linux/of.h>
41#include <linux/of_i2c.h>
42#include <linux/of_device.h> 41#include <linux/of_device.h>
43#include <linux/slab.h> 42#include <linux/slab.h>
44#include <linux/i2c-omap.h> 43#include <linux/i2c-omap.h>
@@ -1231,8 +1230,6 @@ omap_i2c_probe(struct platform_device *pdev)
1231 dev_info(dev->dev, "bus %d rev%d.%d at %d kHz\n", adap->nr, 1230 dev_info(dev->dev, "bus %d rev%d.%d at %d kHz\n", adap->nr,
1232 major, minor, dev->speed); 1231 major, minor, dev->speed);
1233 1232
1234 of_i2c_register_devices(adap);
1235
1236 pm_runtime_mark_last_busy(dev->dev); 1233 pm_runtime_mark_last_busy(dev->dev);
1237 pm_runtime_put_autosuspend(dev->dev); 1234 pm_runtime_put_autosuspend(dev->dev);
1238 1235
diff --git a/drivers/i2c/busses/i2c-pnx.c b/drivers/i2c/busses/i2c-pnx.c
index 1713b3ee61f5..d09577a05d00 100644
--- a/drivers/i2c/busses/i2c-pnx.c
+++ b/drivers/i2c/busses/i2c-pnx.c
@@ -23,7 +23,6 @@
23#include <linux/err.h> 23#include <linux/err.h>
24#include <linux/clk.h> 24#include <linux/clk.h>
25#include <linux/slab.h> 25#include <linux/slab.h>
26#include <linux/of_i2c.h>
27 26
28#define I2C_PNX_TIMEOUT_DEFAULT 10 /* msec */ 27#define I2C_PNX_TIMEOUT_DEFAULT 10 /* msec */
29#define I2C_PNX_SPEED_KHZ_DEFAULT 100 28#define I2C_PNX_SPEED_KHZ_DEFAULT 100
@@ -741,8 +740,6 @@ static int i2c_pnx_probe(struct platform_device *pdev)
741 goto out_irq; 740 goto out_irq;
742 } 741 }
743 742
744 of_i2c_register_devices(&alg_data->adapter);
745
746 dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n", 743 dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n",
747 alg_data->adapter.name, res->start, alg_data->irq); 744 alg_data->adapter.name, res->start, alg_data->irq);
748 745
diff --git a/drivers/i2c/busses/i2c-powermac.c b/drivers/i2c/busses/i2c-powermac.c
index 06858d576552..37e8cfad625b 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -440,7 +440,9 @@ static int i2c_powermac_probe(struct platform_device *dev)
440 adapter->algo = &i2c_powermac_algorithm; 440 adapter->algo = &i2c_powermac_algorithm;
441 i2c_set_adapdata(adapter, bus); 441 i2c_set_adapdata(adapter, bus);
442 adapter->dev.parent = &dev->dev; 442 adapter->dev.parent = &dev->dev;
443 adapter->dev.of_node = dev->dev.of_node; 443
444 /* Clear of_node to skip automatic registration of i2c child nodes */
445 adapter->dev.of_node = NULL;
444 rc = i2c_add_adapter(adapter); 446 rc = i2c_add_adapter(adapter);
445 if (rc) { 447 if (rc) {
446 printk(KERN_ERR "i2c-powermac: Adapter %s registration " 448 printk(KERN_ERR "i2c-powermac: Adapter %s registration "
@@ -451,9 +453,8 @@ static int i2c_powermac_probe(struct platform_device *dev)
451 453
452 printk(KERN_INFO "PowerMac i2c bus %s registered\n", adapter->name); 454 printk(KERN_INFO "PowerMac i2c bus %s registered\n", adapter->name);
453 455
454 /* Cannot use of_i2c_register_devices() due to Apple device-tree 456 /* Use custom child registration due to Apple device-tree funkyness */
455 * funkyness 457 adapter->dev.of_node = dev->dev.of_node;
456 */
457 i2c_powermac_register_devices(adapter, bus); 458 i2c_powermac_register_devices(adapter, bus);
458 459
459 return 0; 460 return 0;
diff --git a/drivers/i2c/busses/i2c-pxa.c b/drivers/i2c/busses/i2c-pxa.c
index 3dbc1acdc28a..bbe6dfbc5c05 100644
--- a/drivers/i2c/busses/i2c-pxa.c
+++ b/drivers/i2c/busses/i2c-pxa.c
@@ -31,7 +31,6 @@
31#include <linux/i2c-pxa.h> 31#include <linux/i2c-pxa.h>
32#include <linux/of.h> 32#include <linux/of.h>
33#include <linux/of_device.h> 33#include <linux/of_device.h>
34#include <linux/of_i2c.h>
35#include <linux/platform_device.h> 34#include <linux/platform_device.h>
36#include <linux/err.h> 35#include <linux/err.h>
37#include <linux/clk.h> 36#include <linux/clk.h>
@@ -1247,7 +1246,6 @@ static int i2c_pxa_probe(struct platform_device *dev)
1247 printk(KERN_INFO "I2C: Failed to add bus\n"); 1246 printk(KERN_INFO "I2C: Failed to add bus\n");
1248 goto eadapt; 1247 goto eadapt;
1249 } 1248 }
1250 of_i2c_register_devices(&i2c->adap);
1251 1249
1252 platform_set_drvdata(dev, i2c); 1250 platform_set_drvdata(dev, i2c);
1253 1251
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index 0a077b1ef94f..3535f3c0f7b4 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -36,7 +36,6 @@
36#include <linux/cpufreq.h> 36#include <linux/cpufreq.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/io.h> 38#include <linux/io.h>
39#include <linux/of_i2c.h>
40#include <linux/of_gpio.h> 39#include <linux/of_gpio.h>
41#include <linux/pinctrl/consumer.h> 40#include <linux/pinctrl/consumer.h>
42 41
@@ -1154,7 +1153,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
1154 return ret; 1153 return ret;
1155 } 1154 }
1156 1155
1157 of_i2c_register_devices(&i2c->adap);
1158 platform_set_drvdata(pdev, i2c); 1156 platform_set_drvdata(pdev, i2c);
1159 1157
1160 pm_runtime_enable(&pdev->dev); 1158 pm_runtime_enable(&pdev->dev);
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 4e86a3190d46..55110ddbed1f 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -27,7 +27,6 @@
27#include <linux/platform_device.h> 27#include <linux/platform_device.h>
28#include <linux/interrupt.h> 28#include <linux/interrupt.h>
29#include <linux/i2c.h> 29#include <linux/i2c.h>
30#include <linux/of_i2c.h>
31#include <linux/err.h> 30#include <linux/err.h>
32#include <linux/pm_runtime.h> 31#include <linux/pm_runtime.h>
33#include <linux/clk.h> 32#include <linux/clk.h>
@@ -758,7 +757,6 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
758 "I2C adapter %d with bus speed %lu Hz (L/H=%x/%x)\n", 757 "I2C adapter %d with bus speed %lu Hz (L/H=%x/%x)\n",
759 adap->nr, pd->bus_speed, pd->iccl, pd->icch); 758 adap->nr, pd->bus_speed, pd->iccl, pd->icch);
760 759
761 of_i2c_register_devices(adap);
762 return 0; 760 return 0;
763 761
764 err_all: 762 err_all:
diff --git a/drivers/i2c/busses/i2c-sirf.c b/drivers/i2c/busses/i2c-sirf.c
index a63c7d506836..0ff22e29e7df 100644
--- a/drivers/i2c/busses/i2c-sirf.c
+++ b/drivers/i2c/busses/i2c-sirf.c
@@ -12,7 +12,6 @@
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14#include <linux/i2c.h> 14#include <linux/i2c.h>
15#include <linux/of_i2c.h>
16#include <linux/clk.h> 15#include <linux/clk.h>
17#include <linux/err.h> 16#include <linux/err.h>
18#include <linux/io.h> 17#include <linux/io.h>
@@ -366,8 +365,6 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
366 365
367 clk_disable(clk); 366 clk_disable(clk);
368 367
369 of_i2c_register_devices(adap);
370
371 dev_info(&pdev->dev, " I2C adapter ready to operate\n"); 368 dev_info(&pdev->dev, " I2C adapter ready to operate\n");
372 369
373 return 0; 370 return 0;
diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c
index 19a40afaf172..f8f6f2e552db 100644
--- a/drivers/i2c/busses/i2c-stu300.c
+++ b/drivers/i2c/busses/i2c-stu300.c
@@ -17,7 +17,6 @@
17#include <linux/clk.h> 17#include <linux/clk.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/of_i2c.h>
21 20
22/* the name of this kernel module */ 21/* the name of this kernel module */
23#define NAME "stu300" 22#define NAME "stu300"
@@ -933,7 +932,6 @@ stu300_probe(struct platform_device *pdev)
933 platform_set_drvdata(pdev, dev); 932 platform_set_drvdata(pdev, dev);
934 dev_info(&pdev->dev, "ST DDC I2C @ %p, irq %d\n", 933 dev_info(&pdev->dev, "ST DDC I2C @ %p, irq %d\n",
935 dev->virtbase, dev->irq); 934 dev->virtbase, dev->irq);
936 of_i2c_register_devices(adap);
937 935
938 return 0; 936 return 0;
939} 937}
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 9aa1b60f7fdd..c457cb447c66 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -25,7 +25,6 @@
25#include <linux/interrupt.h> 25#include <linux/interrupt.h>
26#include <linux/delay.h> 26#include <linux/delay.h>
27#include <linux/slab.h> 27#include <linux/slab.h>
28#include <linux/of_i2c.h>
29#include <linux/of_device.h> 28#include <linux/of_device.h>
30#include <linux/module.h> 29#include <linux/module.h>
31#include <linux/clk/tegra.h> 30#include <linux/clk/tegra.h>
@@ -802,8 +801,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
802 return ret; 801 return ret;
803 } 802 }
804 803
805 of_i2c_register_devices(&i2c_dev->adapter);
806
807 return 0; 804 return 0;
808} 805}
809 806
diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c
index f3a8790a07e8..6bb3a89a440f 100644
--- a/drivers/i2c/busses/i2c-versatile.c
+++ b/drivers/i2c/busses/i2c-versatile.c
@@ -16,7 +16,6 @@
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/of_i2c.h>
20 19
21#define I2C_CONTROL 0x00 20#define I2C_CONTROL 0x00
22#define I2C_CONTROLS 0x00 21#define I2C_CONTROLS 0x00
@@ -108,7 +107,6 @@ static int i2c_versatile_probe(struct platform_device *dev)
108 ret = i2c_bit_add_numbered_bus(&i2c->adap); 107 ret = i2c_bit_add_numbered_bus(&i2c->adap);
109 if (ret >= 0) { 108 if (ret >= 0) {
110 platform_set_drvdata(dev, i2c); 109 platform_set_drvdata(dev, i2c);
111 of_i2c_register_devices(&i2c->adap);
112 return 0; 110 return 0;
113 } 111 }
114 112
diff --git a/drivers/i2c/busses/i2c-wmt.c b/drivers/i2c/busses/i2c-wmt.c
index baaa7d15b73e..c65da3d913a0 100644
--- a/drivers/i2c/busses/i2c-wmt.c
+++ b/drivers/i2c/busses/i2c-wmt.c
@@ -21,7 +21,6 @@
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/of.h> 22#include <linux/of.h>
23#include <linux/of_address.h> 23#include <linux/of_address.h>
24#include <linux/of_i2c.h>
25#include <linux/of_irq.h> 24#include <linux/of_irq.h>
26#include <linux/platform_device.h> 25#include <linux/platform_device.h>
27 26
@@ -439,8 +438,6 @@ static int wmt_i2c_probe(struct platform_device *pdev)
439 438
440 platform_set_drvdata(pdev, i2c_dev); 439 platform_set_drvdata(pdev, i2c_dev);
441 440
442 of_i2c_register_devices(adap);
443
444 return 0; 441 return 0;
445} 442}
446 443
diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index 433f377b3869..4c8b368d463b 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -40,7 +40,6 @@
40#include <linux/i2c-xiic.h> 40#include <linux/i2c-xiic.h>
41#include <linux/io.h> 41#include <linux/io.h>
42#include <linux/slab.h> 42#include <linux/slab.h>
43#include <linux/of_i2c.h>
44 43
45#define DRIVER_NAME "xiic-i2c" 44#define DRIVER_NAME "xiic-i2c"
46 45
@@ -752,8 +751,6 @@ static int xiic_i2c_probe(struct platform_device *pdev)
752 i2c_new_device(&i2c->adap, pdata->devices + i); 751 i2c_new_device(&i2c->adap, pdata->devices + i);
753 } 752 }
754 753
755 of_i2c_register_devices(&i2c->adap);
756
757 return 0; 754 return 0;
758 755
759add_adapter_failed: 756add_adapter_failed:
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 3d9ca2d3d77e..e874b052b4f8 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -23,7 +23,11 @@
23 SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> and 23 SMBus 2.0 support by Mark Studebaker <mdsxyz123@yahoo.com> and
24 Jean Delvare <khali@linux-fr.org> 24 Jean Delvare <khali@linux-fr.org>
25 Mux support by Rodolfo Giometti <giometti@enneenne.com> and 25 Mux support by Rodolfo Giometti <giometti@enneenne.com> and
26 Michael Lawnick <michael.lawnick.ext@nsn.com> */ 26 Michael Lawnick <michael.lawnick.ext@nsn.com>
27 OF support is copyright (c) 2008 Jochen Friedrich <jochen@scram.de>
28 (based on a previous patch from Jon Smirl <jonsmirl@gmail.com>) and
29 (c) 2013 Wolfram Sang <wsa@the-dreams.de>
30 */
27 31
28#include <linux/module.h> 32#include <linux/module.h>
29#include <linux/kernel.h> 33#include <linux/kernel.h>
@@ -35,7 +39,9 @@
35#include <linux/init.h> 39#include <linux/init.h>
36#include <linux/idr.h> 40#include <linux/idr.h>
37#include <linux/mutex.h> 41#include <linux/mutex.h>
42#include <linux/of.h>
38#include <linux/of_device.h> 43#include <linux/of_device.h>
44#include <linux/of_irq.h>
39#include <linux/completion.h> 45#include <linux/completion.h>
40#include <linux/hardirq.h> 46#include <linux/hardirq.h>
41#include <linux/irqflags.h> 47#include <linux/irqflags.h>
@@ -954,6 +960,104 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter)
954 up_read(&__i2c_board_lock); 960 up_read(&__i2c_board_lock);
955} 961}
956 962
963/* OF support code */
964
965#if IS_ENABLED(CONFIG_OF)
966static void of_i2c_register_devices(struct i2c_adapter *adap)
967{
968 void *result;
969 struct device_node *node;
970
971 /* Only register child devices if the adapter has a node pointer set */
972 if (!adap->dev.of_node)
973 return;
974
975 dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
976
977 for_each_available_child_of_node(adap->dev.of_node, node) {
978 struct i2c_board_info info = {};
979 struct dev_archdata dev_ad = {};
980 const __be32 *addr;
981 int len;
982
983 dev_dbg(&adap->dev, "of_i2c: register %s\n", node->full_name);
984
985 if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
986 dev_err(&adap->dev, "of_i2c: modalias failure on %s\n",
987 node->full_name);
988 continue;
989 }
990
991 addr = of_get_property(node, "reg", &len);
992 if (!addr || (len < sizeof(int))) {
993 dev_err(&adap->dev, "of_i2c: invalid reg on %s\n",
994 node->full_name);
995 continue;
996 }
997
998 info.addr = be32_to_cpup(addr);
999 if (info.addr > (1 << 10) - 1) {
1000 dev_err(&adap->dev, "of_i2c: invalid addr=%x on %s\n",
1001 info.addr, node->full_name);
1002 continue;
1003 }
1004
1005 info.irq = irq_of_parse_and_map(node, 0);
1006 info.of_node = of_node_get(node);
1007 info.archdata = &dev_ad;
1008
1009 if (of_get_property(node, "wakeup-source", NULL))
1010 info.flags |= I2C_CLIENT_WAKE;
1011
1012 request_module("%s%s", I2C_MODULE_PREFIX, info.type);
1013
1014 result = i2c_new_device(adap, &info);
1015 if (result == NULL) {
1016 dev_err(&adap->dev, "of_i2c: Failure registering %s\n",
1017 node->full_name);
1018 of_node_put(node);
1019 irq_dispose_mapping(info.irq);
1020 continue;
1021 }
1022 }
1023}
1024
1025static int of_dev_node_match(struct device *dev, void *data)
1026{
1027 return dev->of_node == data;
1028}
1029
1030/* must call put_device() when done with returned i2c_client device */
1031struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
1032{
1033 struct device *dev;
1034
1035 dev = bus_find_device(&i2c_bus_type, NULL, node,
1036 of_dev_node_match);
1037 if (!dev)
1038 return NULL;
1039
1040 return i2c_verify_client(dev);
1041}
1042EXPORT_SYMBOL(of_find_i2c_device_by_node);
1043
1044/* must call put_device() when done with returned i2c_adapter device */
1045struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
1046{
1047 struct device *dev;
1048
1049 dev = bus_find_device(&i2c_bus_type, NULL, node,
1050 of_dev_node_match);
1051 if (!dev)
1052 return NULL;
1053
1054 return i2c_verify_adapter(dev);
1055}
1056EXPORT_SYMBOL(of_find_i2c_adapter_by_node);
1057#else
1058static void of_i2c_register_devices(struct i2c_adapter *adap) { }
1059#endif /* CONFIG_OF */
1060
957static int i2c_do_add_adapter(struct i2c_driver *driver, 1061static int i2c_do_add_adapter(struct i2c_driver *driver,
958 struct i2c_adapter *adap) 1062 struct i2c_adapter *adap)
959{ 1063{
@@ -1058,6 +1162,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
1058 1162
1059exit_recovery: 1163exit_recovery:
1060 /* create pre-declared device nodes */ 1164 /* create pre-declared device nodes */
1165 of_i2c_register_devices(adap);
1166
1061 if (adap->nr < __i2c_first_dynamic_bus_num) 1167 if (adap->nr < __i2c_first_dynamic_bus_num)
1062 i2c_scan_static_board_info(adap); 1168 i2c_scan_static_board_info(adap);
1063 1169
@@ -1282,7 +1388,6 @@ void i2c_del_adapter(struct i2c_adapter *adap)
1282} 1388}
1283EXPORT_SYMBOL(i2c_del_adapter); 1389EXPORT_SYMBOL(i2c_del_adapter);
1284 1390
1285
1286/* ------------------------------------------------------------------------- */ 1391/* ------------------------------------------------------------------------- */
1287 1392
1288int i2c_for_each_dev(void *data, int (*fn)(struct device *, void *)) 1393int i2c_for_each_dev(void *data, int (*fn)(struct device *, void *))
diff --git a/drivers/i2c/i2c-mux.c b/drivers/i2c/i2c-mux.c
index 7409ebb33c47..797e3117bef7 100644
--- a/drivers/i2c/i2c-mux.c
+++ b/drivers/i2c/i2c-mux.c
@@ -25,7 +25,6 @@
25#include <linux/i2c.h> 25#include <linux/i2c.h>
26#include <linux/i2c-mux.h> 26#include <linux/i2c-mux.h>
27#include <linux/of.h> 27#include <linux/of.h>
28#include <linux/of_i2c.h>
29 28
30/* multiplexer per channel data */ 29/* multiplexer per channel data */
31struct i2c_mux_priv { 30struct i2c_mux_priv {
@@ -185,8 +184,6 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
185 dev_info(&parent->dev, "Added multiplexed i2c bus %d\n", 184 dev_info(&parent->dev, "Added multiplexed i2c bus %d\n",
186 i2c_adapter_id(&priv->adap)); 185 i2c_adapter_id(&priv->adap));
187 186
188 of_i2c_register_devices(&priv->adap);
189
190 return &priv->adap; 187 return &priv->adap;
191} 188}
192EXPORT_SYMBOL_GPL(i2c_add_mux_adapter); 189EXPORT_SYMBOL_GPL(i2c_add_mux_adapter);
diff --git a/drivers/i2c/muxes/i2c-arb-gpio-challenge.c b/drivers/i2c/muxes/i2c-arb-gpio-challenge.c
index f7bf24375f81..74b41ae690f3 100644
--- a/drivers/i2c/muxes/i2c-arb-gpio-challenge.c
+++ b/drivers/i2c/muxes/i2c-arb-gpio-challenge.c
@@ -21,7 +21,6 @@
21#include <linux/i2c-mux.h> 21#include <linux/i2c-mux.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/of_i2c.h>
25#include <linux/of_gpio.h> 24#include <linux/of_gpio.h>
26#include <linux/platform_device.h> 25#include <linux/platform_device.h>
27#include <linux/slab.h> 26#include <linux/slab.h>
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index 6a206e8d58f4..5d4a99ba743e 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -16,7 +16,6 @@
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/slab.h> 17#include <linux/slab.h>
18#include <linux/gpio.h> 18#include <linux/gpio.h>
19#include <linux/of_i2c.h>
20#include <linux/of_gpio.h> 19#include <linux/of_gpio.h>
21 20
22struct gpiomux { 21struct gpiomux {
diff --git a/drivers/i2c/muxes/i2c-mux-pinctrl.c b/drivers/i2c/muxes/i2c-mux-pinctrl.c
index 0d082027c29a..69a91732ae65 100644
--- a/drivers/i2c/muxes/i2c-mux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-mux-pinctrl.c
@@ -20,7 +20,6 @@
20#include <linux/i2c-mux.h> 20#include <linux/i2c-mux.h>
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/module.h> 22#include <linux/module.h>
23#include <linux/of_i2c.h>
24#include <linux/pinctrl/consumer.h> 23#include <linux/pinctrl/consumer.h>
25#include <linux/i2c-mux-pinctrl.h> 24#include <linux/i2c-mux-pinctrl.h>
26#include <linux/platform_device.h> 25#include <linux/platform_device.h>
diff --git a/drivers/media/platform/exynos4-is/fimc-is-i2c.c b/drivers/media/platform/exynos4-is/fimc-is-i2c.c
index 617a798d9235..993055605214 100644
--- a/drivers/media/platform/exynos4-is/fimc-is-i2c.c
+++ b/drivers/media/platform/exynos4-is/fimc-is-i2c.c
@@ -12,7 +12,7 @@
12 12
13#include <linux/clk.h> 13#include <linux/clk.h>
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/of_i2c.h> 15#include <linux/i2c.h>
16#include <linux/platform_device.h> 16#include <linux/platform_device.h>
17#include <linux/pm_runtime.h> 17#include <linux/pm_runtime.h>
18#include <linux/slab.h> 18#include <linux/slab.h>
@@ -67,8 +67,6 @@ static int fimc_is_i2c_probe(struct platform_device *pdev)
67 pm_runtime_enable(&pdev->dev); 67 pm_runtime_enable(&pdev->dev);
68 pm_runtime_enable(&i2c_adap->dev); 68 pm_runtime_enable(&i2c_adap->dev);
69 69
70 of_i2c_register_devices(i2c_adap);
71
72 return 0; 70 return 0;
73} 71}
74 72
diff --git a/drivers/media/platform/exynos4-is/fimc-is.c b/drivers/media/platform/exynos4-is/fimc-is.c
index 967f6a939340..2276fdc213c5 100644
--- a/drivers/media/platform/exynos4-is/fimc-is.c
+++ b/drivers/media/platform/exynos4-is/fimc-is.c
@@ -21,7 +21,7 @@
21#include <linux/interrupt.h> 21#include <linux/interrupt.h>
22#include <linux/kernel.h> 22#include <linux/kernel.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/of_i2c.h> 24#include <linux/i2c.h>
25#include <linux/of_irq.h> 25#include <linux/of_irq.h>
26#include <linux/of_address.h> 26#include <linux/of_address.h>
27#include <linux/of_platform.h> 27#include <linux/of_platform.h>
diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index 19f556c5957f..f8c66b434fd6 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -20,7 +20,6 @@
20#include <linux/of.h> 20#include <linux/of.h>
21#include <linux/of_platform.h> 21#include <linux/of_platform.h>
22#include <linux/of_device.h> 22#include <linux/of_device.h>
23#include <linux/of_i2c.h>
24#include <linux/platform_device.h> 23#include <linux/platform_device.h>
25#include <linux/pm_runtime.h> 24#include <linux/pm_runtime.h>
26#include <linux/types.h> 25#include <linux/types.h>
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig
index 80e5c13b930d..78cc76053328 100644
--- a/drivers/of/Kconfig
+++ b/drivers/of/Kconfig
@@ -48,12 +48,6 @@ config OF_IRQ
48 def_bool y 48 def_bool y
49 depends on !SPARC 49 depends on !SPARC
50 50
51config OF_I2C
52 def_tristate I2C
53 depends on I2C
54 help
55 OpenFirmware I2C accessors
56
57config OF_NET 51config OF_NET
58 depends on NETDEVICES 52 depends on NETDEVICES
59 def_bool y 53 def_bool y
diff --git a/drivers/of/Makefile b/drivers/of/Makefile
index 1f9c0c492ef9..efd05102c405 100644
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
@@ -3,7 +3,6 @@ obj-$(CONFIG_OF_FLATTREE) += fdt.o
3obj-$(CONFIG_OF_PROMTREE) += pdt.o 3obj-$(CONFIG_OF_PROMTREE) += pdt.o
4obj-$(CONFIG_OF_ADDRESS) += address.o 4obj-$(CONFIG_OF_ADDRESS) += address.o
5obj-$(CONFIG_OF_IRQ) += irq.o 5obj-$(CONFIG_OF_IRQ) += irq.o
6obj-$(CONFIG_OF_I2C) += of_i2c.o
7obj-$(CONFIG_OF_NET) += of_net.o 6obj-$(CONFIG_OF_NET) += of_net.o
8obj-$(CONFIG_OF_SELFTEST) += selftest.o 7obj-$(CONFIG_OF_SELFTEST) += selftest.o
9obj-$(CONFIG_OF_MDIO) += of_mdio.o 8obj-$(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 b667264222cc..000000000000
--- a/drivers/of/of_i2c.c
+++ /dev/null
@@ -1,114 +0,0 @@
1/*
2 * OF helpers for the I2C API
3 *
4 * Copyright (c) 2008 Jochen Friedrich <jochen@scram.de>
5 *
6 * Based on a previous patch from Jon Smirl <jonsmirl@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 */
13
14#include <linux/i2c.h>
15#include <linux/irq.h>
16#include <linux/of.h>
17#include <linux/of_i2c.h>
18#include <linux/of_irq.h>
19#include <linux/module.h>
20
21void of_i2c_register_devices(struct i2c_adapter *adap)
22{
23 void *result;
24 struct device_node *node;
25
26 /* Only register child devices if the adapter has a node pointer set */
27 if (!adap->dev.of_node)
28 return;
29
30 dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
31
32 for_each_available_child_of_node(adap->dev.of_node, node) {
33 struct i2c_board_info info = {};
34 struct dev_archdata dev_ad = {};
35 const __be32 *addr;
36 int len;
37
38 dev_dbg(&adap->dev, "of_i2c: register %s\n", node->full_name);
39
40 if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
41 dev_err(&adap->dev, "of_i2c: modalias failure on %s\n",
42 node->full_name);
43 continue;
44 }
45
46 addr = of_get_property(node, "reg", &len);
47 if (!addr || (len < sizeof(int))) {
48 dev_err(&adap->dev, "of_i2c: invalid reg on %s\n",
49 node->full_name);
50 continue;
51 }
52
53 info.addr = be32_to_cpup(addr);
54 if (info.addr > (1 << 10) - 1) {
55 dev_err(&adap->dev, "of_i2c: invalid addr=%x on %s\n",
56 info.addr, node->full_name);
57 continue;
58 }
59
60 info.irq = irq_of_parse_and_map(node, 0);
61 info.of_node = of_node_get(node);
62 info.archdata = &dev_ad;
63
64 if (of_get_property(node, "wakeup-source", NULL))
65 info.flags |= I2C_CLIENT_WAKE;
66
67 request_module("%s%s", I2C_MODULE_PREFIX, info.type);
68
69 result = i2c_new_device(adap, &info);
70 if (result == NULL) {
71 dev_err(&adap->dev, "of_i2c: Failure registering %s\n",
72 node->full_name);
73 of_node_put(node);
74 irq_dispose_mapping(info.irq);
75 continue;
76 }
77 }
78}
79EXPORT_SYMBOL(of_i2c_register_devices);
80
81static int of_dev_node_match(struct device *dev, void *data)
82{
83 return dev->of_node == data;
84}
85
86/* must call put_device() when done with returned i2c_client device */
87struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
88{
89 struct device *dev;
90
91 dev = bus_find_device(&i2c_bus_type, NULL, node,
92 of_dev_node_match);
93 if (!dev)
94 return NULL;
95
96 return i2c_verify_client(dev);
97}
98EXPORT_SYMBOL(of_find_i2c_device_by_node);
99
100/* must call put_device() when done with returned i2c_adapter device */
101struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
102{
103 struct device *dev;
104
105 dev = bus_find_device(&i2c_bus_type, NULL, node,
106 of_dev_node_match);
107 if (!dev)
108 return NULL;
109
110 return i2c_verify_adapter(dev);
111}
112EXPORT_SYMBOL(of_find_i2c_adapter_by_node);
113
114MODULE_LICENSE("GPL");
diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c
index a56797d88edc..2d76fd47c3d7 100644
--- a/drivers/staging/imx-drm/imx-tve.c
+++ b/drivers/staging/imx-drm/imx-tve.c
@@ -21,7 +21,7 @@
21#include <linux/clk.h> 21#include <linux/clk.h>
22#include <linux/clk-provider.h> 22#include <linux/clk-provider.h>
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/of_i2c.h> 24#include <linux/i2c.h>
25#include <linux/regmap.h> 25#include <linux/regmap.h>
26#include <linux/regulator/consumer.h> 26#include <linux/regulator/consumer.h>
27#include <linux/spinlock.h> 27#include <linux/spinlock.h>