]> Pileus Git - ~andy/linux/commitdiff
i2c: move OF helpers into the core
authorWolfram Sang <wsa@the-dreams.de>
Thu, 11 Jul 2013 11:56:15 +0000 (12:56 +0100)
committerWolfram Sang <wsa@the-dreams.de>
Fri, 23 Aug 2013 08:22:20 +0000 (10:22 +0200)
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>
47 files changed:
Documentation/acpi/enumeration.txt
arch/powerpc/platforms/44x/warp.c
drivers/gpu/drm/tilcdc/tilcdc_slave.c
drivers/gpu/drm/tilcdc/tilcdc_tfp410.c
drivers/gpu/host1x/drm/output.c
drivers/i2c/busses/i2c-at91.c
drivers/i2c/busses/i2c-cpm.c
drivers/i2c/busses/i2c-davinci.c
drivers/i2c/busses/i2c-designware-platdrv.c
drivers/i2c/busses/i2c-gpio.c
drivers/i2c/busses/i2c-i801.c
drivers/i2c/busses/i2c-ibm_iic.c
drivers/i2c/busses/i2c-imx.c
drivers/i2c/busses/i2c-mpc.c
drivers/i2c/busses/i2c-mv64xxx.c
drivers/i2c/busses/i2c-mxs.c
drivers/i2c/busses/i2c-nomadik.c
drivers/i2c/busses/i2c-ocores.c
drivers/i2c/busses/i2c-octeon.c
drivers/i2c/busses/i2c-omap.c
drivers/i2c/busses/i2c-pnx.c
drivers/i2c/busses/i2c-powermac.c
drivers/i2c/busses/i2c-pxa.c
drivers/i2c/busses/i2c-s3c2410.c
drivers/i2c/busses/i2c-sh_mobile.c
drivers/i2c/busses/i2c-sirf.c
drivers/i2c/busses/i2c-stu300.c
drivers/i2c/busses/i2c-tegra.c
drivers/i2c/busses/i2c-versatile.c
drivers/i2c/busses/i2c-wmt.c
drivers/i2c/busses/i2c-xiic.c
drivers/i2c/i2c-core.c
drivers/i2c/i2c-mux.c
drivers/i2c/muxes/i2c-arb-gpio-challenge.c
drivers/i2c/muxes/i2c-mux-gpio.c
drivers/i2c/muxes/i2c-mux-pinctrl.c
drivers/media/platform/exynos4-is/fimc-is-i2c.c
drivers/media/platform/exynos4-is/fimc-is.c
drivers/media/platform/exynos4-is/media-dev.c
drivers/of/Kconfig
drivers/of/Makefile
drivers/of/of_i2c.c [deleted file]
drivers/staging/imx-drm/imx-tve.c
include/linux/i2c.h
include/linux/of_i2c.h [deleted file]
sound/soc/fsl/imx-sgtl5000.c
sound/soc/fsl/imx-wm8962.c

index d9be7a97dff35e7b1521e709e8a29c278d3fb434..958266efcc20933b2876b087fc336d43ea950999 100644 (file)
@@ -238,7 +238,6 @@ An I2C bus (controller) driver does:
        if (ret)
                /* handle error */
 
-       of_i2c_register_devices(adapter);
        /* Enumerate the slave devices behind this bus via ACPI */
        acpi_i2c_register_devices(adapter);
 
index 4cfa49901c023f069828c5b8f50a1b5028cf69bf..534574a97ec906d72e9f15fde252dac5a36ca514 100644 (file)
@@ -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 <linux/export.h>
 
index dfffaf01402225b20bbbcefd97b264cad040ce28..a19f657dfa59f0efe70ea33df0bf85f82af00f0d 100644 (file)
@@ -16,7 +16,6 @@
  */
 
 #include <linux/i2c.h>
-#include <linux/of_i2c.h>
 #include <linux/pinctrl/pinmux.h>
 #include <linux/pinctrl/consumer.h>
 #include <drm/drm_encoder_slave.h>
index 925c7cddeff9a16e44bb99273e8ff84f784e8b62..c38b56b268ac0d8ba61a8826d13ad435f9f59fb7 100644 (file)
@@ -16,7 +16,6 @@
  */
 
 #include <linux/i2c.h>
-#include <linux/of_i2c.h>
 #include <linux/gpio.h>
 #include <linux/of_gpio.h>
 #include <linux/pinctrl/pinmux.h>
