if (!bus)
return -EINVAL;
- error = klist_iter_init_node(&bus->p->klist_devices, &i,
- (start ? &start->p->knode_bus : NULL));
- if (!error) {
- while ((dev = next_device(&i)) && !error)
- error = fn(dev, data);
- klist_iter_exit(&i);
- }
+ klist_iter_init_node(&bus->p->klist_devices, &i,
+ (start ? &start->p->knode_bus : NULL));
+ while ((dev = next_device(&i)) && !error)
+ error = fn(dev, data);
+ klist_iter_exit(&i);
return error;
}
EXPORT_SYMBOL_GPL(bus_for_each_dev);
if (!bus)
return NULL;
- if (klist_iter_init_node(&bus->p->klist_devices, &i,
- (start ? &start->p->knode_bus : NULL)) < 0)
- return NULL;
-
+ klist_iter_init_node(&bus->p->klist_devices, &i,
+ (start ? &start->p->knode_bus : NULL));
while ((dev = next_device(&i)))
if (match(dev, data) && get_device(dev))
break;
return NULL;
if (hint) {
- if (klist_iter_init_node(&subsys->p->klist_devices, &i,
- &hint->p->knode_bus) < 0)
- return NULL;
+ klist_iter_init_node(&subsys->p->klist_devices, &i, &hint->p->knode_bus);
dev = next_device(&i);
if (dev && dev->id == id && get_device(dev)) {
klist_iter_exit(&i);
if (!bus)
return -EINVAL;
- error = klist_iter_init_node(&bus->p->klist_drivers, &i,
- start ? &start->p->knode_bus : NULL);
- if (!error) {
- while ((drv = next_driver(&i)) && !error)
- error = fn(drv, data);
- klist_iter_exit(&i);
- }
+ klist_iter_init_node(&bus->p->klist_drivers, &i,
+ start ? &start->p->knode_bus : NULL);
+ while ((drv = next_driver(&i)) && !error)
+ error = fn(drv, data);
+ klist_iter_exit(&i);
return error;
}
EXPORT_SYMBOL_GPL(bus_for_each_drv);
* otherwise if it is NULL, the iteration starts at the beginning of
* the list.
*/
-int subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys,
- struct device *start, const struct device_type *type)
+void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys,
+ struct device *start, const struct device_type *type)
{
struct klist_node *start_knode = NULL;
- int error;
if (start)
start_knode = &start->p->knode_bus;
- error = klist_iter_init_node(&subsys->p->klist_devices, &iter->ki,
- start_knode);
- if (!error)
- iter->type = type;
- return error;
+ klist_iter_init_node(&subsys->p->klist_devices, &iter->ki, start_knode);
+ iter->type = type;
}
EXPORT_SYMBOL_GPL(subsys_dev_iter_init);
* otherwise if it is NULL, the iteration starts at the beginning of
* the list.
*/
-int class_dev_iter_init(struct class_dev_iter *iter, struct class *class,
- struct device *start, const struct device_type *type)
+void class_dev_iter_init(struct class_dev_iter *iter, struct class *class,
+ struct device *start, const struct device_type *type)
{
struct klist_node *start_knode = NULL;
- int error;
if (start)
start_knode = &start->knode_class;
- error = klist_iter_init_node(&class->p->klist_devices, &iter->ki,
- start_knode);
- if (!error)
- iter->type = type;
-
- return error;
+ klist_iter_init_node(&class->p->klist_devices, &iter->ki, start_knode);
+ iter->type = type;
}
EXPORT_SYMBOL_GPL(class_dev_iter_init);
return -EINVAL;
}
- error = class_dev_iter_init(&iter, class, start, NULL);
- if (!error) {
- while ((dev = class_dev_iter_next(&iter))) {
- error = fn(dev, data);
- if (error)
- break;
- }
- class_dev_iter_exit(&iter);
+ class_dev_iter_init(&iter, class, start, NULL);
+ while ((dev = class_dev_iter_next(&iter))) {
+ error = fn(dev, data);
+ if (error)
+ break;
}
+ class_dev_iter_exit(&iter);
+
return error;
}
EXPORT_SYMBOL_GPL(class_for_each_device);
return NULL;
}
- if (class_dev_iter_init(&iter, class, start, NULL) < 0)
- return NULL;
-
+ class_dev_iter_init(&iter, class, start, NULL);
while ((dev = class_dev_iter_next(&iter))) {
if (match(dev, data)) {
get_device(dev);
if (!drv)
return -EINVAL;
- error = klist_iter_init_node(&drv->p->klist_devices, &i,
- start ? &start->p->knode_driver : NULL);
- if (!error) {
- while ((dev = next_device(&i)) && !error)
- error = fn(dev, data);
- klist_iter_exit(&i);
- }
+ klist_iter_init_node(&drv->p->klist_devices, &i,
+ start ? &start->p->knode_driver : NULL);
+ while ((dev = next_device(&i)) && !error)
+ error = fn(dev, data);
+ klist_iter_exit(&i);
return error;
}
EXPORT_SYMBOL_GPL(driver_for_each_device);
if (!drv)
return NULL;
- if (klist_iter_init_node(&drv->p->klist_devices, &i,
- (start ? &start->p->knode_driver : NULL)) < 0)
- return NULL;
-
+ klist_iter_init_node(&drv->p->klist_devices, &i,
+ (start ? &start->p->knode_driver : NULL));
while ((dev = next_device(&i)))
if (match(dev, data) && get_device(dev))
break;
struct klist_iter ki;
const struct device_type *type;
};
-int subsys_dev_iter_init(struct subsys_dev_iter *iter,
+void subsys_dev_iter_init(struct subsys_dev_iter *iter,
struct bus_type *subsys,
struct device *start,
const struct device_type *type);
void class_compat_remove_link(struct class_compat *cls, struct device *dev,
struct device *device_link);
-extern int class_dev_iter_init(struct class_dev_iter *iter,
- struct class *class,
- struct device *start,
- const struct device_type *type);
+extern void class_dev_iter_init(struct class_dev_iter *iter,
+ struct class *class,
+ struct device *start,
+ const struct device_type *type);
extern struct device *class_dev_iter_next(struct class_dev_iter *iter);
extern void class_dev_iter_exit(struct class_dev_iter *iter);
extern void klist_iter_init(struct klist *k, struct klist_iter *i);
-extern int klist_iter_init_node(struct klist *k, struct klist_iter *i,
+extern void klist_iter_init_node(struct klist *k, struct klist_iter *i,
struct klist_node *n);
extern void klist_iter_exit(struct klist_iter *i);
extern struct klist_node *klist_next(struct klist_iter *i);
* Similar to klist_iter_init(), but starts the action off with @n,
* instead of with the list head.
*/
-int klist_iter_init_node(struct klist *k, struct klist_iter *i,
- struct klist_node *n)
+void klist_iter_init_node(struct klist *k, struct klist_iter *i,
+ struct klist_node *n)
{
- if (n) {
- kref_get(&n->n_ref);
- if (!n->n_klist) {
- kref_put(&n->n_ref);
- return -ENODEV;
- }
- }
i->i_klist = k;
i->i_cur = n;
- return 0;
+ if (n)
+ kref_get(&n->n_ref);
}
EXPORT_SYMBOL_GPL(klist_iter_init_node);