aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/feature-removal-schedule.txt14
-rw-r--r--drivers/i2c/busses/i2c-isa.c18
-rw-r--r--drivers/i2c/i2c-core.c34
-rw-r--r--include/linux/i2c.h3
4 files changed, 5 insertions, 64 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index 5c88ba1ea262..c4b3bdad15d8 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -190,18 +190,10 @@ Who: Jean Delvare <khali@linux-fr.org>
190 190
191--------------------------- 191---------------------------
192 192
193What: i2c_adapter.dev 193What: i2c_adapter.list
194 i2c_adapter.list
195When: July 2007 194When: July 2007
196Why: Superfluous, given i2c_adapter.class_dev: 195Why: Superfluous, this list duplicates the one maintained by the driver
197 * The "dev" was a stand-in for the physical device node that legacy 196 core.
198 drivers would not have; but now it's almost always present. Any
199 remaining legacy drivers must upgrade (they now trigger warnings).
200 * The "list" duplicates class device children.
201 The delay in removing this is so upgraded lm_sensors and libsensors
202 can get deployed. (Removal causes minor changes in the sysfs layout,
203 notably the location of the adapter type name and parenting the i2c
204 client hardware directly from their controller.)
205Who: Jean Delvare <khali@linux-fr.org>, 197Who: Jean Delvare <khali@linux-fr.org>,
206 David Brownell <dbrownell@users.sourceforge.net> 198 David Brownell <dbrownell@users.sourceforge.net>
207 199
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c
index 5f33bc9c1e02..a2e75bc9178b 100644
--- a/drivers/i2c/busses/i2c-isa.c
+++ b/drivers/i2c/busses/i2c-isa.c
@@ -141,6 +141,7 @@ static int __init i2c_isa_init(void)
141 sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr); 141 sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr);
142 isa_adapter.dev.driver = &i2c_adapter_driver; 142 isa_adapter.dev.driver = &i2c_adapter_driver;
143 isa_adapter.dev.release = &i2c_adapter_dev_release; 143 isa_adapter.dev.release = &i2c_adapter_dev_release;
144 isa_adapter.dev.class = &i2c_adapter_class;
144 err = device_register(&isa_adapter.dev); 145 err = device_register(&isa_adapter.dev);
145 if (err) { 146 if (err) {
146 printk(KERN_ERR "i2c-isa: Failed to register device\n"); 147 printk(KERN_ERR "i2c-isa: Failed to register device\n");
@@ -152,24 +153,10 @@ static int __init i2c_isa_init(void)
152 goto exit_unregister; 153 goto exit_unregister;
153 } 154 }
154 155
155 /* Add this adapter to the i2c_adapter class */
156 memset(&isa_adapter.class_dev, 0x00, sizeof(struct class_device));
157 isa_adapter.class_dev.dev = &isa_adapter.dev;
158 isa_adapter.class_dev.class = &i2c_adapter_class;
159 strlcpy(isa_adapter.class_dev.class_id, isa_adapter.dev.bus_id,
160 BUS_ID_SIZE);
161 err = class_device_register(&isa_adapter.class_dev);
162 if (err) {
163 printk(KERN_ERR "i2c-isa: Failed to register class device\n");
164 goto exit_remove_name;
165 }
166
167 dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name); 156 dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name);
168 157
169 return 0; 158 return 0;
170 159
171exit_remove_name:
172 device_remove_file(&isa_adapter.dev, &dev_attr_name);
173exit_unregister: 160exit_unregister:
174 init_completion(&isa_adapter.dev_released); /* Needed? */ 161 init_completion(&isa_adapter.dev_released); /* Needed? */
175 device_unregister(&isa_adapter.dev); 162 device_unregister(&isa_adapter.dev);
@@ -201,15 +188,12 @@ static void __exit i2c_isa_exit(void)
201 /* Clean up the sysfs representation */ 188 /* Clean up the sysfs representation */
202 dev_dbg(&isa_adapter.dev, "Unregistering from sysfs\n"); 189 dev_dbg(&isa_adapter.dev, "Unregistering from sysfs\n");
203 init_completion(&isa_adapter.dev_released); 190 init_completion(&isa_adapter.dev_released);
204 init_completion(&isa_adapter.class_dev_released);
205 class_device_unregister(&isa_adapter.class_dev);
206 device_remove_file(&isa_adapter.dev, &dev_attr_name); 191 device_remove_file(&isa_adapter.dev, &dev_attr_name);
207 device_unregister(&isa_adapter.dev); 192 device_unregister(&isa_adapter.dev);
208 193
209 /* Wait for sysfs to drop all references */ 194 /* Wait for sysfs to drop all references */
210 dev_dbg(&isa_adapter.dev, "Waiting for sysfs completion\n"); 195 dev_dbg(&isa_adapter.dev, "Waiting for sysfs completion\n");
211 wait_for_completion(&isa_adapter.dev_released); 196 wait_for_completion(&isa_adapter.dev_released);
212 wait_for_completion(&isa_adapter.class_dev_released);
213 197
214 dev_dbg(&isa_adapter.dev, "%s unregistered\n", isa_adapter.name); 198 dev_dbg(&isa_adapter.dev, "%s unregistered\n", isa_adapter.name);
215} 199}
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 21fe1406c8b4..40a744d73e8c 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -123,28 +123,9 @@ struct device_driver i2c_adapter_driver = {
123 123
124/* I2C bus adapters -- one roots each I2C or SMBUS segment */ 124/* I2C bus adapters -- one roots each I2C or SMBUS segment */
125 125
126static void i2c_adapter_class_dev_release(struct class_device *dev)
127{
128 struct i2c_adapter *adap = class_dev_to_i2c_adapter(dev);
129 complete(&adap->class_dev_released);
130}
131
132static ssize_t i2c_adapter_show_name(struct class_device *cdev, char *buf)
133{
134 struct i2c_adapter *adap = class_dev_to_i2c_adapter(cdev);
135 return sprintf(buf, "%s\n", adap->name);
136}
137
138static struct class_device_attribute i2c_adapter_attrs[] = {
139 __ATTR(name, S_IRUGO, i2c_adapter_show_name, NULL),
140 { },
141};
142
143struct class i2c_adapter_class = { 126struct class i2c_adapter_class = {
144 .owner = THIS_MODULE, 127 .owner = THIS_MODULE,
145 .name = "i2c-adapter", 128 .name = "i2c-adapter",
146 .class_dev_attrs = i2c_adapter_attrs,
147 .release = &i2c_adapter_class_dev_release,
148}; 129};
149 130
150static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf) 131static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf)
@@ -223,6 +204,7 @@ int i2c_add_adapter(struct i2c_adapter *adap)
223 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr); 204 sprintf(adap->dev.bus_id, "i2c-%d", adap->nr);
224 adap->dev.driver = &i2c_adapter_driver; 205 adap->dev.driver = &i2c_adapter_driver;
225 adap->dev.release = &i2c_adapter_dev_release; 206 adap->dev.release = &i2c_adapter_dev_release;
207 adap->dev.class = &i2c_adapter_class;
226 res = device_register(&adap->dev); 208 res = device_register(&adap->dev);
227 if (res) 209 if (res)
228 goto out_list; 210 goto out_list;
@@ -230,15 +212,6 @@ int i2c_add_adapter(struct i2c_adapter *adap)
230 if (res) 212 if (res)
231 goto out_unregister; 213 goto out_unregister;
232 214
233 /* Add this adapter to the i2c_adapter class */
234 memset(&adap->class_dev, 0x00, sizeof(struct class_device));
235 adap->class_dev.dev = &adap->dev;
236 adap->class_dev.class = &i2c_adapter_class;
237 strlcpy(adap->class_dev.class_id, adap->dev.bus_id, BUS_ID_SIZE);
238 res = class_device_register(&adap->class_dev);
239 if (res)
240 goto out_remove_name;
241
242 dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); 215 dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
243 216
244 /* inform drivers of new adapters */ 217 /* inform drivers of new adapters */
@@ -253,8 +226,6 @@ out_unlock:
253 mutex_unlock(&core_lists); 226 mutex_unlock(&core_lists);
254 return res; 227 return res;
255 228
256out_remove_name:
257 device_remove_file(&adap->dev, &dev_attr_name);
258out_unregister: 229out_unregister:
259 init_completion(&adap->dev_released); /* Needed? */ 230 init_completion(&adap->dev_released); /* Needed? */
260 device_unregister(&adap->dev); 231 device_unregister(&adap->dev);
@@ -314,15 +285,12 @@ int i2c_del_adapter(struct i2c_adapter *adap)
314 285
315 /* clean up the sysfs representation */ 286 /* clean up the sysfs representation */
316 init_completion(&adap->dev_released); 287 init_completion(&adap->dev_released);
317 init_completion(&adap->class_dev_released);
318 class_device_unregister(&adap->class_dev);
319 device_remove_file(&adap->dev, &dev_attr_name); 288 device_remove_file(&adap->dev, &dev_attr_name);
320 device_unregister(&adap->dev); 289 device_unregister(&adap->dev);
321 list_del(&adap->list); 290 list_del(&adap->list);
322 291
323 /* wait for sysfs to drop all references */ 292 /* wait for sysfs to drop all references */
324 wait_for_completion(&adap->dev_released); 293 wait_for_completion(&adap->dev_released);
325 wait_for_completion(&adap->class_dev_released);
326 294
327 /* free dynamically allocated bus id */ 295 /* free dynamically allocated bus id */
328 idr_remove(&i2c_adapter_idr, adap->nr); 296 idr_remove(&i2c_adapter_idr, adap->nr);
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 9428092017e3..7a59dc656657 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -228,17 +228,14 @@ struct i2c_adapter {
228 int timeout; 228 int timeout;
229 int retries; 229 int retries;
230 struct device dev; /* the adapter device */ 230 struct device dev; /* the adapter device */
231 struct class_device class_dev; /* the class device */
232 231
233 int nr; 232 int nr;
234 struct list_head clients; 233 struct list_head clients;
235 struct list_head list; 234 struct list_head list;
236 char name[I2C_NAME_SIZE]; 235 char name[I2C_NAME_SIZE];
237 struct completion dev_released; 236 struct completion dev_released;
238 struct completion class_dev_released;
239}; 237};
240#define dev_to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) 238#define dev_to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev)
241#define class_dev_to_i2c_adapter(d) container_of(d, struct i2c_adapter, class_dev)
242 239
243static inline void *i2c_get_adapdata (struct i2c_adapter *dev) 240static inline void *i2c_get_adapdata (struct i2c_adapter *dev)
244{ 241{