diff options
author | Paul Gortmaker <paul.gortmaker@windriver.com> | 2011-09-15 17:56:39 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2011-10-31 19:32:34 -0400 |
commit | 1d58996da6a8045c8df2899ce5689a19c721322f (patch) | |
tree | 9398cadb5edfcc97cdbeafc29dd5742349be82f3 /include/net | |
parent | 69e7dae4096caeea0a7e2ede376f22a4fdee8456 (diff) | |
download | op-kernel-dev-1d58996da6a8045c8df2899ce5689a19c721322f.zip op-kernel-dev-1d58996da6a8045c8df2899ce5689a19c721322f.tar.gz |
bluetooth: macroize two small inlines to avoid module.h
These two small inlines make calls to try_module_get() and
module_put() which would force us to keep module.h present
within yet another common include header. We can avoid this
by turning them into macros. The hci_dev_hold construct
is patterned off of raw_spin_trylock_irqsave() in spinlock.h
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/bluetooth/hci_core.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 5b92442..3779ea3 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -513,11 +513,15 @@ static inline void __hci_dev_put(struct hci_dev *d) d->destruct(d); } -static inline void hci_dev_put(struct hci_dev *d) -{ - __hci_dev_put(d); - module_put(d->owner); -} +/* + * hci_dev_put and hci_dev_hold are macros to avoid dragging all the + * overhead of all the modular infrastructure into this header. + */ +#define hci_dev_put(d) \ +do { \ + __hci_dev_put(d); \ + module_put(d->owner); \ +} while (0) static inline struct hci_dev *__hci_dev_hold(struct hci_dev *d) { @@ -525,12 +529,10 @@ static inline struct hci_dev *__hci_dev_hold(struct hci_dev *d) return d; } -static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) -{ - if (try_module_get(d->owner)) - return __hci_dev_hold(d); - return NULL; -} +#define hci_dev_hold(d) \ +({ \ + try_module_get(d->owner) ? __hci_dev_hold(d) : NULL; \ +}) #define hci_dev_lock(d) spin_lock(&d->lock) #define hci_dev_unlock(d) spin_unlock(&d->lock) |