Commit 607cf4d9aa1d766890f42fc892d39d48cf6d6c16

Authored by Greg Kroah-Hartman
1 parent 4f5ca09e0b

[PATCH] I2O: Clean up some pretty bad driver model abuses in the i2o code

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Showing 2 changed files with 11 additions and 13 deletions Side-by-side Diff

drivers/message/i2o/iop.c
... ... @@ -833,6 +833,7 @@
833 833 list_for_each_entry_safe(dev, tmp, &c->devices, list)
834 834 i2o_device_remove(dev);
835 835  
  836 + class_device_unregister(c->classdev);
836 837 device_del(&c->device);
837 838  
838 839 /* Ask the IOP to switch to RESET state */
... ... @@ -1077,9 +1078,7 @@
1077 1078 };
1078 1079  
1079 1080 /* I2O controller class */
1080   -static struct class i2o_controller_class = {
1081   - .name = "i2o_controller",
1082   -};
  1081 +static struct class *i2o_controller_class;
1083 1082  
1084 1083 /**
1085 1084 * i2o_iop_alloc - Allocate and initialize a i2o_controller struct
1086 1085  
1087 1086  
... ... @@ -1110,14 +1109,10 @@
1110 1109 sprintf(c->name, "iop%d", c->unit);
1111 1110  
1112 1111 device_initialize(&c->device);
1113   - class_device_initialize(&c->classdev);
1114 1112  
1115 1113 c->device.release = &i2o_iop_release;
1116   - c->classdev.class = &i2o_controller_class;
1117   - c->classdev.dev = &c->device;
1118 1114  
1119 1115 snprintf(c->device.bus_id, BUS_ID_SIZE, "iop%d", c->unit);
1120   - snprintf(c->classdev.class_id, BUS_ID_SIZE, "iop%d", c->unit);
1121 1116  
1122 1117 #if BITS_PER_LONG == 64
1123 1118 spin_lock_init(&c->context_list_lock);
... ... @@ -1146,7 +1141,9 @@
1146 1141 goto iop_reset;
1147 1142 }
1148 1143  
1149   - if ((rc = class_device_add(&c->classdev))) {
  1144 + c->classdev = class_device_create(i2o_controller_class, 0,
  1145 + &c->device, "iop%d", c->unit);
  1146 + if (IS_ERR(c->classdev)) {
1150 1147 osm_err("%s: could not add controller class\n", c->name);
1151 1148 goto device_del;
1152 1149 }
... ... @@ -1184,7 +1181,7 @@
1184 1181 return 0;
1185 1182  
1186 1183 class_del:
1187   - class_device_del(&c->classdev);
  1184 + class_device_unregister(c->classdev);
1188 1185  
1189 1186 device_del:
1190 1187 device_del(&c->device);
... ... @@ -1250,7 +1247,8 @@
1250 1247 if (rc)
1251 1248 goto exit;
1252 1249  
1253   - if ((rc = class_register(&i2o_controller_class))) {
  1250 + i2o_controller_class = class_create(THIS_MODULE, "i2o_controller");
  1251 + if (IS_ERR(i2o_controller_class)) {
1254 1252 osm_err("can't register class i2o_controller\n");
1255 1253 goto device_exit;
1256 1254 }
... ... @@ -1273,7 +1271,7 @@
1273 1271 i2o_driver_exit();
1274 1272  
1275 1273 class_exit:
1276   - class_unregister(&i2o_controller_class);
  1274 + class_destroy(i2o_controller_class);
1277 1275  
1278 1276 device_exit:
1279 1277 i2o_device_exit();
... ... @@ -1292,7 +1290,7 @@
1292 1290 i2o_pci_exit();
1293 1291 i2o_exec_exit();
1294 1292 i2o_driver_exit();
1295   - class_unregister(&i2o_controller_class);
  1293 + class_destroy(i2o_controller_class);
1296 1294 i2o_device_exit();
1297 1295 };
1298 1296  
... ... @@ -194,7 +194,7 @@
194 194 struct resource mem_resource; /* Mem resource allocated to the IOP */
195 195  
196 196 struct device device;
197   - struct class_device classdev; /* I2O controller class */
  197 + struct class_device *classdev; /* I2O controller class device */
198 198 struct i2o_device *exec; /* Executive */
199 199 #if BITS_PER_LONG == 64
200 200 spinlock_t context_list_lock; /* lock for context_list */