index 8140fc6c34d85be1d360f54e9655ba8cdf5bab4a..137ae81ab80eb164d139742b16996bca8b8922b5 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <linux/module.h>
 #include <linux/of_gpio.h>
-#include <linux/of_i2c.h>
+#include <linux/i2c.h>
 
 #include "drm.h"
 
index 6bb839b688be4f17dd0b435f46bf483e054d2071..fd059308affa2985e64142756c9176f356f0d744 100644 (file)
@@ -28,7 +28,6 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include <linux/of_i2c.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/platform_data/dma-atmel.h>
@@ -775,8 +774,6 @@ static int at91_twi_probe(struct platform_device *pdev)
                return rc;
        }
 
-       of_i2c_register_devices(&dev->adapter);
-
        dev_info(dev->dev, "AT91 i2c bus driver.\n");
        return 0;
 }
index 2e1f7eb55bf4a6f6d525db8548928daa39cbd1f2..b2b8aa9adc0ef24bafd93fb6c07679463d14c212 100644 (file)
@@ -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>
 
@@ -681,11 +680,6 @@ static int 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);
index cf90bfff9676138e3da1026dbeb9e678c87d50f9..57473415be10b3654fa1bbbbd30215082a01a9ba 100644 (file)
@@ -38,7 +38,6 @@
 #include <linux/slab.h>
 #include <linux/cpufreq.h>
 #include <linux/gpio.h>
-#include <linux/of_i2c.h>
 #include <linux/of_device.h>
 #include <linux/platform_data/i2c-davinci.h>
 
@@ -726,7 +725,6 @@ static int davinci_i2c_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "failure adding adapter\n");
                goto err_unuse_clocks;
        }
-       of_i2c_register_devices(adap);
 
        return 0;
 
index 64ffb908641cafad0bce655ce922247640577254..ded77c3bd59ca20502a2a08dec91ad120323cb7f 100644 (file)
@@ -35,7 +35,6 @@
 #include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/of.h>
-#include <linux/of_i2c.h>
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 #include <linux/pm_runtime.h>
@@ -172,7 +171,6 @@ static int dw_i2c_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "failure adding adapter\n");
                return r;
        }
-       of_i2c_register_devices(adap);
        acpi_i2c_register_devices(adap);
 
        pm_runtime_set_autosuspend_delay(&pdev->dev, 1000);
index 8cdb4f743e19882b31e783d81643055a4babe0c8..bfa02c6c2ddaf01b03a9a5121c2ddcf122f9a3e2 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/platform_device.h>
 #include <linux/gpio.h>
 #include <linux/of_gpio.h>
-#include <linux/of_i2c.h>
 
 struct i2c_gpio_private_data {
        struct i2c_adapter adap;
@@ -224,8 +223,6 @@ static int i2c_gpio_probe(struct platform_device *pdev)
        if (ret)
                goto err_add_bus;
 
-       of_i2c_register_devices(adap);
-
        platform_set_drvdata(pdev, priv);
 
        dev_info(&pdev->dev, "using pins %u (SDA) and %u (SCL%s)\n",
index 4ebceed6bc6612dbbc50bd62a8e91ef97615b66d..4296d1721272bd3fa077944a63e5708000b6a4dd 100644 (file)
@@ -87,7 +87,6 @@
 #include <linux/slab.h>
 #include <linux/wait.h>
 #include <linux/err.h>
-#include <linux/of_i2c.h>
 
 #if (defined CONFIG_I2C_MUX_GPIO || defined CONFIG_I2C_MUX_GPIO_MODULE) && \
                defined CONFIG_DMI
@@ -1230,7 +1229,6 @@ static int i801_probe(struct pci_dev *dev, const struct pci_device_id *id)
                goto exit_free_irq;
        }
 
-       of_i2c_register_devices(&priv->adapter);
        i801_probe_optional_slaves(priv);
        /* We ignore errors - multiplexing is optional */
        i801_add_mux(priv);
index 973f51688276cd160de29d6483e1376a3c29ea44..ff3caa0c28cdb171e8bace863f8357617485c79c 100644 (file)
@@ -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 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:
index a231d2fd91ce5d8406c8eb4ab021461e482531c0..ccf46656bdad9182e2d75d6c1f3dbf42ea0c32c6 100644 (file)
@@ -52,7 +52,6 @@
 #include <linux/slab.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include <linux/of_i2c.h>
 #include <linux/platform_data/i2c-imx.h>
 
 /** Defines ********************************************************************
@@ -682,8 +681,6 @@ static int __init i2c_imx_probe(struct platform_device *pdev)
                return ret;
        }
 
-       of_i2c_register_devices(&i2c_imx->adapter);
-
        /* Set up platform driver data */
        platform_set_drvdata(pdev, i2c_imx);
        clk_disable_unprepare(i2c_imx->clk);
index ffac2145b94afc4d300787d81a24e5020dc4e7ec..f4060939e9593874e743a1406aa1d51f097984dd 100644 (file)
@@ -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>
@@ -694,7 +693,6 @@ static int 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;
 
index bc60f9ac7c04c01ad27f9b4ed13f7ee6c2c86480..7f3a4744349476f941a4500c9edc6a65a6da0fe2 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/of_irq.h>
-#include <linux/of_i2c.h>
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/delay.h>
@@ -871,8 +870,6 @@ mv64xxx_i2c_probe(struct platform_device *pd)
                goto exit_free_irq;
        }
 
