iio: trigger: move trig->owner init to trigger allocate() stage
To provide a new IIO trigger to the IIO core, usually driver executes the following pipeline: allocate()/register()/get(). Before, IIO core assigned trig->owner as a pointer to the module which registered this trigger at the register() stage. But actually the trigger object is owned by the module earlier, on the allocate() stage, when trigger object is successfully allocated for the driver. This patch moves trig->owner initialization from register() stage of trigger initialization pipeline to allocate() stage to eliminate all misunderstandings and time gaps between trigger object creation and owner acquiring. Signed-off-by: Dmitry Rokosov <ddrokosov@sberdevices.ru> Link: https://lore.kernel.org/r/20220601174837.20292-1-ddrokosov@sberdevices.ru Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This commit is contained in:
parent
17b5a7f65c
commit
bc72d938c1
3 changed files with 41 additions and 35 deletions
|
|
@ -727,10 +727,13 @@ static inline void *iio_priv(const struct iio_dev *indio_dev)
|
|||
|
||||
void iio_device_free(struct iio_dev *indio_dev);
|
||||
struct iio_dev *devm_iio_device_alloc(struct device *parent, int sizeof_priv);
|
||||
__printf(2, 3)
|
||||
struct iio_trigger *devm_iio_trigger_alloc(struct device *parent,
|
||||
const char *fmt, ...);
|
||||
|
||||
#define devm_iio_trigger_alloc(parent, fmt, ...) \
|
||||
__devm_iio_trigger_alloc((parent), THIS_MODULE, (fmt), ##__VA_ARGS__)
|
||||
__printf(3, 4)
|
||||
struct iio_trigger *__devm_iio_trigger_alloc(struct device *parent,
|
||||
struct module *this_mod,
|
||||
const char *fmt, ...);
|
||||
/**
|
||||
* iio_get_debugfs_dentry() - helper function to get the debugfs_dentry
|
||||
* @indio_dev: IIO device structure for device
|
||||
|
|
|
|||
|
|
@ -131,16 +131,10 @@ 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
|
||||
**/
|
||||
#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);
|
||||
int iio_trigger_register(struct iio_trigger *trig_info);
|
||||
|
||||
#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);
|
||||
int devm_iio_trigger_register(struct device *dev,
|
||||
struct iio_trigger *trig_info);
|
||||
|
||||
/**
|
||||
* iio_trigger_unregister() - unregister a trigger from the core
|
||||
|
|
@ -168,8 +162,13 @@ void iio_trigger_poll_chained(struct iio_trigger *trig);
|
|||
|
||||
irqreturn_t iio_trigger_generic_data_rdy_poll(int irq, void *private);
|
||||
|
||||
__printf(2, 3)
|
||||
struct iio_trigger *iio_trigger_alloc(struct device *parent, const char *fmt, ...);
|
||||
#define iio_trigger_alloc(parent, fmt, ...) \
|
||||
__iio_trigger_alloc((parent), THIS_MODULE, (fmt), ##__VA_ARGS__)
|
||||
|
||||
__printf(3, 4)
|
||||
struct iio_trigger *__iio_trigger_alloc(struct device *parent,
|
||||
struct module *this_mod,
|
||||
const char *fmt, ...);
|
||||
void iio_trigger_free(struct iio_trigger *trig);
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue