Commit 7cd9c9bb authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Revert "driver core: check start node in klist_iter_init_node"

This reverts commit a15d49fd as that
patch broke the build.

Cc: Hannes Reinecke <hare@suse.de>
Reported-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 591bfc6b
...@@ -296,13 +296,11 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start, ...@@ -296,13 +296,11 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start,
if (!bus) if (!bus)
return -EINVAL; return -EINVAL;
error = klist_iter_init_node(&bus->p->klist_devices, &i, klist_iter_init_node(&bus->p->klist_devices, &i,
(start ? &start->p->knode_bus : NULL)); (start ? &start->p->knode_bus : NULL));
if (!error) {
while ((dev = next_device(&i)) && !error) while ((dev = next_device(&i)) && !error)
error = fn(dev, data); error = fn(dev, data);
klist_iter_exit(&i); klist_iter_exit(&i);
}
return error; return error;
} }
EXPORT_SYMBOL_GPL(bus_for_each_dev); EXPORT_SYMBOL_GPL(bus_for_each_dev);
...@@ -332,10 +330,8 @@ struct device *bus_find_device(struct bus_type *bus, ...@@ -332,10 +330,8 @@ struct device *bus_find_device(struct bus_type *bus,
if (!bus) if (!bus)
return NULL; return NULL;
if (klist_iter_init_node(&bus->p->klist_devices, &i, klist_iter_init_node(&bus->p->klist_devices, &i,
(start ? &start->p->knode_bus : NULL)) < 0) (start ? &start->p->knode_bus : NULL));
return NULL;
while ((dev = next_device(&i))) while ((dev = next_device(&i)))
if (match(dev, data) && get_device(dev)) if (match(dev, data) && get_device(dev))
break; break;
...@@ -388,9 +384,7 @@ struct device *subsys_find_device_by_id(struct bus_type *subsys, unsigned int id ...@@ -388,9 +384,7 @@ struct device *subsys_find_device_by_id(struct bus_type *subsys, unsigned int id
return NULL; return NULL;
if (hint) { if (hint) {
if (klist_iter_init_node(&subsys->p->klist_devices, &i, klist_iter_init_node(&subsys->p->klist_devices, &i, &hint->p->knode_bus);
&hint->p->knode_bus) < 0)
return NULL;
dev = next_device(&i); dev = next_device(&i);
if (dev && dev->id == id && get_device(dev)) { if (dev && dev->id == id && get_device(dev)) {
klist_iter_exit(&i); klist_iter_exit(&i);
...@@ -452,13 +446,11 @@ int bus_for_each_drv(struct bus_type *bus, struct device_driver *start, ...@@ -452,13 +446,11 @@ int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
if (!bus) if (!bus)
return -EINVAL; return -EINVAL;
error = klist_iter_init_node(&bus->p->klist_drivers, &i, klist_iter_init_node(&bus->p->klist_drivers, &i,
start ? &start->p->knode_bus : NULL); start ? &start->p->knode_bus : NULL);
if (!error) {
while ((drv = next_driver(&i)) && !error) while ((drv = next_driver(&i)) && !error)
error = fn(drv, data); error = fn(drv, data);
klist_iter_exit(&i); klist_iter_exit(&i);
}
return error; return error;
} }
EXPORT_SYMBOL_GPL(bus_for_each_drv); EXPORT_SYMBOL_GPL(bus_for_each_drv);
...@@ -1119,19 +1111,15 @@ EXPORT_SYMBOL_GPL(bus_sort_breadthfirst); ...@@ -1119,19 +1111,15 @@ EXPORT_SYMBOL_GPL(bus_sort_breadthfirst);
* otherwise if it is NULL, the iteration starts at the beginning of * otherwise if it is NULL, the iteration starts at the beginning of
* the list. * the list.
*/ */
int subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys, void subsys_dev_iter_init(struct subsys_dev_iter *iter, struct bus_type *subsys,
struct device *start, const struct device_type *type) struct device *start, const struct device_type *type)
{ {
struct klist_node *start_knode = NULL; struct klist_node *start_knode = NULL;
int error;
if (start) if (start)
start_knode = &start->p->knode_bus; start_knode = &start->p->knode_bus;
error = klist_iter_init_node(&subsys->p->klist_devices, &iter->ki, klist_iter_init_node(&subsys->p->klist_devices, &iter->ki, start_knode);
start_knode);
if (!error)
iter->type = type; iter->type = type;
return error;
} }
EXPORT_SYMBOL_GPL(subsys_dev_iter_init); EXPORT_SYMBOL_GPL(subsys_dev_iter_init);
......
...@@ -301,20 +301,15 @@ void class_destroy(struct class *cls) ...@@ -301,20 +301,15 @@ void class_destroy(struct class *cls)
* otherwise if it is NULL, the iteration starts at the beginning of * otherwise if it is NULL, the iteration starts at the beginning of
* the list. * the list.
*/ */
int class_dev_iter_init(struct class_dev_iter *iter, struct class *class, void class_dev_iter_init(struct class_dev_iter *iter, struct class *class,
struct device *start, const struct device_type *type) struct device *start, const struct device_type *type)
{ {
struct klist_node *start_knode = NULL; struct klist_node *start_knode = NULL;
int error;
if (start) if (start)
start_knode = &start->knode_class; start_knode = &start->knode_class;
error = klist_iter_init_node(&class->p->klist_devices, &iter->ki, klist_iter_init_node(&class->p->klist_devices, &iter->ki, start_knode);
start_knode);
if (!error)
iter->type = type; iter->type = type;
return error;
} }
EXPORT_SYMBOL_GPL(class_dev_iter_init); EXPORT_SYMBOL_GPL(class_dev_iter_init);
...@@ -392,15 +387,14 @@ int class_for_each_device(struct class *class, struct device *start, ...@@ -392,15 +387,14 @@ int class_for_each_device(struct class *class, struct device *start,
return -EINVAL; return -EINVAL;
} }
error = class_dev_iter_init(&iter, class, start, NULL); class_dev_iter_init(&iter, class, start, NULL);
if (!error) {
while ((dev = class_dev_iter_next(&iter))) { while ((dev = class_dev_iter_next(&iter))) {
error = fn(dev, data); error = fn(dev, data);
if (error) if (error)
break; break;
} }
class_dev_iter_exit(&iter); class_dev_iter_exit(&iter);
}
return error; return error;
} }
EXPORT_SYMBOL_GPL(class_for_each_device); EXPORT_SYMBOL_GPL(class_for_each_device);
...@@ -440,9 +434,7 @@ struct device *class_find_device(struct class *class, struct device *start, ...@@ -440,9 +434,7 @@ struct device *class_find_device(struct class *class, struct device *start,
return NULL; return NULL;
} }
if (class_dev_iter_init(&iter, class, start, NULL) < 0) class_dev_iter_init(&iter, class, start, NULL);
return NULL;
while ((dev = class_dev_iter_next(&iter))) { while ((dev = class_dev_iter_next(&iter))) {
if (match(dev, data)) { if (match(dev, data)) {
get_device(dev); get_device(dev);
......
...@@ -49,13 +49,11 @@ int driver_for_each_device(struct device_driver *drv, struct device *start, ...@@ -49,13 +49,11 @@ int driver_for_each_device(struct device_driver *drv, struct device *start,
if (!drv) if (!drv)
return -EINVAL; return -EINVAL;
error = klist_iter_init_node(&drv->p->klist_devices, &i, klist_iter_init_node(&drv->p->klist_devices, &i,
start ? &start->p->knode_driver : NULL); start ? &start->p->knode_driver : NULL);
if (!error) {
while ((dev = next_device(&i)) && !error) while ((dev = next_device(&i)) && !error)
error = fn(dev, data); error = fn(dev, data);
klist_iter_exit(&i); klist_iter_exit(&i);
}
return error; return error;
} }
EXPORT_SYMBOL_GPL(driver_for_each_device); EXPORT_SYMBOL_GPL(driver_for_each_device);
...@@ -85,10 +83,8 @@ struct device *driver_find_device(struct device_driver *drv, ...@@ -85,10 +83,8 @@ struct device *driver_find_device(struct device_driver *drv,
if (!drv) if (!drv)
return NULL; return NULL;
if (klist_iter_init_node(&drv->p->klist_devices, &i, klist_iter_init_node(&drv->p->klist_devices, &i,
(start ? &start->p->knode_driver : NULL)) < 0) (start ? &start->p->knode_driver : NULL));
return NULL;
while ((dev = next_device(&i))) while ((dev = next_device(&i)))
if (match(dev, data) && get_device(dev)) if (match(dev, data) && get_device(dev))
break; break;
......
...@@ -128,7 +128,7 @@ struct subsys_dev_iter { ...@@ -128,7 +128,7 @@ struct subsys_dev_iter {
struct klist_iter ki; struct klist_iter ki;
const struct device_type *type; 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 bus_type *subsys,
struct device *start, struct device *start,
const struct device_type *type); const struct device_type *type);
...@@ -380,7 +380,7 @@ int class_compat_create_link(struct class_compat *cls, struct device *dev, ...@@ -380,7 +380,7 @@ int class_compat_create_link(struct class_compat *cls, struct device *dev,
void class_compat_remove_link(struct class_compat *cls, struct device *dev, void class_compat_remove_link(struct class_compat *cls, struct device *dev,
struct device *device_link); struct device *device_link);
extern int class_dev_iter_init(struct class_dev_iter *iter, extern void class_dev_iter_init(struct class_dev_iter *iter,
struct class *class, struct class *class,
struct device *start, struct device *start,
const struct device_type *type); const struct device_type *type);
......
...@@ -60,7 +60,7 @@ struct klist_iter { ...@@ -60,7 +60,7 @@ struct klist_iter {
extern void klist_iter_init(struct klist *k, struct klist_iter *i); 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); struct klist_node *n);
extern void klist_iter_exit(struct klist_iter *i); extern void klist_iter_exit(struct klist_iter *i);
extern struct klist_node *klist_next(struct klist_iter *i); extern struct klist_node *klist_next(struct klist_iter *i);
......
...@@ -278,19 +278,13 @@ EXPORT_SYMBOL_GPL(klist_node_attached); ...@@ -278,19 +278,13 @@ EXPORT_SYMBOL_GPL(klist_node_attached);
* Similar to klist_iter_init(), but starts the action off with @n, * Similar to klist_iter_init(), but starts the action off with @n,
* instead of with the list head. * instead of with the list head.
*/ */
int klist_iter_init_node(struct klist *k, struct klist_iter *i, void klist_iter_init_node(struct klist *k, struct klist_iter *i,
struct klist_node *n) 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_klist = k;
i->i_cur = n; i->i_cur = n;
return 0; if (n)
kref_get(&n->n_ref);
} }
EXPORT_SYMBOL_GPL(klist_iter_init_node); EXPORT_SYMBOL_GPL(klist_iter_init_node);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment