aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/i2c-core.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r--drivers/i2c/i2c-core.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 7bfd67f4143d..1e3e1a5b4d86 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -107,28 +107,32 @@ struct bus_type i2c_bus_type = {
107 107
108/* ------------------------------------------------------------------------- */ 108/* ------------------------------------------------------------------------- */
109 109
110/* I2C bus adapters -- one roots each I2C or SMBUS segment */
111
110void i2c_adapter_dev_release(struct device *dev) 112void i2c_adapter_dev_release(struct device *dev)
111{ 113{
112 struct i2c_adapter *adap = dev_to_i2c_adapter(dev); 114 struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
113 complete(&adap->dev_released); 115 complete(&adap->dev_released);
114} 116}
115 117
116/* ------------------------------------------------------------------------- */ 118static ssize_t
119show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf)
120{
121 struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
122 return sprintf(buf, "%s\n", adap->name);
123}
117 124
118/* I2C bus adapters -- one roots each I2C or SMBUS segment */ 125static struct device_attribute i2c_adapter_attrs[] = {
126 __ATTR(name, S_IRUGO, show_adapter_name, NULL),
127 { },
128};
119 129
120struct class i2c_adapter_class = { 130struct class i2c_adapter_class = {
121 .owner = THIS_MODULE, 131 .owner = THIS_MODULE,
122 .name = "i2c-adapter", 132 .name = "i2c-adapter",
133 .dev_attrs = i2c_adapter_attrs,
123}; 134};
124 135
125static ssize_t show_adapter_name(struct device *dev, struct device_attribute *attr, char *buf)
126{
127 struct i2c_adapter *adap = dev_to_i2c_adapter(dev);
128 return sprintf(buf, "%s\n", adap->name);
129}
130static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL);
131
132 136
133static void i2c_client_release(struct device *dev) 137static void i2c_client_release(struct device *dev)
134{ 138{
@@ -201,9 +205,6 @@ int i2c_add_adapter(struct i2c_adapter *adap)
201 res = device_register(&adap->dev); 205 res = device_register(&adap->dev);
202 if (res) 206 if (res)
203 goto out_list; 207 goto out_list;
204 res = device_create_file(&adap->dev, &dev_attr_name);
205 if (res)
206 goto out_unregister;
207 208
208 dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); 209 dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name);
209 210
@@ -219,10 +220,6 @@ out_unlock:
219 mutex_unlock(&core_lists); 220 mutex_unlock(&core_lists);
220 return res; 221 return res;
221 222
222out_unregister:
223 init_completion(&adap->dev_released); /* Needed? */
224 device_unregister(&adap->dev);
225 wait_for_completion(&adap->dev_released);
226out_list: 223out_list:
227 list_del(&adap->list); 224 list_del(&adap->list);
228 idr_remove(&i2c_adapter_idr, adap->nr); 225 idr_remove(&i2c_adapter_idr, adap->nr);
@@ -278,7 +275,6 @@ int i2c_del_adapter(struct i2c_adapter *adap)
278 275
279 /* clean up the sysfs representation */ 276 /* clean up the sysfs representation */
280 init_completion(&adap->dev_released); 277 init_completion(&adap->dev_released);
281 device_remove_file(&adap->dev, &dev_attr_name);
282 device_unregister(&adap->dev); 278 device_unregister(&adap->dev);
283 list_del(&adap->list); 279 list_del(&adap->list);
284 280