[i2c] [PATCH 1/2] i2c: Add support for device alias names

Jon Smirl jonsmirl at gmail.com
Mon Apr 28 16:43:35 CEST 2008


On 4/28/08, Jean Delvare <khali at linux-fr.org> wrote:
> Based on earlier work by Jon Smirl and Jochen Friedrich.
>
>  This patch allows new-style i2c chip drivers to have alias names using
>  the official kernel aliasing system and MODULE_DEVICE_TABLE(). At this
>  point, the old i2c driver binding scheme (driver_name/type) is still
>  supported.
>
>  Signed-off-by: Jean Delvare <khali at linux-fr.org>
>  Cc: Jochen Friedrich <jochen at scram.de>
>  Cc: Jon Smirl <jonsmirl at gmail.com>
>  Cc: Kay Sievers <kay.sievers at vrfy.org>
>  ---
>  One thing I am still not happy with is that the aliases created have a
>  trailing "*":
>
>  $ /sbin/modinfo lm90
>  filename:       /lib/modules/2.6.25-git11/kernel/drivers/hwmon/lm90.ko
>  author:         Jean Delvare <khali at linux-fr.org>
>  description:    LM90/ADM1032 driver
>  license:        GPL
>  vermagic:       2.6.25-git11 mod_unload
>  depends:        hwmon
>  alias:          i2c:lm90*
>  alias:          i2c:adm1032*
>  alias:          i2c:lm99*
>  alias:          i2c:lm86*
>  alias:          i2c:max6657*
>  alias:          i2c:adt7461*
>  alias:          i2c:max6680*
>  $
>
>  This would cause trouble if one I2C chip name matches the beginning of
>  another I2C chip name and both chips are supported by different
>  drivers. This has yet to be seen, but still, I'd like to see this
>  problem fixed quickly.


Trailing wildcard is always added by file2alias.c:

                if (do_entry(mod->name, symval+i, alias)) {
                        /* Always end in a wildcard, for future extension */
                        if (alias[strlen(alias)-1] != '*')
                                strcat(alias, "*");


Can't the match order be controlled in the makefile? For example if
you had lm905* and lm90*, put lm905* into into the makefile first
which will cause it to appear in the alias file first. But that would
still cause problems if only lm90 was built and you had a lm905
device.

Alternatively you could change the code to append something like a
period to the name string.

sprintf(alias, I2C_MODULE_PREFIX "%s.", id->name);

I was using macros to alter the name strings to move the PowerPC names
into their own namespace.

-- 
Jon Smirl
jonsmirl at gmail.com



More information about the i2c mailing list