diff options
Diffstat (limited to 'drivers/i2c/busses/i2c-isa.c')
-rw-r--r-- | drivers/i2c/busses/i2c-isa.c | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/drivers/i2c/busses/i2c-isa.c b/drivers/i2c/busses/i2c-isa.c index 5f33bc9c1e02..b0e1370075de 100644 --- a/drivers/i2c/busses/i2c-isa.c +++ b/drivers/i2c/busses/i2c-isa.c | |||
@@ -41,6 +41,10 @@ | |||
41 | #include <linux/platform_device.h> | 41 | #include <linux/platform_device.h> |
42 | #include <linux/completion.h> | 42 | #include <linux/completion.h> |
43 | 43 | ||
44 | /* Exported by i2c-core for i2c-isa only */ | ||
45 | extern void i2c_adapter_dev_release(struct device *dev); | ||
46 | extern struct class i2c_adapter_class; | ||
47 | |||
44 | static u32 isa_func(struct i2c_adapter *adapter); | 48 | static u32 isa_func(struct i2c_adapter *adapter); |
45 | 49 | ||
46 | /* This is the actual algorithm we define */ | 50 | /* This is the actual algorithm we define */ |
@@ -64,16 +68,6 @@ static u32 isa_func(struct i2c_adapter *adapter) | |||
64 | } | 68 | } |
65 | 69 | ||
66 | 70 | ||
67 | /* Copied from i2c-core */ | ||
68 | static ssize_t show_adapter_name(struct device *dev, | ||
69 | struct device_attribute *attr, char *buf) | ||
70 | { | ||
71 | struct i2c_adapter *adap = dev_to_i2c_adapter(dev); | ||
72 | return sprintf(buf, "%s\n", adap->name); | ||
73 | } | ||
74 | static DEVICE_ATTR(name, S_IRUGO, show_adapter_name, NULL); | ||
75 | |||
76 | |||
77 | /* We implement an interface which resembles i2c_{add,del}_driver, | 71 | /* We implement an interface which resembles i2c_{add,del}_driver, |
78 | but for i2c-isa drivers. We don't have to remember and handle lists | 72 | but for i2c-isa drivers. We don't have to remember and handle lists |
79 | of drivers and adapters so this is much more simple, of course. */ | 73 | of drivers and adapters so this is much more simple, of course. */ |
@@ -139,41 +133,18 @@ static int __init i2c_isa_init(void) | |||
139 | isa_adapter.nr = ANY_I2C_ISA_BUS; | 133 | isa_adapter.nr = ANY_I2C_ISA_BUS; |
140 | isa_adapter.dev.parent = &platform_bus; | 134 | isa_adapter.dev.parent = &platform_bus; |
141 | sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr); | 135 | sprintf(isa_adapter.dev.bus_id, "i2c-%d", isa_adapter.nr); |
142 | isa_adapter.dev.driver = &i2c_adapter_driver; | ||
143 | isa_adapter.dev.release = &i2c_adapter_dev_release; | 136 | isa_adapter.dev.release = &i2c_adapter_dev_release; |
137 | isa_adapter.dev.class = &i2c_adapter_class; | ||
144 | err = device_register(&isa_adapter.dev); | 138 | err = device_register(&isa_adapter.dev); |
145 | if (err) { | 139 | if (err) { |
146 | printk(KERN_ERR "i2c-isa: Failed to register device\n"); | 140 | printk(KERN_ERR "i2c-isa: Failed to register device\n"); |
147 | goto exit; | 141 | goto exit; |
148 | } | 142 | } |
149 | err = device_create_file(&isa_adapter.dev, &dev_attr_name); | ||
150 | if (err) { | ||
151 | printk(KERN_ERR "i2c-isa: Failed to create name file\n"); | ||
152 | goto exit_unregister; | ||
153 | } | ||
154 | |||
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 | 143 | ||
167 | dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name); | 144 | dev_dbg(&isa_adapter.dev, "%s registered\n", isa_adapter.name); |
168 | 145 | ||
169 | return 0; | 146 | return 0; |
170 | 147 | ||
171 | exit_remove_name: | ||
172 | device_remove_file(&isa_adapter.dev, &dev_attr_name); | ||
173 | exit_unregister: | ||
174 | init_completion(&isa_adapter.dev_released); /* Needed? */ | ||
175 | device_unregister(&isa_adapter.dev); | ||
176 | wait_for_completion(&isa_adapter.dev_released); | ||
177 | exit: | 148 | exit: |
178 | return err; | 149 | return err; |
179 | } | 150 | } |
@@ -201,15 +172,11 @@ static void __exit i2c_isa_exit(void) | |||
201 | /* Clean up the sysfs representation */ | 172 | /* Clean up the sysfs representation */ |
202 | dev_dbg(&isa_adapter.dev, "Unregistering from sysfs\n"); | 173 | dev_dbg(&isa_adapter.dev, "Unregistering from sysfs\n"); |
203 | init_completion(&isa_adapter.dev_released); | 174 | 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); | ||
207 | device_unregister(&isa_adapter.dev); | 175 | device_unregister(&isa_adapter.dev); |
208 | 176 | ||
209 | /* Wait for sysfs to drop all references */ | 177 | /* Wait for sysfs to drop all references */ |
210 | dev_dbg(&isa_adapter.dev, "Waiting for sysfs completion\n"); | 178 | dev_dbg(&isa_adapter.dev, "Waiting for sysfs completion\n"); |
211 | wait_for_completion(&isa_adapter.dev_released); | 179 | wait_for_completion(&isa_adapter.dev_released); |
212 | wait_for_completion(&isa_adapter.class_dev_released); | ||
213 | 180 | ||
214 | dev_dbg(&isa_adapter.dev, "%s unregistered\n", isa_adapter.name); | 181 | dev_dbg(&isa_adapter.dev, "%s unregistered\n", isa_adapter.name); |
215 | } | 182 | } |