Skip to contentSkip to conversation

Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.

PATCH In review Jon Smirl 9 participants 18 messages Jan 23, 2008 – Feb 1, 2008 4 messages not in the archive

Subsystems (6)
lore
Share & tools
lore

Jon Smirl

author
#0 lore raw

PATCH 1/3 Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.

Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.

---

 drivers/i2c/busses/Makefile      |    2 
 drivers/i2c/busses/i2c-mpc-drv.c |  421 ++++++++++++++++++++++++++++++++++++++
 drivers/i2c/busses/i2c-mpc.c     |  421 --------------------------------------
 3 files changed, 423 insertions(+), 421 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-mpc-drv.c
 delete mode 100644 drivers/i2c/busses/i2c-mpc.c
drivers/i2c/busses/Makefile +2 -0
index ea7068f..171800d 100644
@@ -2,6 +2,8 @@
 # Makefile for the i2c bus drivers.
 #
 
+i2c-mpc-objs	:= i2c-mpc-drv.o
+
 obj-$(CONFIG_I2C_ALI1535)	+= i2c-ali1535.o
 obj-$(CONFIG_I2C_ALI1563)	+= i2c-ali1563.o
 obj-$(CONFIG_I2C_ALI15X3)	+= i2c-ali15x3.o
drivers/i2c/busses/i2c-mpc-drv.c new file +421 -0

421 lines not on this page · raw message

drivers/i2c/busses/i2c-mpc.c deleted +0 -421

421 lines not on this page · raw message

author
#1 lore raw

PATCH 2/3 Convert PowerPC MPC i2c to of_platform_driver from platform_driver

Convert MPC i2c driver from a platform_driver to a of_platform_driver. Add the ability to dynamically load i2c drivers based on device tree names. Routine names were changed from fsl_ to mpc_ to make them match the file name. Common code moved to powerpc-common.* Orginal ppc driver left intact for deletion when ppc arch is removed.

---

 arch/powerpc/sysdev/fsl_soc.c       |  125 ---------------------------
 drivers/i2c/busses/Makefile         |    2 
 drivers/i2c/busses/i2c-mpc-drv.c    |  165 ++++++++++++++++++++++++++++++++---
 drivers/i2c/busses/powerpc-common.c |   81 +++++++++++++++++
 drivers/i2c/busses/powerpc-common.h |   23 +++++
 include/linux/mod_devicetable.h     |    9 ++
 6 files changed, 263 insertions(+), 142 deletions(-)
 create mode 100644 drivers/i2c/busses/powerpc-common.c
 create mode 100644 drivers/i2c/busses/powerpc-common.h
arch/powerpc/sysdev/fsl_soc.c +0 -125
index e4b14a5..d6ef264 100644
@@ -318,131 +318,6 @@ err:
 
 arch_initcall(gfar_of_init);
 
