i2c: Migration aids for i2c_adapter.dev removal
Flag i2c_adapter.dev for removal after userspace tools get upgraded, and include a near-term code migration aid to facilitate this: - The class device gets the name attribute it should have had. This was previously (wrongly) associated with the i2c_adapter.dev node. Sysfs based tools and libraries can start converting right away. - Issue a warning for legacy adapter drivers that don't provide any physical device node; so systems with those drivers will know to fix this problem earlier. This is one of a series of patches to help the I2C stack become a better citizen of the Linux Driver Model world. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Jean Delvare <khali@linux-fr.org>
This commit is contained in:
parent
999445d437
commit
b119dc3f99
@ -226,6 +226,23 @@ Who: Jean Delvare <khali@linux-fr.org>
|
|||||||
|
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
What: i2c_adapter.dev
|
||||||
|
i2c_adapter.list
|
||||||
|
When: July 2007
|
||||||
|
Why: Superfluous, given i2c_adapter.class_dev:
|
||||||
|
* The "dev" was a stand-in for the physical device node that legacy
|
||||||
|
drivers would not have; but now it's almost always present. Any
|
||||||
|
remaining legacy drivers must upgrade (they now trigger warnings).
|
||||||
|
* The "list" duplicates class device children.
|
||||||
|
The delay in removing this is so upgraded lm_sensors and libsensors
|
||||||
|
can get deployed. (Removal causes minor changes in the sysfs layout,
|
||||||
|
notably the location of the adapter type name and parenting the i2c
|
||||||
|
client hardware directly from their controller.)
|
||||||
|
Who: Jean Delvare <khali@linux-fr.org>,
|
||||||
|
David Brownell <dbrownell@users.sourceforge.net>
|
||||||
|
|
||||||
|
---------------------------
|
||||||
|
|
||||||
What: IPv4 only connection tracking/NAT/helpers
|
What: IPv4 only connection tracking/NAT/helpers
|
||||||
When: 2.6.22
|
When: 2.6.22
|
||||||
Why: The new layer 3 independant connection tracking replaces the old
|
Why: The new layer 3 independant connection tracking replaces the old
|
||||||
|
@ -95,16 +95,32 @@ struct device_driver i2c_adapter_driver = {
|
|||||||
.bus = &i2c_bus_type,
|
.bus = &i2c_bus_type,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/* I2C bus adapters -- one roots each I2C or SMBUS segment */
|
||||||
|
|
||||||
static void i2c_adapter_class_dev_release(struct class_device *dev)
|
static void i2c_adapter_class_dev_release(struct class_device *dev)
|
||||||
{
|
{
|
||||||
struct i2c_adapter *adap = class_dev_to_i2c_adapter(dev);
|
struct i2c_adapter *adap = class_dev_to_i2c_adapter(dev);
|
||||||
complete(&adap->class_dev_released);
|
complete(&adap->class_dev_released);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ssize_t i2c_adapter_show_name(struct class_device *cdev, char *buf)
|
||||||
|
{
|
||||||
|
struct i2c_adapter *adap = class_dev_to_i2c_adapter(cdev);
|
||||||
|
return sprintf(buf, "%s\n", adap->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct class_device_attribute i2c_adapter_attrs[] = {
|
||||||
|
__ATTR(name, S_IRUGO, i2c_adapter_show_name, NULL),
|
||||||
|
{ },
|
||||||
|
};
|
||||||
|
|
||||||
struct class i2c_adapter_class = {
|
struct class i2c_adapter_class = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.name = "i2c-adapter",
|
.name = "i2c-adapter",
|
||||||
.release = &i2c_adapter_class_dev_release,
|
.class_dev_attrs = i2c_adapter_attrs,
|
||||||
|
.release = &i2c_adapter_class_dev_release,
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf)
|
static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
@ -175,8 +191,12 @@ int i2c_add_adapter(struct i2c_adapter *adap)
|
|||||||
* If the parent pointer is not set up,
|
* If the parent pointer is not set up,
|
||||||
* we add this adapter to the host bus.
|
* we add this adapter to the host bus.
|
||||||
*/
|
*/
|
||||||
if (adap->dev.parent == NULL)
|
if (adap->dev.parent == NULL) {
|
||||||
adap->dev.parent = &platform_bus;
|
adap->dev.parent = &platform_bus;
|
||||||
|
printk(KERN_WARNING "**WARNING** I2C adapter driver [%s] "
|
||||||
|
"forgot to specify physical device; fix it!\n",
|
||||||
|
adap->name);
|
||||||
|
}
|
||||||
sprintf(adap->dev.bus_id, "i2c-%d", adap->nr);
|
sprintf(adap->dev.bus_id, "i2c-%d", adap->nr);
|
||||||
adap->dev.driver = &i2c_adapter_driver;
|
adap->dev.driver = &i2c_adapter_driver;
|
||||||
adap->dev.release = &i2c_adapter_dev_release;
|
adap->dev.release = &i2c_adapter_dev_release;
|
||||||
|
Loading…
Reference in New Issue
Block a user