-       of_i2c_register_devices(&drv_data->adapter);
-
        return 0;
 
 exit_free_irq:
index 46cda0b02fd1e16f42cff7e20c4bc31d5aed3abe..f4a01675fa71b4a18ac2b35714425be363442528 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/stmp_device.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include <linux/of_i2c.h>
 #include <linux/dma-mapping.h>
 #include <linux/dmaengine.h>
 
@@ -752,8 +751,6 @@ static int mxs_i2c_probe(struct platform_device *pdev)
                return err;
        }
 
-       of_i2c_register_devices(adap);
-
        return 0;
 }
 
index 1909e80735416ae2aa41b8cf285ccf7956855ea3..8bf9ac01301a5cb6fb2042808f3fdc23b3e5002b 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/pm_runtime.h>
 #include <linux/platform_data/i2c-nomadik.h>
 #include <linux/of.h>
-#include <linux/of_i2c.h>
 #include <linux/pinctrl/consumer.h>
 
 #define DRIVER_NAME "nmk-i2c"
@@ -1045,8 +1044,6 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
                goto err_add_adap;
        }
 
-       of_i2c_register_devices(adap);
-
        pm_runtime_put(&adev->dev);
 
        return 0;
index e14182cd87ffeea016d9c36cd87b6ae8e4430a76..c61f37a10a074e30f2c3c1e368a602a85e7301b9 100644 (file)
@@ -24,7 +24,6 @@
 #include <linux/i2c-ocores.h>
 #include <linux/slab.h>
 #include <linux/io.h>
-#include <linux/of_i2c.h>
 #include <linux/log2.h>
 
 struct ocores_i2c {
@@ -432,8 +431,6 @@ static int ocores_i2c_probe(struct platform_device *pdev)
        if (pdata) {
                for (i = 0; i < pdata->num_devices; i++)
                        i2c_new_device(&i2c->adap, pdata->devices + i);
-       } else {
-               of_i2c_register_devices(&i2c->adap);
        }
 
        return 0;
index 956fe320f313d84c4a0371c32d858192ad7742f1..b929ba271b4705714f846fa07aae3d9116fcada3 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/of_i2c.h>
 #include <linux/delay.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
@@ -599,8 +598,6 @@ static int octeon_i2c_probe(struct platform_device *pdev)
        }
        dev_info(i2c->dev, "version %s\n", DRV_VERSION);
 
-       of_i2c_register_devices(&i2c->adap);
-
        return 0;
 
 out:
index 9ccb7b9cb6fcab329551907078ffe780d38f7dd8..6d8308d5dc4e915c4584e2d5d9b3e5690882a2b9 100644 (file)
@@ -38,7 +38,6 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/of.h>
-#include <linux/of_i2c.h>
 #include <linux/of_device.h>
 #include <linux/slab.h>
 #include <linux/i2c-omap.h>
@@ -1231,8 +1230,6 @@ omap_i2c_probe(struct platform_device *pdev)
        dev_info(dev->dev, "bus %d rev%d.%d at %d kHz\n", adap->nr,
                 major, minor, dev->speed);
 
-       of_i2c_register_devices(adap);
-
        pm_runtime_mark_last_busy(dev->dev);
        pm_runtime_put_autosuspend(dev->dev);
 
