Skip to content

Commit f810a5c

Browse files
fenrus75torvalds
authored andcommitted
Use WARN() in drivers/base/
Use WARN() instead of a printk+WARN_ON() pair; this way the message becomes part of the warning section for better reporting/collection. Signed-off-by: Arjan van de Ven <arjan@linux.intel.com> Cc: Greg KH <greg@kroah.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 12e0036 commit f810a5c

3 files changed

Lines changed: 7 additions & 14 deletions

File tree

‎drivers/base/core.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,10 @@ static void device_release(struct kobject *kobj)
116116
dev->type->release(dev);
117117
else if (dev->class && dev->class->dev_release)
118118
dev->class->dev_release(dev);
119-
else {
120-
printk(KERN_ERR "Device '%s' does not have a release() "
119+
else
120+
WARN(1, KERN_ERR "Device '%s' does not have a release() "
121121
"function, it is broken and must be fixed.\n",
122122
dev->bus_id);
123-
WARN_ON(1);
124-
}
125123
}
126124

127125
static struct kobj_type device_ktype = {

‎drivers/base/memory.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,8 @@ memory_block_action(struct memory_block *mem, unsigned long action)
204204
}
205205
break;
206206
default:
207-
printk(KERN_WARNING "%s(%p, %ld) unknown action: %ld\n",
207+
WARN(1, KERN_WARNING "%s(%p, %ld) unknown action: %ld\n",
208208
__func__, mem, action, action);
209-
WARN_ON(1);
210209
ret = -EINVAL;
211210
}
212211

‎drivers/base/sys.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,16 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
168168
int err = 0;
169169

170170
if (!cls) {
171-
printk(KERN_WARNING "sysdev: invalid class passed to "
171+
WARN(1, KERN_WARNING "sysdev: invalid class passed to "
172172
"sysdev_driver_register!\n");
173-
WARN_ON(1);
174173
return -EINVAL;
175174
}
176175

177176
/* Check whether this driver has already been added to a class. */
178-
if (drv->entry.next && !list_empty(&drv->entry)) {
179-
printk(KERN_WARNING "sysdev: class %s: driver (%p) has already"
177+
if (drv->entry.next && !list_empty(&drv->entry))
178+
WARN(1, KERN_WARNING "sysdev: class %s: driver (%p) has already"
180179
" been registered to a class, something is wrong, but "
181180
"will forge on!\n", cls->name, drv);
182-
WARN_ON(1);
183-
}
184181

185182
mutex_lock(&sysdev_drivers_lock);
186183
if (cls && kset_get(&cls->kset)) {
@@ -194,8 +191,7 @@ int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
194191
}
195192
} else {
196193
err = -EINVAL;
197-
printk(KERN_ERR "%s: invalid device class\n", __func__);
198-
WARN_ON(1);
194+
WARN(1, KERN_ERR "%s: invalid device class\n", __func__);
199195
}
200196
mutex_unlock(&sysdev_drivers_lock);
201197
return err;

0 commit comments

Comments
 (0)