Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Revert "driver core: check start node in klist_iter_init_node"

This reverts commit a15d49fd3094cff90e5410ca454a870e0a722fe1 as that
patch broke the build.

Cc: Hannes Reinecke <hare@suse.de>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+46 -76
+17 -29
drivers/base/bus.c
··· 296 296 if (!bus) 297 297 return -EINVAL; 298 298 299 - error = klist_iter_init_node(&bus->p->klist_devices, &i, 300 - (start ? &start->p->knode_bus : NULL)); 301 - if (!error) { 302 - while ((dev = next_device(&i)) && !error) 303 - error = fn(dev, data); 304 - klist_iter_exit(&i); 305 - } 299 + klist_iter_init_node(&bus->p->klist_devices, &i, 300 + (start ? &start->p->knode_bus : NULL)); 301 + while ((dev = next_device(&i)) && !error) 302 + error = fn(dev, data); 303 + klist_iter_exit(&i); 306 304 return error; 307 305 } 308 306 EXPORT_SYMBOL_GPL(bus_for_each_dev); ··· 330 332 if (!bus) 331 333 return NULL; 332 334 333 - if (klist_iter_init_node(&bus->p->klist_devices, &i, 334 - (start ? &start->p->knode_bus : NULL)) < 0) 335 - return NULL; 336 - 335 + klist_iter_init_node(&bus->p->klist_devices, &i, 336 + (start ? &start->p->knode_bus : NULL)); 337 337 while ((dev = next_device(&i))) 338 338 if (match(dev, data) && get_device(dev)) 339 339 break; ··· 384 388 return NULL; 385 389 386 390 if (hint) { 387 - if (klist_iter_init_node(&subsys->p->klist_devices, &i, 388 - &hint->p->knode_bus) < 0) 389 - return NULL; 391 + klist_iter_init_node(&subsys->p->klist_devices, &i, &hint->p->knode_bus); 390 392 dev = next_device(&i); 391 393 if (dev && dev->id == id && get_device(dev)) { 392 394 klist_iter_exit(&i); ··· 446 452 if (!bus) 447 453 return -EINVAL; 448 454 449 - error = klist_iter_init_node(&bus->p->klist_drivers, &i, 450 - start ? &start->p->knode_bus : NULL); 451 - if (!error) { 452 - while ((drv = next_driver(&i)) && !error) 453 - error = fn(drv, data); 454 - klist_iter_exit(&i); 455 - } 455 + klist_iter_init_node(&bus->p->klist_drivers, &i, 456 + start ? &start->p->knode_bus : NULL); 457 + while ((drv = next_driver(&i)) && !error) 458 + error = fn(drv, data); 459 + klist_iter_exit(&i); 456 460 return error; 457 461 } 458 462 EXPORT_SYMBOL_GPL(bus_for_each_drv); ··· 1111 1119 * otherwise if it is NULL, the iteration starts at the beginning of 1112 1120 * the list. 1113 1121 */ 1114 - int subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys, 1115 - struct device *start, const struct device_type *type) 1122 + void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys, 1123 + struct device *start, const struct device_type *type) 1116 1124 { 1117 1125 struct klist_node *start_knode = NULL; 1118 - int error; 1119 1126 1120 1127 if (start) 1121 1128 start_knode = &start->p->knode_bus; 1122 - error = klist_iter_init_node(&subsys->p->klist_devices, &iter->ki, 1123 - start_knode); 1124 - if (!error) 1125 - iter->type = type; 1126 - return error; 1129 + klist_iter_init_node(&subsys->p->klist_devices, &iter->ki, start_knode); 1130 + iter->type = type; 1127 1131 } 1128 1132 EXPORT_SYMBOL_GPL(subsys_dev_iter_init); 1129 1133
+12 -20
drivers/base/class.c
··· 301 301 * otherwise if it is NULL, the iteration starts at the beginning of 302 302 * the list. 303 303 */ 304 - int class_dev_iter_init(struct class_dev_iter *iter, struct class *class, 305 - struct device *start, const struct device_type *type) 304 + void class_dev_iter_init(struct class_dev_iter *iter, struct class *class, 305 + struct device *start, const struct device_type *type) 306 306 { 307 307 struct klist_node *start_knode = NULL; 308 - int error; 309 308 310 309 if (start) 311 310 start_knode = &start->knode_class; 312 - error = klist_iter_init_node(&class->p->klist_devices, &iter->ki, 313 - start_knode); 314 - if (!error) 315 - iter->type = type; 316 - 317 - return error; 311 + klist_iter_init_node(&class->p->klist_devices, &iter->ki, start_knode); 312 + iter->type = type; 318 313 } 319 314 EXPORT_SYMBOL_GPL(class_dev_iter_init); 320 315 ··· 387 392 return -EINVAL; 388 393 } 389 394 390 - error = class_dev_iter_init(&iter, class, start, NULL); 391 - if (!error) { 392 - while ((dev = class_dev_iter_next(&iter))) { 393 - error = fn(dev, data); 394 - if (error) 395 - break; 396 - } 397 - class_dev_iter_exit(&iter); 395 + class_dev_iter_init(&iter, class, start, NULL); 396 + while ((dev = class_dev_iter_next(&iter))) { 397 + error = fn(dev, data); 398 + if (error) 399 + break; 398 400 } 401 + class_dev_iter_exit(&iter); 402 + 399 403 return error; 400 404 } 401 405 EXPORT_SYMBOL_GPL(class_for_each_device); ··· 434 440 return NULL; 435 441 } 436 442 437 - if (class_dev_iter_init(&iter, class, start, NULL) < 0) 438 - return NULL; 439 - 443 + class_dev_iter_init(&iter, class, start, NULL); 440 444 while ((dev = class_dev_iter_next(&iter))) { 441 445 if (match(dev, data)) { 442 446 get_device(dev);
+7 -11
drivers/base/driver.c
··· 49 49 if (!drv) 50 50 return -EINVAL; 51 51 52 - error = klist_iter_init_node(&drv->p->klist_devices, &i, 53 - start ? &start->p->knode_driver : NULL); 54 - if (!error) { 55 - while ((dev = next_device(&i)) && !error) 56 - error = fn(dev, data); 57 - klist_iter_exit(&i); 58 - } 52 + klist_iter_init_node(&drv->p->klist_devices, &i, 53 + start ? &start->p->knode_driver : NULL); 54 + while ((dev = next_device(&i)) && !error) 55 + error = fn(dev, data); 56 + klist_iter_exit(&i); 59 57 return error; 60 58 } 61 59 EXPORT_SYMBOL_GPL(driver_for_each_device); ··· 83 85 if (!drv) 84 86 return NULL; 85 87 86 - if (klist_iter_init_node(&drv->p->klist_devices, &i, 87 - (start ? &start->p->knode_driver : NULL)) < 0) 88 - return NULL; 89 - 88 + klist_iter_init_node(&drv->p->klist_devices, &i, 89 + (start ? &start->p->knode_driver : NULL)); 90 90 while ((dev = next_device(&i))) 91 91 if (match(dev, data) && get_device(dev)) 92 92 break;
+5 -5
include/linux/device.h
··· 128 128 struct klist_iter ki; 129 129 const struct device_type *type; 130 130 }; 131 - int subsys_dev_iter_init(struct subsys_dev_iter *iter, 131 + void subsys_dev_iter_init(struct subsys_dev_iter *iter, 132 132 struct bus_type *subsys, 133 133 struct device *start, 134 134 const struct device_type *type); ··· 380 380 void class_compat_remove_link(struct class_compat *cls, struct device *dev, 381 381 struct device *device_link); 382 382 383 - extern int class_dev_iter_init(struct class_dev_iter *iter, 384 - struct class *class, 385 - struct device *start, 386 - const struct device_type *type); 383 + extern void class_dev_iter_init(struct class_dev_iter *iter, 384 + struct class *class, 385 + struct device *start, 386 + const struct device_type *type); 387 387 extern struct device *class_dev_iter_next(struct class_dev_iter *iter); 388 388 extern void class_dev_iter_exit(struct class_dev_iter *iter); 389 389
+1 -1
include/linux/klist.h
··· 60 60 61 61 62 62 extern void klist_iter_init(struct klist *k, struct klist_iter *i); 63 - extern int klist_iter_init_node(struct klist *k, struct klist_iter *i, 63 + extern void klist_iter_init_node(struct klist *k, struct klist_iter *i, 64 64 struct klist_node *n); 65 65 extern void klist_iter_exit(struct klist_iter *i); 66 66 extern struct klist_node *klist_next(struct klist_iter *i);
+4 -10
lib/klist.c
··· 278 278 * Similar to klist_iter_init(), but starts the action off with @n, 279 279 * instead of with the list head. 280 280 */ 281 - int klist_iter_init_node(struct klist *k, struct klist_iter *i, 282 - struct klist_node *n) 281 + void klist_iter_init_node(struct klist *k, struct klist_iter *i, 282 + struct klist_node *n) 283 283 { 284 - if (n) { 285 - kref_get(&n->n_ref); 286 - if (!n->n_klist) { 287 - kref_put(&n->n_ref); 288 - return -ENODEV; 289 - } 290 - } 291 284 i->i_klist = k; 292 285 i->i_cur = n; 293 - return 0; 286 + if (n) 287 + kref_get(&n->n_ref); 294 288 } 295 289 EXPORT_SYMBOL_GPL(klist_iter_init_node); 296 290