index 1713b3ee61f55306b4995d6b16c4022fdebd14ec..d09577a05d00a6fa6e5eefc0b98c1b07d2efafc9 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/slab.h>
-#include <linux/of_i2c.h>
 
 #define I2C_PNX_TIMEOUT_DEFAULT                10 /* msec */
 #define I2C_PNX_SPEED_KHZ_DEFAULT      100
@@ -741,8 +740,6 @@ static int i2c_pnx_probe(struct platform_device *pdev)
                goto out_irq;
        }
 
-       of_i2c_register_devices(&alg_data->adapter);
-
        dev_dbg(&pdev->dev, "%s: Master at %#8x, irq %d.\n",
                alg_data->adapter.name, res->start, alg_data->irq);
 
index 06858d576552bf354c914f11247038301f505235..37e8cfad625b9c87101d7dd9916d5cb7787d84ae 100644 (file)
@@ -440,7 +440,9 @@ static int i2c_powermac_probe(struct platform_device *dev)
        adapter->algo = &i2c_powermac_algorithm;
        i2c_set_adapdata(adapter, bus);
        adapter->dev.parent = &dev->dev;
-       adapter->dev.of_node = dev->dev.of_node;
+
+       /* Clear of_node to skip automatic registration of i2c child nodes */
+       adapter->dev.of_node = NULL;
        rc = i2c_add_adapter(adapter);
        if (rc) {
                printk(KERN_ERR "i2c-powermac: Adapter %s registration "
@@ -451,9 +453,8 @@ static int i2c_powermac_probe(struct platform_device *dev)
 
        printk(KERN_INFO "PowerMac i2c bus %s registered\n", adapter->name);
 
-       /* Cannot use of_i2c_register_devices() due to Apple device-tree
-        * funkyness
-        */
+       /* Use custom child registration due to Apple device-tree funkyness */
+       adapter->dev.of_node = dev->dev.of_node;
        i2c_powermac_register_devices(adapter, bus);
 
        return 0;
index 3dbc1acdc28a6dacf669aee1b7d6710c8ea1c018..bbe6dfbc5c05da4917ad0d295f2c32659ce29dfc 100644 (file)
@@ -31,7 +31,6 @@
 #include <linux/i2c-pxa.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include <linux/of_i2c.h>
 #include <linux/platform_device.h>
 #include <linux/err.h>
 #include <linux/clk.h>
@@ -1247,7 +1246,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);
 
index 0a077b1ef94f687c4150561ab3d353532858cec2..3535f3c0f7b43233b09123c89b4727fc302cba3b 100644 (file)
@@ -36,7 +36,6 @@
 #include <linux/cpufreq.h>
 #include <linux/slab.h>
 #include <linux/io.h>
-#include <linux/of_i2c.h>
 #include <linux/of_gpio.h>
 #include <linux/pinctrl/consumer.h>
 
@@ -1154,7 +1153,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev)
                return ret;
        }
 
-       of_i2c_register_devices(&i2c->adap);
        platform_set_drvdata(pdev, i2c);
 
        pm_runtime_enable(&pdev->dev);
index 4e86a3190d46bfef45ca6cac99a9614c79ecc104..55110ddbed1ff4163d48acf20da36b58e2ee2e43 100644 (file)
@@ -27,7 +27,6 @@
 #include <linux/platform_device.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
-#include <linux/of_i2c.h>
 #include <linux/err.h>
 #include <linux/pm_runtime.h>
 #include <linux/clk.h>
@@ -758,7 +757,6 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
                 "I2C adapter %d with bus speed %lu Hz (L/H=%x/%x)\n",
                 adap->nr, pd->bus_speed, pd->iccl, pd->icch);
 
-       of_i2c_register_devices(adap);
        return 0;
 
  err_all:
index a63c7d50683676f5e01969573ffce373b3ce578f..0ff22e29e7df5477fcbd2b5a094d4edbc03c85b5 100644 (file)
@@ -12,7 +12,6 @@
 #include <linux/slab.h>
 #include <linux/platform_device.h>
 #include <linux/i2c.h>
-#include <linux/of_i2c.h>
 #include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/io.h>
@@ -366,8 +365,6 @@ static int i2c_sirfsoc_probe(struct platform_device *pdev)
 
        clk_disable(clk);
 
