aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/device.h
diff options
context:
space:
mode:
authorMatthew Wilcox <matthew@wil.cx>2008-05-28 12:28:39 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-22 00:54:52 -0400
commitd2a3b9146e4f40c2e872d7567c996ef95083d802 (patch)
treec95bd0a155e1c868fcaffeb0949dd3441203f72a /include/linux/device.h
parent1e41250863cd4de5ffa0678c405d001ca5b62796 (diff)
class: add lockdep infrastructure
This adds the infrastructure to properly handle lockdep issues when the internal class semaphore is changed to a mutex. Matthew wrote the original patch, and Greg fixed it up to work properly with the class_create() function. From: Matthew Wilcox <matthew@wil.cx> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Dave Young <hidave.darkstar@gmail.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ingo Molnar <mingo@elte.hu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'include/linux/device.h')
-rw-r--r--include/linux/device.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/include/linux/device.h b/include/linux/device.h
index b0556082179b..0e1d24c2ed41 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -16,6 +16,7 @@
16#include <linux/kobject.h> 16#include <linux/kobject.h>
17#include <linux/klist.h> 17#include <linux/klist.h>
18#include <linux/list.h> 18#include <linux/list.h>
19#include <linux/lockdep.h>
19#include <linux/compiler.h> 20#include <linux/compiler.h>
20#include <linux/types.h> 21#include <linux/types.h>
21#include <linux/module.h> 22#include <linux/module.h>
@@ -205,8 +206,18 @@ struct class {
205 206
206extern struct kobject *sysfs_dev_block_kobj; 207extern struct kobject *sysfs_dev_block_kobj;
207extern struct kobject *sysfs_dev_char_kobj; 208extern struct kobject *sysfs_dev_char_kobj;
208extern int __must_check class_register(struct class *class); 209extern int __must_check __class_register(struct class *class,
210 struct lock_class_key *key);
209extern void class_unregister(struct class *class); 211extern void class_unregister(struct class *class);
212
213/* This is a #define to keep the compiler from merging different
214 * instances of the __key variable */
215#define class_register(class) \
216({ \
217 static struct lock_class_key __key; \
218 __class_register(class, &__key); \
219})
220
210extern int class_for_each_device(struct class *class, struct device *start, 221extern int class_for_each_device(struct class *class, struct device *start,
211 void *data, 222 void *data,
212 int (*fn)(struct device *dev, void *data)); 223 int (*fn)(struct device *dev, void *data));
@@ -239,9 +250,19 @@ struct class_interface {
239extern int __must_check class_interface_register(struct class_interface *); 250extern int __must_check class_interface_register(struct class_interface *);
240extern void class_interface_unregister(struct class_interface *); 251extern void class_interface_unregister(struct class_interface *);
241 252
242extern struct class *class_create(struct module *owner, const char *name); 253extern struct class * __must_check __class_create(struct module *owner,
254 const char *name,
255 struct lock_class_key *key);
243extern void class_destroy(struct class *cls); 256extern void class_destroy(struct class *cls);
244 257
258/* This is a #define to keep the compiler from merging different
259 * instances of the __key variable */
260#define class_create(owner, name) \
261({ \
262 static struct lock_class_key __key; \
263 __class_create(owner, name, &__key); \
264})
265
245/* 266/*
246 * The type of device, "struct device" is embedded in. A class 267 * The type of device, "struct device" is embedded in. A class
247 * or bus can contain devices of different types 268 * or bus can contain devices of different types