mirror of https://gitee.com/openkylin/linux.git
iio: core: move @trig_readonly from struct iio_dev to struct iio_dev_opaque
This is only set via the iio_trig_set_immutable() call and later used by the IIO core so there is no benefit in drivers being able to access it. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com> Link: https://lore.kernel.org/r/20210426174911.397061-5-jic23@kernel.org
This commit is contained in:
parent
6eaf9f6a27
commit
3028e0c2af
|
@ -117,14 +117,17 @@ EXPORT_SYMBOL(iio_trigger_unregister);
|
|||
|
||||
int iio_trigger_set_immutable(struct iio_dev *indio_dev, struct iio_trigger *trig)
|
||||
{
|
||||
struct iio_dev_opaque *iio_dev_opaque;
|
||||
|
||||
if (!indio_dev || !trig)
|
||||
return -EINVAL;
|
||||
|
||||
iio_dev_opaque = to_iio_dev_opaque(indio_dev);
|
||||
mutex_lock(&indio_dev->mlock);
|
||||
WARN_ON(indio_dev->trig_readonly);
|
||||
WARN_ON(iio_dev_opaque->trig_readonly);
|
||||
|
||||
indio_dev->trig = iio_trigger_get(trig);
|
||||
indio_dev->trig_readonly = true;
|
||||
iio_dev_opaque->trig_readonly = true;
|
||||
mutex_unlock(&indio_dev->mlock);
|
||||
|
||||
return 0;
|
||||
|
@ -402,6 +405,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
|
|||
size_t len)
|
||||
{
|
||||
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
|
||||
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
|
||||
struct iio_trigger *oldtrig = indio_dev->trig;
|
||||
struct iio_trigger *trig;
|
||||
int ret;
|
||||
|
@ -411,7 +415,7 @@ static ssize_t iio_trigger_write_current(struct device *dev,
|
|||
mutex_unlock(&indio_dev->mlock);
|
||||
return -EBUSY;
|
||||
}
|
||||
if (indio_dev->trig_readonly) {
|
||||
if (iio_dev_opaque->trig_readonly) {
|
||||
mutex_unlock(&indio_dev->mlock);
|
||||
return -EPERM;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* @indio_dev: public industrial I/O device information
|
||||
* @id: used to identify device internally
|
||||
* @driver_module: used to make it harder to undercut users
|
||||
* @trig_readonly: mark the current trigger immutable
|
||||
* @event_interface: event chrdevs associated with interrupt lines
|
||||
* @attached_buffers: array of buffers statically attached by the driver
|
||||
* @attached_buffers_cnt: number of buffers in the array of statically attached buffers
|
||||
|
@ -30,6 +31,7 @@ struct iio_dev_opaque {
|
|||
struct iio_dev indio_dev;
|
||||
int id;
|
||||
struct module *driver_module;
|
||||
bool trig_readonly;
|
||||
struct iio_event_interface *event_interface;
|
||||
struct iio_buffer **attached_buffers;
|
||||
unsigned int attached_buffers_cnt;
|
||||
|
|
|
@ -503,7 +503,6 @@ struct iio_buffer_setup_ops {
|
|||
* @scan_timestamp: [INTERN] set if any buffers have requested timestamp
|
||||
* @scan_index_timestamp:[INTERN] cache of the index to the timestamp
|
||||
* @trig: [INTERN] current device trigger (buffer modes)
|
||||
* @trig_readonly: [INTERN] mark the current trigger immutable
|
||||
* @pollfunc: [DRIVER] function run on trigger being received
|
||||
* @pollfunc_event: [DRIVER] function run on events trigger being received
|
||||
* @channels: [DRIVER] channel specification structure table
|
||||
|
@ -535,7 +534,6 @@ struct iio_dev {
|
|||
bool scan_timestamp;
|
||||
unsigned scan_index_timestamp;
|
||||
struct iio_trigger *trig;
|
||||
bool trig_readonly;
|
||||
struct iio_poll_func *pollfunc;
|
||||
struct iio_poll_func *pollfunc_event;
|
||||
|
||||
|
|
Loading…
Reference in New Issue