[i2c] Aliases and device names for i2c

Jon Smirl jonsmirl at gmail.com
Tue Jul 1 21:07:37 CEST 2008


Is the problem is stemming from having the i2c drivers support
multiple similar but not exactly the same chips?  These similar chips
are being exposed as aliases which they really aren't; they are
actually different chips.

A solution to this is for the drivers to register themselves multiple
times, one for each different chip. Doing that frees up aliases for
true aliases which is what device trees need.

That also resolve the issue of needing a name attribute in the sysfs
device node. We shouldn't need that attribute. By registering multiple
times, the link from the device to the driver will contain the correct
chip id. Of course we can still make a legacy name attribute until
user space is converted.

With this structure modalias will contain the alias used to load the driver.
The driver link will have pfc856?.name.name
pfc856?.name.name can also be use to create the name attribute.

static const struct i2c_device_id pcf8563_id[] = {
	{ "pcf8563", 0 },
	{ "samsung,pcf8563", 0 },
	{ }
};
MODULE_DEVICE_TABLE(i2c, pcf8563_id);

static struct i2c_driver pcf8563_driver = {
	.driver		= {
		.name	= "pcf8563",
	},
	.probe		= pcf8563_probe,
	.remove		= pcf8563_remove,
	.id_table	= pcf8563_id,
};

static int __init pcf8563_init(void)
{
	return i2c_add_driver(&pcf8563_driver);
}

static void __exit pcf8563_exit(void)
{
	i2c_del_driver(&pcf8563_driver);
}

static const struct i2c_device_id pcf8563_id[] = {
	{ "rtc8564", 0 },
	{ "dallas,rtc8564", 0 },
	{ }
};
MODULE_DEVICE_TABLE(i2c, pcf8563_id);

static struct i2c_driver pcf8563_driver = {
	.driver		= {
		.name	= "pcf8564",
	},
	.probe		= pcf8563_probe,
	.remove		= pcf8563_remove,
	.id_table	= pcf8564_id,
};

static int __init pcf8564_init(void)
{
	return i2c_add_driver(&pcf8564_driver);
}

static void __exit pcf8564_exit(void)
{
	i2c_del_driver(&pcf8564_driver);
}

-- 
Jon Smirl
jonsmirl at gmail.com



More information about the i2c mailing list