]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
[POWERPC] i2c: Fix build breakage introduced by OF helpers
authorJochen Friedrich <jochen@scram.de>
Fri, 18 Apr 2008 14:23:03 +0000 (00:23 +1000)
committerPaul Mackerras <paulus@samba.org>
Sun, 20 Apr 2008 03:03:35 +0000 (13:03 +1000)
Fix build breakage introduced in commit "[POWERPC] i2c: OF helpers for
the i2c API".  If i2c-core is compiled as a module, the helper needs
to be compiled as a module, as well.  Rename i2c.c to of_i2c.c to
avoid name space conflict.

[paulus@samba.org: Changed dependency from OF to PPC_OF to avoid
sparc{32,64} allmodconfig breakage.]

Signed-off-by: Jochen Friedrich <jochen@scram.de>
Signed-off-by: Paul Mackerras <paulus@samba.org>
drivers/of/Kconfig
drivers/of/Makefile
drivers/of/i2c.c [deleted file]
drivers/of/of_i2c.c [new file with mode: 0644]

index 7c305317f372fb7edb5986a51b86ba5fd41d0667..3a7a11a75fb464017ce284d34a41388f2875dd15 100644 (file)
@@ -9,7 +9,7 @@ config OF_GPIO
          OpenFirmware GPIO accessors
 
 config OF_I2C
-       def_bool y
-       depends on OF && I2C
+       def_tristate I2C
+       depends on PPC_OF && I2C
        help
          OpenFirmware I2C accessors
index a07b95362c5387b2f24e76014a7077c1e07017a9..548772e871fd8e52a1ed66156fc0c129e84660af 100644 (file)
@@ -1,4 +1,4 @@
 obj-y = base.o
 obj-$(CONFIG_OF_DEVICE) += device.o platform.o
 obj-$(CONFIG_OF_GPIO)   += gpio.o
