Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1d58996d authored by Paul Gortmaker's avatar Paul Gortmaker
Browse files

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: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
parent 69e7dae4
Loading
Loading
Loading
Loading
+13 −11
Original line number Original line Diff line number Diff line
@@ -513,11 +513,15 @@ static inline void __hci_dev_put(struct hci_dev *d)
		d->destruct(d);
		d->destruct(d);
}
}


static inline void hci_dev_put(struct hci_dev *d)
/*
{
 * hci_dev_put and hci_dev_hold are macros to avoid dragging all the
	__hci_dev_put(d);
 * overhead of all the modular infrastructure into this header.
	module_put(d->owner);
 */
}
#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)
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;
	return d;
}
}


static inline struct hci_dev *hci_dev_hold(struct hci_dev *d)
#define hci_dev_hold(d)						\
{
({								\
	if (try_module_get(d->owner))
	try_module_get(d->owner) ? __hci_dev_hold(d) : NULL;	\
		return __hci_dev_hold(d);
})
	return NULL;
}


#define hci_dev_lock(d)		spin_lock(&d->lock)
#define hci_dev_lock(d)		spin_lock(&d->lock)
#define hci_dev_unlock(d)	spin_unlock(&d->lock)
#define hci_dev_unlock(d)	spin_unlock(&d->lock)