-       of_i2c_register_devices(adap);
-
        dev_info(&pdev->dev, " I2C adapter ready to operate\n");
 
        return 0;
index 19a40afaf1728952b5c432736d8f15195831f79b..f8f6f2e552db29e344b41f4e42d0cbc1ac9fc000 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/slab.h>
-#include <linux/of_i2c.h>
 
 /* the name of this kernel module */
 #define NAME "stu300"
@@ -933,7 +932,6 @@ stu300_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, dev);
        dev_info(&pdev->dev, "ST DDC I2C @ %p, irq %d\n",
                 dev->virtbase, dev->irq);
-       of_i2c_register_devices(adap);
 
        return 0;
 }
index 9aa1b60f7fdd86581e2f694d96a2834e0ecad055..c457cb447c66bdf51911339853b561c273c06082 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
-#include <linux/of_i2c.h>
 #include <linux/of_device.h>
 #include <linux/module.h>
 #include <linux/clk/tegra.h>
@@ -802,8 +801,6 @@ static int tegra_i2c_probe(struct platform_device *pdev)
                return ret;
        }
 
-       of_i2c_register_devices(&i2c_dev->adapter);
-
        return 0;
 }
 
index f3a8790a07e8fed578c3665c85ab9c085a6101dd..6bb3a89a440f09484082b66fd4b68bda6d439ff7 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/io.h>
-#include <linux/of_i2c.h>
 
 #define I2C_CONTROL    0x00
 #define I2C_CONTROLS   0x00
@@ -108,7 +107,6 @@ static int i2c_versatile_probe(struct platform_device *dev)
        ret = i2c_bit_add_numbered_bus(&i2c->adap);
        if (ret >= 0) {
                platform_set_drvdata(dev, i2c);
-               of_i2c_register_devices(&i2c->adap);
                return 0;
        }
 
index baaa7d15b73e03b265617e276ef8733a68159d8b..c65da3d913a03d11ed13d62c17d7dffb3fb097bf 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
-#include <linux/of_i2c.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
 
@@ -439,8 +438,6 @@ static int wmt_i2c_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, i2c_dev);
 
-       of_i2c_register_devices(adap);
-
        return 0;
 }
 
index 433f377b3869f846b32a80b854c81c88d23ab9cb..4c8b368d463b7c77517fb3ed314e4234bd6dafbc 100644 (file)
@@ -40,7 +40,6 @@
 #include <linux/i2c-xiic.h>
 #include <linux/io.h>
 #include <linux/slab.h>
-#include <linux/of_i2c.h>
 
 #define DRIVER_NAME "xiic-i2c"
 
@@ -752,8 +751,6 @@ static int xiic_i2c_probe(struct platform_device *pdev)
                        i2c_new_device(&i2c->adap, pdata->devices + i);
        }
 
-       of_i2c_register_devices(&i2c->adap);
-
        return 0;
 
 add_adapter_failed:
index 3d9ca2d3d77ec1a876fdb95021f97a521fb0e279..e874b052b4f85eaca1896f2b256a281a8ea60e47 100644 (file)
    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 is copyright (c) 2008 Jochen Friedrich <jochen@scram.de>
+   (based on a previous patch from Jon Smirl <jonsmirl@gmail.com>) and
+   (c) 2013  Wolfram Sang <wsa@the-dreams.de>
+ */
 
 #include <linux/module.h>
 #include <linux/kernel.h>
@@ -35,7 +39,9 @@
 #include <linux/init.h>
 #include <linux/idr.h>
 #include <linux/mutex.h>
+#include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/of_irq.h>
 #include <linux/completion.h>
 #include <linux/hardirq.h>
 #include <linux/irqflags.h>
@@ -954,6 +960,104 @@ static void i2c_scan_static_board_info(struct i2c_adapter *adapter)
        up_read(&__i2c_board_lock);
 }
 
+/* OF support code */
+
+#if IS_ENABLED(CONFIG_OF)
+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_available_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;
+
+               if (of_get_property(node, "wakeup-source", NULL))
+                       info.flags |= I2C_CLIENT_WAKE;
+
+               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 i2c_verify_client(dev);
+}
+EXPORT_SYMBOL(of_find_i2c_device_by_node);
+
+/* must call put_device() when done with returned i2c_adapter device */
+struct i2c_adapter *of_find_i2c_adapter_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 i2c_verify_adapter(dev);
+}
+EXPORT_SYMBOL(of_find_i2c_adapter_by_node);
+#else
+static void of_i2c_register_devices(struct i2c_adapter *adap) { }
+#endif /* CONFIG_OF */
+
 static int i2c_do_add_adapter(struct i2c_driver *driver,
                              struct i2c_adapter *adap)
 {
@@ -1058,6 +1162,8 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
 
 exit_recovery:
        /* create pre-declared device nodes */
+       of_i2c_register_devices(adap);
+
        if (adap->nr < __i2c_first_dynamic_bus_num)
                i2c_scan_static_board_info(adap);
 
@@ -1282,7 +1388,6 @@ void i2c_del_adapter(struct i2c_adapter *adap)
 }
 EXPORT_SYMBOL(i2c_del_adapter);
 
-
 /* ------------------------------------------------------------------------- */
 
 int i2c_for_each_dev(void *data, int (*fn)(struct device *, void *))
index 7409ebb33c47df7166087f937d0d5eb91d9d70c9..797e3117bef7437ef2d6f734431a16e43acaed34 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/i2c.h>
 #include <linux/i2c-mux.h>
 #include <linux/of.h>
-#include <linux/of_i2c.h>
 
 /* multiplexer per channel data */
 struct i2c_mux_priv {
@@ -185,8 +184,6 @@ struct i2c_adapter *i2c_add_mux_adapter(struct i2c_adapter *parent,
        dev_info(&parent->dev, "Added multiplexed i2c bus %d\n",
                 i2c_adapter_id(&priv->adap));
 
-       of_i2c_register_devices(&priv->adap);
-
        return &priv->adap;
 }
 EXPORT_SYMBOL_GPL(i2c_add_mux_adapter);
index f7bf24375f81c004768d47651352cb6a91eec5e2..74b41ae690f3e6dab7271319ed62c436ac30935a 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/i2c-mux.h>
 #include <linux/init.h>
 #include <linux/module.h>
-#include <linux/of_i2c.h>
 #include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
index 6a206e8d58f4e3f2985a00e287ea7a5103a86024..5d4a99ba743e39b21a9483ce2a15aabb41a84934 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/gpio.h>
-#include <linux/of_i2c.h>
 #include <linux/of_gpio.h>
 
 struct gpiomux {
index 0d082027c29afa31c1f6bb0a0ab6f768f99d91a8..69a91732ae6561560ca6286007a10602e0e09ba4 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/i2c-mux.h>
 #include <linux/init.h>
 #include <linux/module.h>
-#include <linux/of_i2c.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/i2c-mux-pinctrl.h>
 #include <linux/platform_device.h>
index 617a798d92352e30e5342253f5fcc83aa6b18a5c..9930556052141cdc6f3a0b60da7945ba9de3b7bd 100644 (file)
@@ -12,7 +12,7 @@
 
 #include <linux/clk.h>
 #include <linux/module.h>
-#include <linux/of_i2c.h>
+#include <linux/i2c.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/slab.h>
@@ -67,8 +67,6 @@ static int fimc_is_i2c_probe(struct platform_device *pdev)
        pm_runtime_enable(&pdev->dev);
        pm_runtime_enable(&i2c_adap->dev);
 
-       of_i2c_register_devices(i2c_adap);
-
        return 0;
 }
 
index 967f6a939340ea7ace2eb8826703bf713be4cd9d..2276fdc213c53dd128edb6e0f7b37b28d8654b16 100644 (file)
@@ -21,7 +21,7 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
-#include <linux/of_i2c.h>
+#include <linux/i2c.h>
 #include <linux/of_irq.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
index 19f556c5957f5661bbc5b5ccb35575d6e01b97a6..f8c66b434fd612f89b42b7d8c51cd7edb4f71d15 100644 (file)
@@ -20,7 +20,6 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/of_device.h>
-#include <linux/of_i2c.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/types.h>
index 80e5c13b930de507424d4549e2e968636a58bbaa..78cc76053328c2c8c70bff559f5dc0f903a241df 100644 (file)
@@ -48,12 +48,6 @@ config OF_IRQ
        def_bool y
        depends on !SPARC
 
-config OF_I2C
-       def_tristate I2C
-       depends on I2C
-       help
-         OpenFirmware I2C accessors
-
 config OF_NET
        depends on NETDEVICES
        def_bool y
index 1f9c0c492ef9f57b3e39a71db1dd551ad7b55bf1..efd05102c40533100794b7d6a7626f583a1f0cdc 100644 (file)
@@ -3,7 +3,6 @@ obj-$(CONFIG_OF_FLATTREE) += fdt.o
 obj-$(CONFIG_OF_PROMTREE) += pdt.o
 obj-$(CONFIG_OF_ADDRESS)  += address.o
 obj-$(CONFIG_OF_IRQ)    += irq.o
-obj-$(CONFIG_OF_I2C)   += of_i2c.o
 obj-$(CONFIG_OF_NET)   += of_net.o
 obj-$(CONFIG_OF_SELFTEST) += selftest.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 (file)
index b667264..0000000
+++ /dev/null
@@ -1,114 +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_available_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;
-
-               if (of_get_property(node, "wakeup-source", NULL))
-                       info.flags |= I2C_CLIENT_WAKE;
-
-               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 i2c_verify_client(dev);
-}
-EXPORT_SYMBOL(of_find_i2c_device_by_node);
-
-/* must call put_device() when done with returned i2c_adapter device */
-struct i2c_adapter *of_find_i2c_adapter_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 i2c_verify_adapter(dev);
-}
-EXPORT_SYMBOL(of_find_i2c_adapter_by_node);
-
-MODULE_LICENSE("GPL");
index a56797d88edcdc85056dfed0b83f31811ed24cf4..2d76fd47c3d7ef9c7007dff91444739f33c358bb 100644 (file)
@@ -21,7 +21,7 @@
 #include <linux/clk.h>
 #include <linux/clk-provider.h>
 #include <linux/module.h>