-obj-$(CONFIG_OF_I2C)   += i2c.o
+obj-$(CONFIG_OF_I2C)   += of_i2c.o
diff --git a/drivers/of/i2c.c b/drivers/of/i2c.c
deleted file mode 100644 (file)
index 6316891..0000000
+++ /dev/null
@@ -1,115 +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/of.h>
-
-struct i2c_driver_device {
-       char    *of_device;
-       char    *i2c_type;
-};
-
-static struct i2c_driver_device i2c_devices[] = {
-       { "dallas,ds1374", "rtc-ds1374" },
-};
-
-static int of_find_i2c_driver(struct device_node *node,
-                             struct i2c_board_info *info)
-{
-       int i, cplen;
-       const char *compatible;
-       const char *p;
-
-       /* 1. search for exception list entry */
-       for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
-               if (!of_device_is_compatible(node, i2c_devices[i].of_device))
-                       continue;
-               if (strlcpy(info->type, i2c_devices[i].i2c_type,
-                           I2C_NAME_SIZE) >= I2C_NAME_SIZE)
-                       return -ENOMEM;
-
-               return 0;
-       }
-
-       compatible = of_get_property(node, "compatible", &cplen);
-       if (!compatible)
-               return -ENODEV;
-
-       /* 2. search for linux,<i2c-type> entry */
-       p = compatible;
-       while (cplen > 0) {
-               if (!strncmp(p, "linux,", 6)) {
-                       p += 6;
-                       if (strlcpy(info->type, p,
-                                   I2C_NAME_SIZE) >= I2C_NAME_SIZE)
-                               return -ENOMEM;
-                       return 0;
-               }
-
-               i = strlen(p) + 1;
-               p += i;
-               cplen -= i;
-       }
-
-       /* 3. take fist compatible entry and strip manufacturer */
-       p = strchr(compatible, ',');
-       if (!p)
-               return -ENODEV;
-       p++;
-       if (strlcpy(info->type, p, I2C_NAME_SIZE) >= I2C_NAME_SIZE)
-               return -ENOMEM;
-       return 0;
-}
-
-void of_register_i2c_devices(struct i2c_adapter *adap,
-                            struct device_node *adap_node)
-{
-       void *result;
-       struct device_node *node;
-
-       for_each_child_of_node(adap_node, node) {
-               struct i2c_board_info info = {};
-               const u32 *addr;
-               int len;
-
-               addr = of_get_property(node, "reg", &len);
-               if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
-                       printk(KERN_ERR
-                              "of-i2c: invalid i2c device entry\n");
-                       continue;
-               }
-
-               info.irq = irq_of_parse_and_map(node, 0);
-               if (info.irq == NO_IRQ)
-                       info.irq = -1;
-
-               if (of_find_i2c_driver(node, &info) < 0) {
-                       irq_dispose_mapping(info.irq);
-                       continue;
-               }
-
-               info.addr = *addr;
-
-               request_module(info.type);
-
-               result = i2c_new_device(adap, &info);
-               if (result == NULL) {
-                       printk(KERN_ERR
-                              "of-i2c: Failed to load driver for %s\n",
-                              info.type);
-                       irq_dispose_mapping(info.irq);
-                       continue;
-               }
-       }
-}
-EXPORT_SYMBOL(of_register_i2c_devices);
diff --git a/drivers/of/of_i2c.c b/drivers/of/of_i2c.c
new file mode 100644 (file)
index 0000000..6316891
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * 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/of.h>
+
+struct i2c_driver_device {
+       char    *of_device;
+       char    *i2c_type;
+};
+
+static struct i2c_driver_device i2c_devices[] = {
+       { "dallas,ds1374", "rtc-ds1374" },
+};
+
+static int of_find_i2c_driver(struct device_node *node,
+                             struct i2c_board_info *info)
+{
+       int i, cplen;
+       const char *compatible;
+       const char *p;
+
+       /* 1. search for exception list entry */
+       for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
+               if (!of_device_is_compatible(node, i2c_devices[i].of_device))
+                       continue;
+               if (strlcpy(info->type, i2c_devices[i].i2c_type,
+                           I2C_NAME_SIZE) >= I2C_NAME_SIZE)
+                       return -ENOMEM;
+
+               return 0;
+       }
+
+       compatible = of_get_property(node, "compatible", &cplen);
+       if (!compatible)
+               return -ENODEV;
+
+       /* 2. search for linux,<i2c-type> entry */
+       p = compatible;
+       while (cplen > 0) {
+               if (!strncmp(p, "linux,", 6)) {
+                       p += 6;
+                       if (strlcpy(info->type, p,
+                                   I2C_NAME_SIZE) >= I2C_NAME_SIZE)
+                               return -ENOMEM;
+                       return 0;
+               }
+
+               i = strlen(p) + 1;
+               p += i;
+               cplen -= i;
+       }
+
+       /* 3. take fist compatible entry and strip manufacturer */
+       p = strchr(compatible, ',');
+       if (!p)
+               return -ENODEV;
+       p++;
+       if (strlcpy(info->type, p, I2C_NAME_SIZE) >= I2C_NAME_SIZE)
+               return -ENOMEM;
+       return 0;
+}
+
+void of_register_i2c_devices(struct i2c_adapter *adap,
+                            struct device_node *adap_node)
+{
+       void *result;
+       struct device_node *node;
+
+       for_each_child_of_node(adap_node, node) {
+               struct i2c_board_info info = {};
+               const u32 *addr;
+               int len;
+
+               addr = of_get_property(node, "reg", &len);
+               if (!addr || len < sizeof(int) || *addr > (1 << 10) - 1) {
+                       printk(KERN_ERR
+                              "of-i2c: invalid i2c device entry\n");
+                       continue;
+               }
+
+               info.irq = irq_of_parse_and_map(node, 0);
+               if (info.irq == NO_IRQ)
+                       info.irq = -1;
+
+               if (of_find_i2c_driver(node, &info) < 0) {
+                       irq_dispose_mapping(info.irq);
+                       continue;
+               }
+
+               info.addr = *addr;
+
+               request_module(info.type);
+
+               result = i2c_new_device(adap, &info);
+               if (result == NULL) {
+                       printk(KERN_ERR
+                              "of-i2c: Failed to load driver for %s\n",
+                              info.type);
+                       irq_dispose_mapping(info.irq);
+                       continue;
+               }
+       }
+}
+EXPORT_SYMBOL(of_register_i2c_devices);