aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/iio/trigger.h
diff options
context:
space:
mode:
authorJonathan Cameron <jic23@kernel.org>2017-07-23 17:25:44 +0100
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2017-08-22 21:18:32 +0100
commit035c70aeb64b861aa88a666c61fda8b2ae49aeae (patch)
tree3c646e32be0254bf61a83d1ef24c90d23abf86d9 /include/linux/iio/trigger.h
parentiio: Use macro magic to avoid manual assign of driver_module (diff)
downloadlinux-dev-035c70aeb64b861aa88a666c61fda8b2ae49aeae.tar.xz
linux-dev-035c70aeb64b861aa88a666c61fda8b2ae49aeae.zip
iio: triggers: Use macros to avoid boilerplate assignment of owner.
This trig_ops.owner assignment occurs in all trigger drivers and can be simply automated using a macro as has been done in many other places in the kernel. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Diffstat (limited to 'include/linux/iio/trigger.h')
-rw-r--r--include/linux/iio/trigger.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h
index ea08302f2d7b..999793212b40 100644
--- a/include/linux/iio/trigger.h
+++ b/include/linux/iio/trigger.h
@@ -62,6 +62,7 @@ struct iio_trigger_ops {
**/
struct iio_trigger {
const struct iio_trigger_ops *ops;
+ struct module *owner;
int id;
const char *name;
struct device dev;
@@ -87,14 +88,14 @@ static inline struct iio_trigger *to_iio_trigger(struct device *d)
static inline void iio_trigger_put(struct iio_trigger *trig)
{
- module_put(trig->ops->owner);
+ module_put(trig->owner);
put_device(&trig->dev);
}
static inline struct iio_trigger *iio_trigger_get(struct iio_trigger *trig)
{
get_device(&trig->dev);
- __module_get(trig->ops->owner);
+ __module_get(trig->owner);
return trig;
}
@@ -127,10 +128,16 @@ static inline void *iio_trigger_get_drvdata(struct iio_trigger *trig)
* iio_trigger_register() - register a trigger with the IIO core
* @trig_info: trigger to be registered
**/
-int iio_trigger_register(struct iio_trigger *trig_info);
-
-int devm_iio_trigger_register(struct device *dev,
- struct iio_trigger *trig_info);
+#define iio_trigger_register(trig_info) \
+ __iio_trigger_register((trig_info), THIS_MODULE)
+int __iio_trigger_register(struct iio_trigger *trig_info,
+ struct module *this_mod);
+
+#define devm_iio_trigger_register(dev, trig_info) \
+ __devm_iio_trigger_register((dev), (trig_info), THIS_MODULE)
+int __devm_iio_trigger_register(struct device *dev,
+ struct iio_trigger *trig_info,
+ struct module *this_mod);
/**
* iio_trigger_unregister() - unregister a trigger from the core