diff options
author | Takashi Iwai <tiwai@suse.de> | 2010-03-23 08:01:36 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-03-23 08:01:36 +0100 |
commit | 3791628cfa296f06f5f58e905edd19ec5e126a3f (patch) | |
tree | dd166ce651b3ef19f823c7ac963022e64d97000b | |
parent | f8fa90f13140d1494def96ff1d6a8e41ec18ae0f (diff) | |
download | alsa-driver-build-unstable-3791628cfa296f06f5f58e905edd19ec5e126a3f.tar.gz |
Add blocking_notifier_*() wrappers for older kernels
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | include/adriver.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/include/adriver.h b/include/adriver.h index 185c1aa31..5a96be9fe 100644 --- a/include/adriver.h +++ b/include/adriver.h @@ -1944,4 +1944,53 @@ char *compat_skip_spaces(const char *); #endif /* < 2.6.25 */ #endif /* CONFIG_PCI */ +/* blocking_notifier */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 17) +#include <linux/notifier.h> +#ifndef BLOCKING_INIT_NOTIFIER_HEAD +struct blocking_notifier_head { + struct rw_semaphore rwsem; + struct notifier_block *head; +}; + +#define BLOCKING_INIT_NOTIFIER_HEAD(name) do { \ + init_rwsem(&(name)->rwsem); \ + (name)->head = NULL; \ + } while (0) + +static inline int +blocking_notifier_call_chain(struct blocking_notifier_head *nh, + unsigned long val, void *v) +{ + int ret; + down_read(&nh->rwsem); + ret = notifier_call_chain(&nh->head, val, v); + up_read(&nh->rwsem); + return ret; +} + +static inline int +blocking_notifier_chain_register(struct blocking_notifier_head *nh, + struct notifier_block *nb) +{ + int ret; + down_write(&nh->rwsem); + ret = notifier_chain_register(&nh->head, nb); + up_write(&nh->rwsem); + return ret; +} + +static inline int +blocking_notifier_chain_unregister(struct blocking_notifier_head *nh, + struct notifier_block *nb) +{ + int ret; + down_write(&nh->rwsem); + ret = notifier_chain_unregister(&nh->head, nb); + up_write(&nh->rwsem); + return ret; +} +#endif /* BLOCKING_INIT_NOTIFIER_HEAD */ +#endif /* <2.6.17 */ + #endif /* __SOUND_LOCAL_DRIVER_H */ |