aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r--drivers/base/class.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 839d27cecb36..cc5e28c8885c 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -198,6 +198,7 @@ static void class_create_release(struct class *cls)
198 * class_create - create a struct class structure 198 * class_create - create a struct class structure
199 * @owner: pointer to the module that is to "own" this struct class 199 * @owner: pointer to the module that is to "own" this struct class
200 * @name: pointer to a string for the name of this class. 200 * @name: pointer to a string for the name of this class.
201 * @key: the lock_class_key for this class; used by mutex lock debugging
201 * 202 *
202 * This is used to create a struct class pointer that can then be used 203 * This is used to create a struct class pointer that can then be used
203 * in calls to device_create(). 204 * in calls to device_create().
@@ -294,6 +295,12 @@ int class_for_each_device(struct class *class, struct device *start,
294 295
295 if (!class) 296 if (!class)
296 return -EINVAL; 297 return -EINVAL;
298 if (!class->p) {
299 WARN(1, "%s called for class '%s' before it was initialized",
300 __func__, class->name);
301 return -EINVAL;
302 }
303
297 mutex_lock(&class->p->class_mutex); 304 mutex_lock(&class->p->class_mutex);
298 list_for_each_entry(dev, &class->p->class_devices, node) { 305 list_for_each_entry(dev, &class->p->class_devices, node) {
299 if (start) { 306 if (start) {
@@ -343,6 +350,11 @@ struct device *class_find_device(struct class *class, struct device *start,
343 350
344 if (!class) 351 if (!class)
345 return NULL; 352 return NULL;
353 if (!class->p) {
354 WARN(1, "%s called for class '%s' before it was initialized",
355 __func__, class->name);
356 return NULL;
357 }
346 358
347 mutex_lock(&class->p->class_mutex); 359 mutex_lock(&class->p->class_mutex);
348 list_for_each_entry(dev, &class->p->class_devices, node) { 360 list_for_each_entry(dev, &class->p->class_devices, node) {