aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2007-01-04 07:07:04 -0500
committerJean Delvare <khali@arrakis.delvare>2007-01-04 07:07:04 -0500
commitb119dc3f992183a04e508fc0a09f550eb19bf30e (patch)
tree554c4ff65d6585448ae207da06e127bbc15b2ad7 /drivers/i2c
parent999445d4372812f361807b76411c158099e8e93e (diff)
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>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/i2c-core.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 3e31f1d265c9..b05378a3d673 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -95,16 +95,32 @@ struct device_driver i2c_adapter_driver = {
95 .bus = &i2c_bus_type, 95 .bus = &i2c_bus_type,
96}; 96};
97 97
98/* ------------------------------------------------------------------------- */
99
100/* I2C bus adapters -- one roots each I2C or SMBUS segment */
101
98static void i2c_adapter_class_dev_release(struct class_device *dev) 102static void i2c_adapter_class_dev_release(struct class_device *dev)
99{ 103{
100 struct i2c_adapter *adap = class_dev_to_i2c_adapter(dev); 104 struct i2c_adapter *adap = class_dev_to_i2c_adapter(dev);
101 complete(&adap->class_dev_released); 105 complete(&adap->class_dev_released);
102} 106}
103 107
108static ssize_t i2c_adapter_show_name(struct class_device *cdev, char *buf)
109{
110 struct i2c_adapter *adap = class_dev_to_i2c_adapter(cdev);
111 return sprintf(buf, "%s\n", adap->name);
112}
113
114static struct class_device_attribute i2c_adapter_attrs[] = {
115 __ATTR(name, S_IRUGO, i2c_adapter_show_name, NULL),
116 { },
117};
118
104struct class i2c_adapter_class = { 119struct class i2c_adapter_class = {
105 .owner = THIS_MODULE, 120 .owner = THIS_MODULE,
106 .name = "i2c-adapter", 121 .name = "i2c-adapter",
107 .release = &i2c_adapter_class_dev_release, 122 .class_dev_attrs = i2c_adapter_attrs,
123 .release = &i2c_adapter_class_dev_release,
108}; 124};
109 125
110static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf) 126static 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)
175 * If the parent pointer is not set up, 191 * If the parent pointer is not set up,
176 * we add this adapter to the host bus. 192 * we add this adapter to the host bus.
177 */ 193 */
178 if (adap->dev.parent == NULL) 194 if (adap->dev.parent == NULL) {
179 adap->dev.parent = &platform_bus; 195 adap->dev.parent = &platform_bus;
196 printk(KERN_WARNING "**WARNING** I2C adapter driver [%s] "
197 "forgot to specify physical device; fix it!\n",
198 adap->name);
199 }
180 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); 200 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr);
181 adap->dev.driver = &i2c_adapter_driver; 201 adap->dev.driver = &i2c_adapter_driver;
182 adap->dev.release = &i2c_adapter_dev_release; 202 adap->dev.release = &i2c_adapter_dev_release;