-#include <linux/of_i2c.h>
+#include <linux/i2c.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
 #include <linux/spinlock.h>
index b3c4b8dac1ceb70d2a9d434314f9ad2a5d957183..ed53696e31a67d83f52f4477a1d004b459531a9e 100644 (file)
@@ -544,6 +544,26 @@ static inline int i2c_adapter_id(struct i2c_adapter *adap)
 
 #endif /* I2C */
 
+#if IS_ENABLED(CONFIG_OF)
+/* 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);
+
+/* must call put_device() when done with returned i2c_adapter device */
+extern struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node);
+
+#else
+
+static inline struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
+{
+       return NULL;
+}
+
+static inline struct i2c_adapter *of_find_i2c_adapter_by_node(struct device_node *node)
+{
+       return NULL;
+}
+#endif /* CONFIG_OF */
+
 #if IS_ENABLED(CONFIG_ACPI_I2C)
 extern void acpi_i2c_register_devices(struct i2c_adapter *adap);
 #else
diff --git a/include/linux/of_i2c.h b/include/linux/of_i2c.h
deleted file mode 100644 (file)
index cfb545c..0000000
+++ /dev/null
@@ -1,46 +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);
-
-/* must call put_device() when done with returned i2c_adapter device */
-extern struct i2c_adapter *of_find_i2c_adapter_by_node(
-                                               struct device_node *node);
-
-#else
-static inline void of_i2c_register_devices(struct i2c_adapter *adap)
-{
-       return;
-}
-
-static inline struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
-{
-       return NULL;
-}
-
-/* must call put_device() when done with returned i2c_adapter device */
-static inline struct i2c_adapter *of_find_i2c_adapter_by_node(
-                                               struct device_node *node)
-{
-       return NULL;
-}
-#endif /* CONFIG_OF_I2C */
-
-#endif /* __LINUX_OF_I2C_H */
index 3f726e4f88db8c2900840819e5d86ede5e9415d1..f2fbde9c3d4cd07e8ec7195a99e4fee0e722ef52 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
-#include <linux/of_i2c.h>
+#include <linux/i2c.h>
 #include <linux/clk.h>
 #include <sound/soc.h>
 
index 52a36a90f4f4eb19c4739fda1714f48e715d1c68..9fd7a65ae83b3fd9125e279420f2fc4149749ae3 100644 (file)
@@ -15,7 +15,7 @@
 
 #include <linux/module.h>
 #include <linux/of_platform.h>
-#include <linux/of_i2c.h>
+#include <linux/i2c.h>
 #include <linux/slab.h>
 #include <linux/clk.h>
 #include <sound/soc.h>