[i2c] [PATCH 0/4] Series to add device tree naming to i2c

Jon Smirl jonsmirl at gmail.com
Mon Dec 10 08:35:05 EST 2007


On 12/9/07, Benjamin Herrenschmidt <benh at kernel.crashing.org> wrote:
>
> On Sun, 2007-12-09 at 15:57 -0500, Jon Smirl wrote:
> >
> > Are there technical concerns with this series? The white space can be
> > fixed in a few minutes.
> >
> > Adding a tag to differentiate matching types has implications that are
> > broader than just i2c. Shouldn't we do this first with the existing
> > scheme and then change the tagging process with later patches?
>
> No, we should decide on what to do with the tagging process (or not do)
> first, don't you think ? (If we need a tagging process, Scott had a
> concern but it might be moot, let's discuss that first).

Right now the tags are simply strings. The second parameter is driver specific.

+static struct i2c_device_id rs5c372_id[] = {
+       {"rtc-rs5c372", rtc_rs5c372a},
+       {"rs5c372a", rtc_rs5c372a},
+       {"rs5c372b", rtc_rs5c372b},
+       {"rv5c386", rtc_rv5c386},
+       {"rv5c387a", rtc_rv5c387a},
+       {"ricoh,rs5c372a", rtc_rs5c372a},
+       {"ricoh,rs5c372b", rtc_rs5c372b},
+       {"ricoh,rv5c386", rtc_rv5c386},
+       {"ricoh,rv5c387a", rtc_rv5c387a},
+       {},
+};

The current mechanism is simple string matching there are no platform
specific namespaces.

We could wrap the device tree style names in a macro that adds a
non-printable character to the front.

Something like this:
#define DT_NAMESPACE "\1"
#define DT_NAME(x) (DT_NAMESPACE x)
+       {DT_NAME("ricoh,rv5c386"), rtc_rv5c386},

And then modify the mpc i2c driver to insert the DT_NAMESPACE in front
of the string.

Another solution would be to make the names disappear on non-device
tree platforms

in mod_devicetable.h:
#ifdef USING_DEVICE_TREES
#define DT_NAME(x) x
#else
#define DTNAME(x)
#endif

+static struct i2c_device_id rs5c372_id[] = {
+       {"rtc-rs5c372", rtc_rs5c372a},
+       {"rs5c372a", rtc_rs5c372a},
+       {"rs5c372b", rtc_rs5c372b},
+       {"rv5c386", rtc_rv5c386},
+       {"rv5c387a", rtc_rv5c387a},
+       DT_NAME({"ricoh,rs5c372a", rtc_rs5c372a},)
+       DT_NAME({"ricoh,rs5c372b", rtc_rs5c372b},)
+       DT_NAME({"ricoh,rv5c386", rtc_rv5c386},)
+       DT_NAME({"ricoh,rv5c387a", rtc_rv5c387a},)
+       {},

But what's the point in making these names specific to device trees?
They are perfectly valid names for the devices that could be used from
any platform.

-- 
Jon Smirl
jonsmirl at gmail.com



More information about the Linuxppc-dev mailing list