aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message
diff options
context:
space:
mode:
authorMarkus Lidel <Markus.Lidel@shadowconnect.com>2006-01-06 03:19:31 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-06 11:33:54 -0500
commit24791bd48f643194d806654b587251b0f92233e8 (patch)
treec95c4db1a565146e3c1d565ba1b796e78d88d556 /drivers/message
parent793fd15d9fafe5b1c71e50d3c041f1463895dbde (diff)
[PATCH] I2O: Remove wrong I2O device class
Removed wrong I2O device class, which was only needed to add sysfs attributes. Signed-off-by: Markus Lidel <Markus.Lidel@shadowconnect.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/message')
-rw-r--r--drivers/message/i2o/core.h2
-rw-r--r--drivers/message/i2o/device.c144
-rw-r--r--drivers/message/i2o/driver.c2
-rw-r--r--drivers/message/i2o/iop.c34
4 files changed, 68 insertions, 114 deletions
diff --git a/drivers/message/i2o/core.h b/drivers/message/i2o/core.h
index 9eefedb16211..9aa9b91170b2 100644
--- a/drivers/message/i2o/core.h
+++ b/drivers/message/i2o/core.h
@@ -33,6 +33,8 @@ extern int __init i2o_pci_init(void);
33extern void __exit i2o_pci_exit(void); 33extern void __exit i2o_pci_exit(void);
34 34
35/* device */ 35/* device */
36extern struct device_attribute i2o_device_attrs[];
37
36extern void i2o_device_remove(struct i2o_device *); 38extern void i2o_device_remove(struct i2o_device *);
37extern int i2o_device_parse_lct(struct i2o_controller *); 39extern int i2o_device_parse_lct(struct i2o_controller *);
38 40
diff --git a/drivers/message/i2o/device.c b/drivers/message/i2o/device.c
index 1db26215937f..a5e260b7a3b6 100644
--- a/drivers/message/i2o/device.c
+++ b/drivers/message/i2o/device.c
@@ -142,8 +142,9 @@ static void i2o_device_release(struct device *dev)
142 142
143 143
144/** 144/**
145 * i2o_device_class_show_class_id - Displays class id of I2O device 145 * i2o_device_show_class_id - Displays class id of I2O device
146 * @cd: class device of which the class id should be displayed 146 * @dev: device of which the class id should be displayed
147 * @attr: pointer to device attribute
147 * @buf: buffer into which the class id should be printed 148 * @buf: buffer into which the class id should be printed
148 * 149 *
149 * Returns the number of bytes which are printed into the buffer. 150 * Returns the number of bytes which are printed into the buffer.
@@ -159,15 +160,15 @@ static ssize_t i2o_device_show_class_id(struct device *dev,
159} 160}
160 161
161/** 162/**
162 * i2o_device_class_show_tid - Displays TID of I2O device 163 * i2o_device_show_tid - Displays TID of I2O device
163 * @cd: class device of which the TID should be displayed 164 * @dev: device of which the TID should be displayed
164 * @buf: buffer into which the class id should be printed 165 * @attr: pointer to device attribute
166 * @buf: buffer into which the TID should be printed
165 * 167 *
166 * Returns the number of bytes which are printed into the buffer. 168 * Returns the number of bytes which are printed into the buffer.
167 */ 169 */
168static ssize_t i2o_device_show_tid(struct device *dev, 170static ssize_t i2o_device_show_tid(struct device *dev,
169 struct device_attribute *attr, 171 struct device_attribute *attr, char *buf)
170 char *buf)
171{ 172{
172 struct i2o_device *i2o_dev = to_i2o_device(dev); 173 struct i2o_device *i2o_dev = to_i2o_device(dev);
173 174
@@ -209,66 +210,6 @@ static struct i2o_device *i2o_device_alloc(void)
209} 210}
210 211
211/** 212/**
212 * i2o_setup_sysfs_links - Adds attributes to the I2O device
213 * @cd: I2O class device which is added to the I2O device class
214 *
215 * This function get called when a I2O device is added to the class. It
216 * creates the attributes for each device and creates user/parent symlink
217 * if necessary.
218 *
219 * Returns 0 on success or negative error code on failure.
220 */
221static void i2o_setup_sysfs_links(struct i2o_device *i2o_dev)
222{
223 struct i2o_controller *c = i2o_dev->iop;
224 struct i2o_device *tmp;
225
226 /* create user entries for this device */
227 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
228 if (tmp && tmp != i2o_dev)
229 sysfs_create_link(&i2o_dev->device.kobj,
230 &tmp->device.kobj, "user");
231
232 /* create user entries refering to this device */
233 list_for_each_entry(tmp, &c->devices, list)
234 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid &&
235 tmp != i2o_dev)
236 sysfs_create_link(&tmp->device.kobj,
237 &i2o_dev->device.kobj, "user");
238
239 /* create parent entries for this device */
240 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
241 if (tmp && tmp != i2o_dev)
242 sysfs_create_link(&i2o_dev->device.kobj,
243 &tmp->device.kobj, "parent");
244
245 /* create parent entries refering to this device */
246 list_for_each_entry(tmp, &c->devices, list)
247 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid &&
248 tmp != i2o_dev)
249 sysfs_create_link(&tmp->device.kobj,
250 &i2o_dev->device.kobj, "parent");
251}
252
253static void i2o_remove_sysfs_links(struct i2o_device *i2o_dev)
254{
255 struct i2o_controller *c = i2o_dev->iop;
256 struct i2o_device *tmp;
257
258 sysfs_remove_link(&i2o_dev->device.kobj, "parent");
259 sysfs_remove_link(&i2o_dev->device.kobj, "user");
260
261 list_for_each_entry(tmp, &c->devices, list) {
262 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
263 sysfs_remove_link(&tmp->device.kobj, "parent");
264 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
265 sysfs_remove_link(&tmp->device.kobj, "user");
266 }
267}
268
269
270
271/**
272 * i2o_device_add - allocate a new I2O device and add it to the IOP 213 * i2o_device_add - allocate a new I2O device and add it to the IOP
273 * @iop: I2O controller where the device is on 214 * @iop: I2O controller where the device is on
274 * @entry: LCT entry of the I2O device 215 * @entry: LCT entry of the I2O device
@@ -282,33 +223,57 @@ static void i2o_remove_sysfs_links(struct i2o_device *i2o_dev)
282static struct i2o_device *i2o_device_add(struct i2o_controller *c, 223static struct i2o_device *i2o_device_add(struct i2o_controller *c,
283 i2o_lct_entry * entry) 224 i2o_lct_entry * entry)
284{ 225{
285 struct i2o_device *dev; 226 struct i2o_device *i2o_dev, *tmp;
286 227
287 dev = i2o_device_alloc(); 228 i2o_dev = i2o_device_alloc();
288 if (IS_ERR(dev)) { 229 if (IS_ERR(i2o_dev)) {
289 printk(KERN_ERR "i2o: unable to allocate i2o device\n"); 230 printk(KERN_ERR "i2o: unable to allocate i2o device\n");
290 return dev; 231 return i2o_dev;
291 } 232 }
292 233
293 dev->lct_data = *entry; 234 i2o_dev->lct_data = *entry;
294 dev->iop = c;
295 235
296 snprintf(dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit, 236 snprintf(i2o_dev->device.bus_id, BUS_ID_SIZE, "%d:%03x", c->unit,
297 dev->lct_data.tid); 237 i2o_dev->lct_data.tid);
298 238
299 dev->device.parent = &c->device; 239 i2o_dev->iop = c;
240 i2o_dev->device.parent = &c->device;
300 241
301 device_register(&dev->device); 242 device_register(&i2o_dev->device);
302 243
303 list_add_tail(&dev->list, &c->devices); 244 list_add_tail(&i2o_dev->list, &c->devices);
304 245
305 i2o_setup_sysfs_links(dev); 246 /* create user entries for this device */
247 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
248 if (tmp && (tmp != i2o_dev))
249 sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj,
250 "user");
306 251
307 i2o_driver_notify_device_add_all(dev); 252 /* create user entries refering to this device */
253 list_for_each_entry(tmp, &c->devices, list)
254 if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
255 && (tmp != i2o_dev))
256 sysfs_create_link(&tmp->device.kobj,
257 &i2o_dev->device.kobj, "user");
308 258
309 pr_debug("i2o: device %s added\n", dev->device.bus_id); 259 /* create parent entries for this device */
260 tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
261 if (tmp && (tmp != i2o_dev))
262 sysfs_create_link(&i2o_dev->device.kobj, &tmp->device.kobj,
263 "parent");
310 264
311 return dev; 265 /* create parent entries refering to this device */
266 list_for_each_entry(tmp, &c->devices, list)
267 if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
268 && (tmp != i2o_dev))
269 sysfs_create_link(&tmp->device.kobj,
270 &i2o_dev->device.kobj, "parent");
271
272 i2o_driver_notify_device_add_all(i2o_dev);
273
274 pr_debug("i2o: device %s added\n", i2o_dev->device.bus_id);
275
276 return i2o_dev;
312} 277}
313 278
314/** 279/**
@@ -321,9 +286,22 @@ static struct i2o_device *i2o_device_add(struct i2o_controller *c,
321 */ 286 */
322void i2o_device_remove(struct i2o_device *i2o_dev) 287void i2o_device_remove(struct i2o_device *i2o_dev)
323{ 288{
289 struct i2o_device *tmp;
290 struct i2o_controller *c = i2o_dev->iop;
291
324 i2o_driver_notify_device_remove_all(i2o_dev); 292 i2o_driver_notify_device_remove_all(i2o_dev);
325 i2o_remove_sysfs_links(i2o_dev); 293
294 sysfs_remove_link(&i2o_dev->device.kobj, "parent");
295 sysfs_remove_link(&i2o_dev->device.kobj, "user");
296
297 list_for_each_entry(tmp, &c->devices, list) {
298 if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
299 sysfs_remove_link(&tmp->device.kobj, "parent");
300 if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
301 sysfs_remove_link(&tmp->device.kobj, "user");
302 }
326 list_del(&i2o_dev->list); 303 list_del(&i2o_dev->list);
304
327 device_unregister(&i2o_dev->device); 305 device_unregister(&i2o_dev->device);
328} 306}
329 307
diff --git a/drivers/message/i2o/driver.c b/drivers/message/i2o/driver.c
index 0fb9c4e2ad4c..25292b36e2d9 100644
--- a/drivers/message/i2o/driver.c
+++ b/drivers/message/i2o/driver.c
@@ -61,8 +61,6 @@ static int i2o_bus_match(struct device *dev, struct device_driver *drv)
61}; 61};
62 62
63/* I2O bus type */ 63/* I2O bus type */
64extern struct device_attribute i2o_device_attrs[];
65
66struct bus_type i2o_bus_type = { 64struct bus_type i2o_bus_type = {
67 .name = "i2o", 65 .name = "i2o",
68 .match = i2o_bus_match, 66 .match = i2o_bus_match,
diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
index f86abb42bf89..7411a0504bf2 100644
--- a/drivers/message/i2o/iop.c
+++ b/drivers/message/i2o/iop.c
@@ -806,7 +806,6 @@ void i2o_iop_remove(struct i2o_controller *c)
806 list_for_each_entry_safe(dev, tmp, &c->devices, list) 806 list_for_each_entry_safe(dev, tmp, &c->devices, list)
807 i2o_device_remove(dev); 807 i2o_device_remove(dev);
808 808
809 class_device_unregister(c->classdev);
810 device_del(&c->device); 809 device_del(&c->device);
811 810
812 /* Ask the IOP to switch to RESET state */ 811 /* Ask the IOP to switch to RESET state */
@@ -1050,9 +1049,6 @@ static void i2o_iop_release(struct device *dev)
1050 i2o_iop_free(c); 1049 i2o_iop_free(c);
1051}; 1050};
1052 1051
1053/* I2O controller class */
1054static struct class *i2o_controller_class;
1055
1056/** 1052/**
1057 * i2o_iop_alloc - Allocate and initialize a i2o_controller struct 1053 * i2o_iop_alloc - Allocate and initialize a i2o_controller struct
1058 * 1054 *
@@ -1124,36 +1120,29 @@ int i2o_iop_add(struct i2o_controller *c)
1124 goto iop_reset; 1120 goto iop_reset;
1125 } 1121 }
1126 1122
1127 c->classdev = class_device_create(i2o_controller_class, NULL, MKDEV(0,0),
1128 &c->device, "iop%d", c->unit);
1129 if (IS_ERR(c->classdev)) {
1130 osm_err("%s: could not add controller class\n", c->name);
1131 goto device_del;
1132 }
1133
1134 osm_info("%s: Activating I2O controller...\n", c->name); 1123 osm_info("%s: Activating I2O controller...\n", c->name);
1135 osm_info("%s: This may take a few minutes if there are many devices\n", 1124 osm_info("%s: This may take a few minutes if there are many devices\n",
1136 c->name); 1125 c->name);
1137 1126
1138 if ((rc = i2o_iop_activate(c))) { 1127 if ((rc = i2o_iop_activate(c))) {
1139 osm_err("%s: could not activate controller\n", c->name); 1128 osm_err("%s: could not activate controller\n", c->name);
1140 goto class_del; 1129 goto device_del;
1141 } 1130 }
1142 1131
1143 osm_debug("%s: building sys table...\n", c->name); 1132 osm_debug("%s: building sys table...\n", c->name);
1144 1133
1145 if ((rc = i2o_systab_build())) 1134 if ((rc = i2o_systab_build()))
1146 goto class_del; 1135 goto device_del;
1147 1136
1148 osm_debug("%s: online controller...\n", c->name); 1137 osm_debug("%s: online controller...\n", c->name);
1149 1138
1150 if ((rc = i2o_iop_online(c))) 1139 if ((rc = i2o_iop_online(c)))
1151 goto class_del; 1140 goto device_del;
1152 1141
1153 osm_debug("%s: getting LCT...\n", c->name); 1142 osm_debug("%s: getting LCT...\n", c->name);
1154 1143
1155 if ((rc = i2o_exec_lct_get(c))) 1144 if ((rc = i2o_exec_lct_get(c)))
1156 goto class_del; 1145 goto device_del;
1157 1146
1158 list_add(&c->list, &i2o_controllers); 1147 list_add(&c->list, &i2o_controllers);
1159 1148
@@ -1163,9 +1152,6 @@ int i2o_iop_add(struct i2o_controller *c)
1163 1152
1164 return 0; 1153 return 0;
1165 1154
1166 class_del:
1167 class_device_unregister(c->classdev);
1168
1169 device_del: 1155 device_del:
1170 device_del(&c->device); 1156 device_del(&c->device);
1171 1157
@@ -1225,14 +1211,8 @@ static int __init i2o_iop_init(void)
1225 1211
1226 printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); 1212 printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
1227 1213
1228 i2o_controller_class = class_create(THIS_MODULE, "i2o_controller");
1229 if (IS_ERR(i2o_controller_class)) {
1230 osm_err("can't register class i2o_controller\n");
1231 goto exit;
1232 }
1233
1234 if ((rc = i2o_driver_init())) 1214 if ((rc = i2o_driver_init()))
1235 goto class_exit; 1215 goto exit;
1236 1216
1237 if ((rc = i2o_exec_init())) 1217 if ((rc = i2o_exec_init()))
1238 goto driver_exit; 1218 goto driver_exit;
@@ -1248,9 +1228,6 @@ static int __init i2o_iop_init(void)
1248 driver_exit: 1228 driver_exit:
1249 i2o_driver_exit(); 1229 i2o_driver_exit();
1250 1230
1251 class_exit:
1252 class_destroy(i2o_controller_class);
1253
1254 exit: 1231 exit:
1255 return rc; 1232 return rc;
1256} 1233}
@@ -1265,7 +1242,6 @@ static void __exit i2o_iop_exit(void)
1265 i2o_pci_exit(); 1242 i2o_pci_exit();
1266 i2o_exec_exit(); 1243 i2o_exec_exit();
1267 i2o_driver_exit(); 1244 i2o_driver_exit();
1268 class_destroy(i2o_controller_class);
1269}; 1245};
1270 1246
1271module_init(i2o_iop_init); 1247module_init(i2o_iop_init);