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>

authored by David Brownell and committed by Jean Delvare b119dc3f 999445d4

+41 -4
+17
Documentation/feature-removal-schedule.txt
··· 226 226 227 227 --------------------------- 228 228 229 + What: i2c_adapter.dev 230 + i2c_adapter.list 231 + When: July 2007 232 + Why: Superfluous, given i2c_adapter.class_dev: 233 + * The "dev" was a stand-in for the physical device node that legacy 234 + drivers would not have; but now it's almost always present. Any 235 + remaining legacy drivers must upgrade (they now trigger warnings). 236 + * The "list" duplicates class device children. 237 + The delay in removing this is so upgraded lm_sensors and libsensors 238 + can get deployed. (Removal causes minor changes in the sysfs layout, 239 + notably the location of the adapter type name and parenting the i2c 240 + client hardware directly from their controller.) 241 + Who: Jean Delvare <khali@linux-fr.org>, 242 + David Brownell <dbrownell@users.sourceforge.net> 243 + 244 + --------------------------- 245 + 229 246 What: IPv4 only connection tracking/NAT/helpers 230 247 When: 2.6.22 231 248 Why: The new layer 3 independant connection tracking replaces the old
+24 -4
drivers/i2c/i2c-core.c
··· 95 95 .bus = &i2c_bus_type, 96 96 }; 97 97 98 + /* ------------------------------------------------------------------------- */ 99 + 100 + /* I2C bus adapters -- one roots each I2C or SMBUS segment */ 101 + 98 102 static void i2c_adapter_class_dev_release(struct class_device *dev) 99 103 { 100 104 struct i2c_adapter *adap = class_dev_to_i2c_adapter(dev); 101 105 complete(&adap->class_dev_released); 102 106 } 103 107 108 + static 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 + 114 + static struct class_device_attribute i2c_adapter_attrs[] = { 115 + __ATTR(name, S_IRUGO, i2c_adapter_show_name, NULL), 116 + { }, 117 + }; 118 + 104 119 struct class i2c_adapter_class = { 105 - .owner = THIS_MODULE, 106 - .name = "i2c-adapter", 107 - .release = &i2c_adapter_class_dev_release, 120 + .owner = THIS_MODULE, 121 + .name = "i2c-adapter", 122 + .class_dev_attrs = i2c_adapter_attrs, 123 + .release = &i2c_adapter_class_dev_release, 108 124 }; 109 125 110 126 static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf) ··· 191 175 * If the parent pointer is not set up, 192 176 * we add this adapter to the host bus. 193 177 */ 194 - if (adap->dev.parent == NULL) 178 + if (adap->dev.parent == NULL) { 195 179 adap->dev.parent = &platform_bus; 180 + printk(KERN_WARNING "**WARNING** I2C adapter driver [%s] " 181 + "forgot to specify physical device; fix it!\n", 182 + adap->name); 183 + } 196 184 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); 197 185 adap->dev.driver = &i2c_adapter_driver; 198 186 adap->dev.release = &i2c_adapter_dev_release;