-#ifdef CONFIG_I2C_BOARDINFO
-#include <linux/i2c.h>
-struct i2c_driver_device {
-	char	*of_device;
-	char	*i2c_type;
-};
-
-static struct i2c_driver_device i2c_devices[] __initdata = {
-	{"ricoh,rs5c372a", "rs5c372a",},
-	{"ricoh,rs5c372b", "rs5c372b",},
-	{"ricoh,rv5c386",  "rv5c386",},
-	{"ricoh,rv5c387a", "rv5c387a",},
-	{"dallas,ds1307",  "ds1307",},
-	{"dallas,ds1337",  "ds1337",},
-	{"dallas,ds1338",  "ds1338",},
-	{"dallas,ds1339",  "ds1339",},
-	{"dallas,ds1340",  "ds1340",},
-	{"stm,m41t00",     "m41t00"},
-	{"dallas,ds1374",  "rtc-ds1374",},
-};
-
-static int __init of_find_i2c_driver(struct device_node *node,
-				     struct i2c_board_info *info)
-{
-	int i;
-
-	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;
-	}
-	return -ENODEV;
-}
-
-static void __init of_register_i2c_devices(struct device_node *adap_node,
-					   int bus_num)
-{
-	struct device_node *node = NULL;
-
-	while ((node = of_get_next_child(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_WARNING "fsl_soc.c: 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)
-			continue;
-
-		info.addr = *addr;
-
-		i2c_register_board_info(bus_num, &info, 1);
-	}
-}
-
-static int __init fsl_i2c_of_init(void)
-{
-	struct device_node *np;
-	unsigned int i;
-	struct platform_device *i2c_dev;
-	int ret;
-
-	for (np = NULL, i = 0;
-	     (np = of_find_compatible_node(np, "i2c", "fsl-i2c")) != NULL;
-	     i++) {
-		struct resource r[2];
-		struct fsl_i2c_platform_data i2c_data;
-		const unsigned char *flags = NULL;
-
-		memset(&r, 0, sizeof(r));
-		memset(&i2c_data, 0, sizeof(i2c_data));
-
-		ret = of_address_to_resource(np, 0, &r[0]);
-		if (ret)
-			goto err;
-
-		of_irq_to_resource(np, 0, &r[1]);
-
-		i2c_dev = platform_device_register_simple("fsl-i2c", i, r, 2);
-		if (IS_ERR(i2c_dev)) {
-			ret = PTR_ERR(i2c_dev);
-			goto err;
-		}
-
-		i2c_data.device_flags = 0;
-		flags = of_get_property(np, "dfsrr", NULL);
-		if (flags)
-			i2c_data.device_flags |= FSL_I2C_DEV_SEPARATE_DFSRR;
-
-		flags = of_get_property(np, "fsl5200-clocking", NULL);
-		if (flags)
-			i2c_data.device_flags |= FSL_I2C_DEV_CLOCK_5200;
-
-		ret =
-		    platform_device_add_data(i2c_dev, &i2c_data,
-					     sizeof(struct
-						    fsl_i2c_platform_data));
-		if (ret)
-			goto unreg;
-
-		of_register_i2c_devices(np, i);
-	}
-
-	return 0;
-
-unreg:
-	platform_device_unregister(i2c_dev);
-err:
-	return ret;
-}
-
-arch_initcall(fsl_i2c_of_init);
-#endif
-
 #ifdef CONFIG_PPC_83xx
 static int __init mpc83xx_wdt_init(void)
 {
drivers/i2c/busses/Makefile +1 -1
index 171800d..e94241f 100644
@@ -2,7 +2,7 @@
 # Makefile for the i2c bus drivers.
 #
 
-i2c-mpc-objs	:= i2c-mpc-drv.o
+i2c-mpc-objs	:= i2c-mpc-drv.o powerpc-common.o
 
 obj-$(CONFIG_I2C_ALI1535)	+= i2c-ali1535.o
 obj-$(CONFIG_I2C_ALI1563)	+= i2c-ali1563.o
drivers/i2c/busses/i2c-mpc-drv.c +150 -15

239 lines not on this page · raw message

drivers/i2c/busses/powerpc-common.c new file +81 -0

81 lines not on this page · raw message

drivers/i2c/busses/powerpc-common.h new file +23 -0
new file mode 100644
index 0000000..95f1347
@@ -0,0 +1,23 @@
+/*
+ * powerpc-common.h - routines common to device tree parsing for all
+ *                    powerpc based i2c hosts
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * (C) Copyright 2008 Jon Smirl <[email protected]>
+ *
+ */
+
+void of_register_i2c_devices(struct i2c_adapter *adap, struct device_node *adap_node);
include/linux/mod_devicetable.h +8 -1
index d1488a0..2e53b39 100644
@@ -371,8 +371,15 @@ struct virtio_device_id {
 
 /* These defines are used to separate PowerPC open firmware
  * drivers into their own namespace */
-#define I2C_NAME_SIZE	20
+#define I2C_NAME_SIZE	48  /* Needs to be large enough to hold device tree style names */
 #define I2C_MODULE_PREFIX "i2c:"
+#ifdef CONFIG_OF
+#define OF_PREFIX "OF," /* Used to put OF device tree names into their own namespace */
+#define I2C_OF_MODULE_PREFIX I2C_MODULE_PREFIX OF_PREFIX
+#define OF_ID(s, d) { OF_PREFIX s, (d) },
+#else
+#define OF_ID(s, d)
+#endif
 
 struct i2c_device_id {
 	char name[I2C_NAME_SIZE];
#8 lore raw

PATCH 3/3 Add device tree compatible aliases to i2c drivers

In reply to a message not in the archive

PowerPC device trees use a different naming convention than the Linux kernel. Provide alias names for i2c drivers in order to allow them to be loaded by device tree name. The OF_ID macro ensures that the aliases are only present in powerpc builds and separated into their own namespace.

---

 drivers/hwmon/f75375s.c      |    2 ++
 drivers/i2c/chips/ds1682.c   |    1 +
 drivers/i2c/chips/menelaus.c |    1 +
 drivers/i2c/chips/tps65010.c |    4 ++++
 drivers/i2c/chips/tsl2550.c  |    1 +
 drivers/rtc/rtc-ds1307.c     |    6 ++++++
 drivers/rtc/rtc-ds1374.c     |    1 +
 drivers/rtc/rtc-m41t80.c     |    8 ++++++++
 drivers/rtc/rtc-pcf8563.c    |    2 ++
 drivers/rtc/rtc-rs5c372.c    |    4 ++++
 10 files changed, 30 insertions(+), 0 deletions(-)
drivers/hwmon/f75375s.c +2 -0
index 4cb4db4..dd548e7 100644
@@ -132,6 +132,8 @@ static struct i2c_driver f75375_legacy_driver = {
 static const struct i2c_device_id f75375_id[] = {
 	{ "f75373", f75373 },
 	{ "f75375", f75375 },
+	OF_ID("fintek,f75373", f75373)
+	OF_ID("fintek,f75375", f75375)
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, f75375_id);
drivers/i2c/chips/ds1682.c +1 -0
index 51ff518..817ad1f 100644
@@ -237,6 +237,7 @@ static int ds1682_remove(struct i2c_client *client)
 
 static const struct i2c_device_id ds1682_id[] = {
 	{ "ds1682", 0 },
+	OF_ID("dallas,ds1682", 0)
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, ds1682_id);
drivers/i2c/chips/menelaus.c +1 -0
index 1f9ac5e..ba7d619 100644
@@ -1245,6 +1245,7 @@ static int __exit menelaus_remove(struct i2c_client *client)
 
 static const struct i2c_device_id menelaus_id[] = {
 	{ "menelaus", 0 },
+	OF_ID("ti,twl92330", 0)
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, menelaus_id);
drivers/i2c/chips/tps65010.c +4 -0
index e07274d..67fd30f 100644
@@ -571,6 +571,10 @@ static const struct i2c_device_id tps65010_id[] = {
 	{ "tps65011", TPS65011 },
 	{ "tps65012", TPS65012 },
 	{ "tps65013", TPS65013 },
+	OF_ID("ti,tps65010", TPS65010)
+	OF_ID("ti,tps65011", TPS65011)
+	OF_ID("ti,tps65012", TPS65012)
+	OF_ID("ri,tps65013", TPS65013)
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, tps65010_id);
drivers/i2c/chips/tsl2550.c +1 -0
index 2add8be..8071d6d 100644
@@ -454,6 +454,7 @@ static int tsl2550_resume(struct i2c_client *client)
 
 static const struct i2c_device_id tsl2550_id[] = {
 	{ "tsl2550", 0 },
+	OF_ID("taos,tsl2550", 0)
 	{ },
 };
 MODULE_DEVICE_TABLE(i2c, tsl2550_id);
drivers/rtc/rtc-ds1307.c +6 -0
index a5614ab..e363a5f 100644
@@ -129,6 +129,12 @@ static const struct i2c_device_id ds1307_id[] = {
 	{ "ds1339", ds_1339 },
 	{ "ds1340", ds_1340 },
 	{ "m41t00", m41t00 },
+	OF_ID("dallas,ds1307", ds_1307)
+	OF_ID("dallas,ds1337", ds_1337)
+	OF_ID("dallas,ds1338", ds_1338)
+	OF_ID("dallas,ds1339", ds_1339)
+	OF_ID("dallas,ds1340", ds_1340)
+	OF_ID("stm,m41t00", m41t00)
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, ds1307_id);
drivers/rtc/rtc-ds1374.c +1 -0
index 376ceeb..e4f680a 100644
@@ -43,6 +43,7 @@
 
 static const struct i2c_device_id ds1374_id[] = {
 	{ "ds1374", 0 },
+	OF_ID("dallas,ds1374", 0)
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, ds1374_id);
drivers/rtc/rtc-m41t80.c +8 -0
index c672557..663f8b5 100644
@@ -69,6 +69,14 @@ static const struct i2c_device_id m41t80_id[] = {
 	{ "m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
 	{ "m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
 	{ "m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL },
+	OF_ID("stm,m41t80", 0)
+	OF_ID("stm,m41t81", M41T80_FEATURE_HT)
+	OF_ID("stm,m41t81s", M41T80_FEATURE_HT | M41T80_FEATURE_BL)
+	OF_ID("stm,m41t82", M41T80_FEATURE_HT | M41T80_FEATURE_BL)
+	OF_ID("stm,m41t83", M41T80_FEATURE_HT | M41T80_FEATURE_BL)
+	OF_ID("stm,m41st84", M41T80_FEATURE_HT | M41T80_FEATURE_BL)
+	OF_ID("stm,m41st85", M41T80_FEATURE_HT | M41T80_FEATURE_BL)
+	OF_ID("stm,m41st87", M41T80_FEATURE_HT | M41T80_FEATURE_BL)
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, m41t80_id);
drivers/rtc/rtc-pcf8563.c +2 -0
index 8eff549..51d7471 100644
@@ -263,6 +263,8 @@ static int pcf8563_remove(struct i2c_client *client)
 static struct i2c_device_id pcf8563_id[] = {
 	{"pcf8563", 0},
 	{"rtc8564", 0},
+	OF_ID("phillips,pcf8563", 0)
+	OF_ID("epson,rtc8564", 0)
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, pcf8563_id);
drivers/rtc/rtc-rs5c372.c +4 -0
index a3e4f8d..cdd26c3 100644
@@ -74,6 +74,10 @@ static const struct i2c_device_id rs5c372_id[] = {
 	{ "rs5c372b", rtc_rs5c372b },
 	{ "rv5c386", rtc_rv5c386 },
 	{ "rv5c387a", rtc_rv5c387a },
+	OF_ID("ricoh,rs5c372a", rtc_rs5c372a)
+	OF_ID("ricoh,rs5c372b", rtc_rs5c372b)
+	OF_ID("ricoh,rv5c386", rtc_rv5c386)
+	OF_ID("ricoh,rv5c387a", rtc_rv5c387a)
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, rs5c372_id);

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

#17 lore raw
In reply to Jon Smirl

Hi Jon,

Quoted 4 lines · On Tue, 22 Jan 2008 21:09:12 -0500 Jon Smirl <[email protected]> wrote:

Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.

Quoted 8 lines

---

 drivers/i2c/busses/Makefile      |    2 
 drivers/i2c/busses/i2c-mpc-drv.c |  421 ++++++++++++++++++++++++++++++++++++++
 drivers/i2c/busses/i2c-mpc.c     |  421 --------------------------------------
 3 files changed, 423 insertions(+), 421 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-mpc-drv.c
 delete mode 100644 drivers/i2c/busses/i2c-mpc.c

Adding -M or -C to the "git diff" should identify renames and makes this sort of patch much easier to review.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#19 lore raw
In reply to a message not in the archive
Quoted 16 lines · Stephen Rothwell

Hi Jon,

Quoted 4 lines · On Tue, 22 Jan 2008 21:09:12 -0500 Jon Smirl…

Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.

Quoted 8 lines

---

 drivers/i2c/busses/Makefile      |    2
 drivers/i2c/busses/i2c-mpc-drv.c |  421 ++++++++++++++++++++++++++++++++++++++
 drivers/i2c/busses/i2c-mpc.c     |  421 --------------------------------------
 3 files changed, 423 insertions(+), 421 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-mpc-drv.c
 delete mode 100644 drivers/i2c/busses/i2c-mpc.c
Quoted 2 lines

Adding -M or -C to the "git diff" should identify renames and makes this sort of patch much easier to review.

I use stgit, I'll ask them how to generate rename patches. The actual git diff is buried inside stgit somewhere.

Quoted 7 lines

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

Signature · 7 lines
Jon Smirl
[email protected]

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
#20 lore raw
Quoted 8 lines · Jon Smirl
Quoted 2 lines · Stephen Rothwell

Adding -M or -C to the "git diff" should identify renames and makes this sort of patch much easier to review.

I use stgit, I'll ask them how to generate rename patches. The actual git diff is buried inside stgit somewhere.

From the "stg mail --help" output:

  -O DIFF_OPTS, --diff-opts=DIFF_OPTS
                        options to pass to git-diff

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
author
#21 lore raw
Quoted 5 lines · Grant Likely
Quoted 4 lines · Jon Smirl
Quoted 2 lines · Stephen Rothwell

Adding -M or -C to the "git diff" should identify renames and makes this sort of patch much easier to review.

Quoted 7 lines
Quoted 2 lines

I use stgit, I'll ask them how to generate rename patches. The actual git diff is buried inside stgit somewhere.

From the "stg mail --help" output:

  -O DIFF_OPTS, --diff-opts=DIFF_OPTS
                        options to pass to git-diff

I found that one, there doesn't appear to be a way to set it permanently via the config file. I asked them to add the option. Here's the patch with -M set, I'll make sure and set it on the final version. These patches apply on top of Jean's patch adding module loading to i2c, which apply on top of his 2.6.25 tree.

Rename i2c-mpc to i2c-mpc-drv in preparation for breaking out common code.

---

 drivers/i2c/busses/Makefile      |    2
 drivers/i2c/busses/i2c-mpc-drv.c |  421 ++++++++++++++++++++++++++++++++++++++
 drivers/i2c/busses/i2c-mpc.c     |  421 --------------------------------------
 3 files changed, 423 insertions(+), 421 deletions(-)
 create mode 100644 drivers/i2c/busses/i2c-mpc-drv.c
 delete mode 100644 drivers/i2c/busses/i2c-mpc.c
drivers/i2c/busses/Makefile +2 -0
index ea7068f..171800d 100644
@@ -2,6 +2,8 @@
 # Makefile for the i2c bus drivers.
 #
 
+i2c-mpc-objs	:= i2c-mpc-drv.o
+
 obj-$(CONFIG_I2C_ALI1535)	+= i2c-ali1535.o
 obj-$(CONFIG_I2C_ALI1563)	+= i2c-ali1563.o
 obj-$(CONFIG_I2C_ALI15X3)	+= i2c-ali15x3.o
drivers/i2c/busses/i2c-mpc-drv.c renamed from drivers/i2c/busses/i2c-mpc.c +0 -0
similarity index 100%
rename from drivers/i2c/busses/i2c-mpc.c
rename to drivers/i2c/busses/i2c-mpc-drv.c
Signature · 2 lines
Jon Smirl
[email protected]
#2 lore raw

Re: [PATCH 2/3] Convert PowerPC MPC i2c to of_platform_driver from platform_driver

In reply to Jon Smirl
Quoted 2 lines · On Tue, 22 Jan 2008 21:09:14 -0500 Jon Smirl <[email protected]> wrote:

+static struct of_device_id mpc_i2c_of_match[] = {

(sfr winds up his broken record :-)) const, please.

drivers/i2c/busses/i2c-mpc-drv.c static struct i2c_adapter mpc_ops = { · line 450

Quoted 3 lines
drivers/i2c/busses/i2c-mpc-drv.c +2 -0
+#else
+
 static int fsl_i2c_probe(struct platform_device *pdev)

While this code is still here, you should still explicitly include <linux/platform.h>

drivers/i2c/busses/i2c-mpc-drv.c static int fsl_i2c_probe(struct platform_device *pdev) · line 502

Quoted 2 lines
drivers/i2c/busses/i2c-mpc-drv.c +1 -1
-      fail_add:
+fail_add:

If you are going to move labels, many people leave a single space in front of them so that "diff -p" picks up the function name instead of the label name.

drivers/i2c/busses/powerpc-common.c line 42

Quoted 3 lines
drivers/i2c/busses/powerpc-common.c new file +2 -0
+void of_register_i2c_devices(struct i2c_adapter *adap, struct device_node *adap_node)
 
+		compatible = of_get_property(node, "compatible", &len);

You can specify NULL instead of &len since you don't use the returned value.

drivers/i2c/busses/powerpc-common.c line 44

Quoted 2 lines
drivers/i2c/busses/powerpc-common.c new file +2 -0
+		if (!compatible) {
+			printk(KERN_ERR "i2c-mpc.c: invalid entry, missing compatible attribute\n");

Some of these printk lines are a bit long.

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

author
#3 lore raw

Re: [PATCH 2/3] Convert PowerPC MPC i2c to of_platform_driver from platform_driver

Quoted 5 lines · Stephen Rothwell
Quoted 2 lines · On Tue, 22 Jan 2008 21:09:14 -0500 Jon Smirl <[email protected]> wrote:

+static struct of_device_id mpc_i2c_of_match[] = {

(sfr winds up his broken record :-)) const, please.

Fixed this

Quoted 7 lines

drivers/i2c/busses/i2c-mpc-drv.c static struct i2c_adapter mpc_ops = { · line 450

Quoted 4 lines
drivers/i2c/busses/i2c-mpc-drv.c +2 -0
+#else
+
 static int fsl_i2c_probe(struct platform_device *pdev)

While this code is still here, you should still explicitly include <linux/platform.h>

Fixed this

Quoted 7 lines

drivers/i2c/busses/i2c-mpc-drv.c static int fsl_i2c_probe(struct platform_device *pdev) · line 502

Quoted 3 lines
drivers/i2c/busses/i2c-mpc-drv.c +1 -1
-      fail_add:
+fail_add:

If you are going to move labels, many people leave a single space in front of them so that "diff -p" picks up the function name instead of the label name.

checkpatch told me to get rid of the spaces.

Quoted 6 lines

drivers/i2c/busses/powerpc-common.c line 42

Quoted 4 lines
drivers/i2c/busses/powerpc-common.c new file +2 -0
+void of_register_i2c_devices(struct i2c_adapter *adap, struct device_node *adap_node)
 
+             compatible = of_get_property(node, "compatible", &len);

You can specify NULL instead of &len since you don't use the returned value.

fixed

Quoted 5 lines

drivers/i2c/busses/powerpc-common.c line 44

Quoted 3 lines
drivers/i2c/busses/powerpc-common.c new file +2 -0
+             if (!compatible) {
+                     printk(KERN_ERR "i2c-mpc.c: invalid entry, missing compatible attribute\n");

Some of these printk lines are a bit long.

i got rid of "invalid entry,"

Quoted 7 lines

--
Cheers,
Stephen Rothwell [email protected]
http://www.canb.auug.org.au/~sfr/

Signature · 2 lines
Jon Smirl
[email protected]
#4 lore raw

Re: [PATCH 2/3] Convert PowerPC MPC i2c to of_platform_driver from platform_driver

In reply to Jon Smirl

So, like, the other day Jon Smirl mumbled:

Quoted 6 lines

Convert MPC i2c driver from a platform_driver to a of_platform_driver. Add the ability to dynamically load i2c drivers based on device tree names. Routine names were changed from fsl_ to mpc_ to make them match the file name. Common code moved to powerpc-common.* Orginal ppc driver left intact for deletion when ppc arch is removed.

This seems backwards to me. I was under the impression that our trend was _toward_ "Freescale" and "fsl" names...? And aren't the drivers also already using "fsl-i2c" in the DTS files as called out in the b-w-o.txt too?

Grumble long lines not hard-limited to 70-ish columns, yes, even in log messages... :-)

jdl

#6 lore raw

Re: [PATCH 2/3] Convert PowerPC MPC i2c to of_platform_driver from platform_driver

In reply to a message not in the archive
Quoted 8 lines · Jon Loeliger

So, like, the other day Jon Smirl mumbled:

Quoted 6 lines

Convert MPC i2c driver from a platform_driver to a of_platform_driver. Add the ability to dynamically load i2c drivers based on device tree names. Routine names were changed from fsl_ to mpc_ to make them match the file name. Common code moved to powerpc-common.* Orginal ppc driver left intact for deletion when ppc arch is removed.

Quoted 4 lines

This seems backwards to me. I was under the impression that our trend was _toward_ "Freescale" and "fsl" names...? And aren't the drivers also already using "fsl-i2c" in the DTS files as called out in the b-w-o.txt too?

The routine names should match the file name which then determines the module name. I didn't want to change the module name so I made the routines names match the module name.

Quoted 6 lines

Grumble long lines not hard-limited to 70-ish columns, yes, even in log messages... :-)

jdl

Signature · 7 lines
Jon Smirl
[email protected]

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
#9 lore raw

Re: [PATCH 3/3] Add device tree compatible aliases to i2c drivers

In reply to Jon Smirl

drivers/i2c/chips/tps65010.c static const struct i2c_device_id tps65010_id[] = { · line 578

Quoted 11 lines · Jon Smirl
drivers/i2c/chips/tps65010.c +4 -0
@@ -571,6 +571,10 @@ static const struct i2c_device_id tps65010_id[] = {
 	{ "tps65011", TPS65011 },
 	{ "tps65012", TPS65012 },
 	{ "tps65013", TPS65013 },
+	OF_ID("ti,tps65010", TPS65010)
+	OF_ID("ti,tps65011", TPS65011)
+	OF_ID("ti,tps65012", TPS65012)
+	OF_ID("ri,tps65013", TPS65013)
 	{ },

ti, ti, ti, ri?

Quoted 4 lines
drivers/rtc/rtc-ds1307.c +0 -0
@@ -129,6 +129,12 @@ static const struct i2c_device_id ds1307_id[] = {
 	{ "ds1339", ds_1339 },

drivers/rtc/rtc-ds1307.c static const struct i2c_device_id ds1307_id[] = { · line 139

Quoted 10 lines
drivers/rtc/rtc-ds1307.c +6 -0
 	{ "ds1340", ds_1340 },
 	{ "m41t00", m41t00 },
+	OF_ID("dallas,ds1307", ds_1307)
+	OF_ID("dallas,ds1337", ds_1337)
+	OF_ID("dallas,ds1338", ds_1338)
+	OF_ID("dallas,ds1339", ds_1339)
+	OF_ID("dallas,ds1340", ds_1340)
+	OF_ID("stm,m41t00", m41t00)
 	{},
 };

The convention is to use the stock ticker, capitalized, if a company has one, I guess dallas is MXIM these days, but dallas is a good substitute based on the fact that most people still remember Dallas clock chips and so on from the Ancient Days. STMicroelectronics is STM. I couldn't care less about case sensitivity, but the stock ticker thing was always a good idea.. it gives a sort of grounding in reality for the manufacturer names.

Are we still following this convention or are the names of devices simply arbitrarily defined by Linux kernel developers now?

--
Matt Sealey <[email protected]>
Genesi, Manager, Developer Relations

author
#10 lore raw

Re: [PATCH 3/3] Add device tree compatible aliases to i2c drivers

Quoted 32 lines · Matt Sealey

drivers/i2c/chips/tps65010.c static const struct i2c_device_id tps65010_id[] = { · line 578

Quoted 11 lines · Jon Smirl
drivers/i2c/chips/tps65010.c +4 -0
@@ -571,6 +571,10 @@ static const struct i2c_device_id tps65010_id[] = {
      { "tps65011", TPS65011 },
      { "tps65012", TPS65012 },
      { "tps65013", TPS65013 },
+     OF_ID("ti,tps65010", TPS65010)
+     OF_ID("ti,tps65011", TPS65011)
+     OF_ID("ti,tps65012", TPS65012)
+     OF_ID("ri,tps65013", TPS65013)
      { },

ti, ti, ti, ri?

Quoted 4 lines
drivers/rtc/rtc-ds1307.c +0 -0
@@ -129,6 +129,12 @@ static const struct i2c_device_id ds1307_id[] = {
      { "ds1339", ds_1339 },

drivers/rtc/rtc-ds1307.c static const struct i2c_device_id ds1307_id[] = { · line 139

Quoted 10 lines
drivers/rtc/rtc-ds1307.c +6 -0
      { "ds1340", ds_1340 },
      { "m41t00", m41t00 },
+     OF_ID("dallas,ds1307", ds_1307)
+     OF_ID("dallas,ds1337", ds_1337)
+     OF_ID("dallas,ds1338", ds_1338)
+     OF_ID("dallas,ds1339", ds_1339)
+     OF_ID("dallas,ds1340", ds_1340)
+     OF_ID("stm,m41t00", m41t00)
      {},
 };
Quoted 7 lines

The convention is to use the stock ticker, capitalized, if a company has one, I guess dallas is MXIM these days, but dallas is a good substitute based on the fact that most people still remember Dallas clock chips and so on from the Ancient Days. STMicroelectronics is STM. I couldn't care less about case sensitivity, but the stock ticker thing was always a good idea.. it gives a sort of grounding in reality for the manufacturer names.

I'll put in whatever the Open Firmware police tell me to. We just all need to come to an agreement.

Quoted 7 lines

Are we still following this convention or are the names of devices simply arbitrarily defined by Linux kernel developers now?

--
Matt Sealey <[email protected]>
Genesi, Manager, Developer Relations

Signature · 2 lines
Jon Smirl
[email protected]
#12 lore raw

Re: [i2c] [PATCH 3/3] Add device tree compatible aliases to i2c drivers

In reply to Jon Smirl
Quoted 4 lines · Jon Smirl

PowerPC device trees use a different naming convention than the Linux kernel. Provide alias names for i2c drivers in order to allow them to be loaded by device tree name. The OF_ID macro ensures that the aliases are only present in powerpc builds and separated into their own namespace.

Hmm. I just realized that there's yet another twist to the PPC device bindings that's not yet considered:

Currently the device tree only contains one compatible field for most of the devices. But it's perfectly legal (actually, recommended) to have more than one compatible field -- they go from the specific to the generic.

For example, for an eeprom I might have: "MCHP,24lc128est", "MCHP,24xx128", "24c128". The at24 driver (not in mainline yet :) would likely match with "24c128", and it would normally not make sense to have to list all specific vendors and models of the device type in question in the driver.

I can't register a board_info for each of the compatible fields without changing the way the i2c drivers are registered, since the creation of the duplicate entries will start reporting errors. I also shouldn't (reasonably) have to register every single possible first (i.e. most specific) compatible-field -- that goes against the whole concept of having more than one compatible string.

So it seems that the solution would be to make i2c_board_info take a list of names for the device, and each of them has to be matched with all drivers, taking the first match.

Sounds reasonable to everyone? I can provide a patch to go on top of what's already proposed.

-Olof

#14 lore raw

Re: [PATCH 3/3] Add device tree compatible aliases to i2c drivers

In reply to a message not in the archive
Quoted 5 lines · Olof Johansson

For example, for an eeprom I might have: "MCHP,24lc128est", "MCHP,24xx128", "24c128". The at24 driver (not in mainline yet :) would likely match with "24c128", and it would normally not make sense to have to list all specific vendors and models of the device type in question in the driver.

It's not really about the vendors of the device, but the namespace it goes into. If there's really no canonical vendor name, then a plain old "24c148" might make sense, but that seems like it'd be fairly rare.

Quoted 3 lines

I can't register a board_info for each of the compatible fields without changing the way the i2c drivers are registered, since the creation of the duplicate entries will start reporting errors.

Even with the current i2c changes that have been flying around the lists? If so, it should be fixed...

Quoted 3 lines

So it seems that the solution would be to make i2c_board_info take a list of names for the device, and each of them has to be matched with all drivers, taking the first match.

Agreed.

-Scott

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c

#16 lore raw

Re: [PATCH 3/3] Add device tree compatible aliases to i2c drivers

In reply to a message not in the archive
Quoted 26 lines · Olof Johansson
Quoted 4 lines · Jon Smirl

PowerPC device trees use a different naming convention than the Linux kernel. Provide alias names for i2c drivers in order to allow them to be loaded by device tree name. The OF_ID macro ensures that the aliases are only present in powerpc builds and separated into their own namespace.

Hmm. I just realized that there's yet another twist to the PPC device bindings that's not yet considered:

Currently the device tree only contains one compatible field for most of the devices. But it's perfectly legal (actually, recommended) to have more than one compatible field -- they go from the specific to the generic.

For example, for an eeprom I might have: "MCHP,24lc128est", "MCHP,24xx128", "24c128". The at24 driver (not in mainline yet :) would likely match with "24c128", and it would normally not make sense to have to list all specific vendors and models of the device type in question in the driver.

I can't register a board_info for each of the compatible fields without changing the way the i2c drivers are registered, since the creation of the duplicate entries will start reporting errors. I also shouldn't (reasonably) have to register every single possible first (i.e. most specific) compatible-field -- that goes against the whole concept of having more than one compatible string.

Quoted 6 lines

So it seems that the solution would be to make i2c_board_info take a list of names for the device, and each of them has to be matched with all drivers, taking the first match.

Sounds reasonable to everyone? I can provide a patch to go on top of what's already proposed.

I was aware that this was missing but I'm having enough trouble getting the base code in so I hadn't addressed this problem yet. A patch would be fine, I haven't written any code.

Can you put the support somewhere in powerpc common code? When I get my dynamically loadable audio codec patch ready it is going to have the same problem.

Also note that all of this only works for new style i2c drivers, if you want to dynamically load an old style one your will have to convert it to new style first (not hard to do).

Signature · 7 lines
Jon Smirl
[email protected]

_______________________________________________
i2c mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/i2c
author
#15 lore raw

Re: [i2c] [PATCH 3/3] Add device tree compatible aliases to i2c drivers

In reply to Scott Wood
Quoted 11 lines · Scott Wood
Quoted 5 lines · Olof Johansson

For example, for an eeprom I might have: "MCHP,24lc128est", "MCHP,24xx128", "24c128". The at24 driver (not in mainline yet :) would likely match with "24c128", and it would normally not make sense to have to list all specific vendors and models of the device type in question in the driver.

It's not really about the vendors of the device, but the namespace it goes into. If there's really no canonical vendor name, then a plain old "24c148" might make sense, but that seems like it'd be fairly rare.

Quoted 6 lines
Quoted 3 lines

I can't register a board_info for each of the compatible fields without changing the way the i2c drivers are registered, since the creation of the duplicate entries will start reporting errors.

Even with the current i2c changes that have been flying around the lists? If so, it should be fixed...

How to fix this needs some thought....

Devices can register before their drivers are loaded. What name are you going to use to register the device in this case?

Probably the right way to fix this is in drivers/base not in the i2c code. PowerPC devices would register with their entire compatible string. Then later when drivers are loaded they would be compared
against the device's compatible string. When you register a device
the existing drivers will need to be looked for in the order of the compatible string.

Another wrinkle is exhibited by the USB HID driver. The generic USB HID driver will bind to every HID device it sees. Later if you want to load a specific driver for the USB device you have to go into sysfs and unbind the device from the generic HID driver and then rebind it to the specific driver. Matching on the compatible list will have the same problem.

Quoted 10 lines
Quoted 4 lines

So it seems that the solution would be to make i2c_board_info take a list of names for the device, and each of them has to be matched with all drivers, taking the first match.

Agreed.

-Scott

Signature · 2 lines
Jon Smirl
[email protected]
#11 lore raw

Re: [PATCH 3/3] Add device tree compatible aliases to i2c drivers

In reply to Matt Sealey
Quoted 32 lines · Matt Sealey

drivers/i2c/chips/tps65010.c static const struct i2c_device_id tps65010_id[] = { · line 578

Quoted 11 lines · Jon Smirl
drivers/i2c/chips/tps65010.c +4 -0
@@ -571,6 +571,10 @@ static const struct i2c_device_id tps65010_id[] = {
 	{ "tps65011", TPS65011 },
 	{ "tps65012", TPS65012 },
 	{ "tps65013", TPS65013 },
+	OF_ID("ti,tps65010", TPS65010)
+	OF_ID("ti,tps65011", TPS65011)
+	OF_ID("ti,tps65012", TPS65012)
+	OF_ID("ri,tps65013", TPS65013)
 	{ },

ti, ti, ti, ri?

Quoted 4 lines
drivers/rtc/rtc-ds1307.c +0 -0
@@ -129,6 +129,12 @@ static const struct i2c_device_id ds1307_id[] = {
 	{ "ds1339", ds_1339 },

drivers/rtc/rtc-ds1307.c static const struct i2c_device_id ds1307_id[] = { · line 139

Quoted 10 lines
drivers/rtc/rtc-ds1307.c +6 -0
 	{ "ds1340", ds_1340 },
 	{ "m41t00", m41t00 },
+	OF_ID("dallas,ds1307", ds_1307)
+	OF_ID("dallas,ds1337", ds_1337)
+	OF_ID("dallas,ds1338", ds_1338)
+	OF_ID("dallas,ds1339", ds_1339)
+	OF_ID("dallas,ds1340", ds_1340)
+	OF_ID("stm,m41t00", m41t00)
 	{},
 };
Quoted 7 lines

The convention is to use the stock ticker, capitalized, if a company has one, I guess dallas is MXIM these days, but dallas is a good substitute based on the fact that most people still remember Dallas clock chips and so on from the Ancient Days. STMicroelectronics is STM. I couldn't care less about case sensitivity, but the stock ticker thing was always a good idea.. it gives a sort of grounding in reality for the manufacturer names.

The stock ticker is a recent convention. "dallas," has been used in existing IEEE1275 bindings, which to my mind trumps newer conventions.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson