2019-06-04 10:11:33 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2011-10-14 16:34:14 +01:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2011 Jonathan Cameron
|
|
|
|
*
|
|
|
|
* Join together the various functionality of iio_simple_dummy driver
|
|
|
|
*/
|
|
|
|
|
2014-09-25 16:58:07 +03:00
|
|
|
#ifndef _IIO_SIMPLE_DUMMY_H_
|
|
|
|
#define _IIO_SIMPLE_DUMMY_H_
|
2011-10-14 16:34:14 +01:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
|
|
|
|
struct iio_dummy_accel_calibscale;
|
2014-11-10 14:45:29 +02:00
|
|
|
struct iio_dummy_regs;
|
2011-10-14 16:34:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* struct iio_dummy_state - device instance specific state.
|
|
|
|
* @dac_val: cache for dac value
|
|
|
|
* @single_ended_adc_val: cache for single ended adc value
|
|
|
|
* @differential_adc_val: cache for differential adc value
|
|
|
|
* @accel_val: cache for acceleration value
|
|
|
|
* @accel_calibbias: cache for acceleration calibbias
|
|
|
|
* @accel_calibscale: cache for acceleration calibscale
|
|
|
|
* @lock: lock to ensure state is consistent
|
|
|
|
* @event_irq: irq number for event line (faked)
|
2015-04-24 09:40:42 -04:00
|
|
|
* @event_val: cache for event threshold value
|
2011-10-14 16:34:14 +01:00
|
|
|
* @event_en: cache of whether event is enabled
|
|
|
|
*/
|
|
|
|
struct iio_dummy_state {
|
|
|
|
int dac_val;
|
|
|
|
int single_ended_adc_val;
|
|
|
|
int differential_adc_val[2];
|
|
|
|
int accel_val;
|
|
|
|
int accel_calibbias;
|
2014-11-10 14:45:34 +02:00
|
|
|
int activity_running;
|
|
|
|
int activity_walking;
|
2011-10-14 16:34:14 +01:00
|
|
|
const struct iio_dummy_accel_calibscale *accel_calibscale;
|
|
|
|
struct mutex lock;
|
2014-11-10 14:45:29 +02:00
|
|
|
struct iio_dummy_regs *regs;
|
2014-11-10 14:45:34 +02:00
|
|
|
int steps_enabled;
|
|
|
|
int steps;
|
|
|
|
int height;
|
2011-10-14 16:34:14 +01:00
|
|
|
#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
|
|
|
|
int event_irq;
|
|
|
|
int event_val;
|
|
|
|
bool event_en;
|
2015-09-11 16:59:30 +03:00
|
|
|
s64 event_timestamp;
|
2011-10-14 16:34:14 +01:00
|
|
|
#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS */
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_IIO_SIMPLE_DUMMY_EVENTS
|
|
|
|
|
|
|
|
struct iio_dev;
|
|
|
|
|
|
|
|
int iio_simple_dummy_read_event_config(struct iio_dev *indio_dev,
|
2013-10-07 15:11:00 +01:00
|
|
|
const struct iio_chan_spec *chan,
|
|
|
|
enum iio_event_type type,
|
|
|
|
enum iio_event_direction dir);
|
2011-10-14 16:34:14 +01:00
|
|
|
|
|
|
|
int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,
|
2013-10-07 15:11:00 +01:00
|
|
|
const struct iio_chan_spec *chan,
|
|
|
|
enum iio_event_type type,
|
|
|
|
enum iio_event_direction dir,
|
iio: fix write_event_config signature
write_event_config callback use an int for state, but it is actually a
boolean. iio_ev_state_store is actually using kstrtobool to check user
input, then gives the converted boolean value to write_event_config.
Fix signature and update all iio drivers to use the new signature.
This patch has been partially written using coccinelle with the
following script:
$ cat iio-bool.cocci
// Options: --all-includes
virtual patch
@c1@
identifier iioinfo;
identifier wecfunc;
@@
static const struct iio_info iioinfo = {
...,
.write_event_config =
(
wecfunc
|
&wecfunc
),
...,
};
@@
identifier c1.wecfunc;
identifier indio_dev, chan, type, dir, state;
@@
int wecfunc(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir,
-int
+bool
state) {
...
}
make coccicheck MODE=patch COCCI=iio-bool.cocci M=drivers/iio
Unfortunately, this script didn't match all files:
* all write_event_config callbacks using iio_device_claim_direct_scoped
were not detected and not patched.
* all files that do not assign and declare the write_event_config
callback in the same file.
iio.h was also manually updated.
The patch was build tested using allmodconfig config.
cc: Julia Lawall <julia.lawall@inria.fr>
Signed-off-by: Julien Stephan <jstephan@baylibre.com>
Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-7-2bcacbb517a2@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-31 16:27:02 +01:00
|
|
|
bool state);
|
2011-10-14 16:34:14 +01:00
|
|
|
|
|
|
|
int iio_simple_dummy_read_event_value(struct iio_dev *indio_dev,
|
2013-10-07 15:11:00 +01:00
|
|
|
const struct iio_chan_spec *chan,
|
|
|
|
enum iio_event_type type,
|
|
|
|
enum iio_event_direction dir,
|
|
|
|
enum iio_event_info info, int *val,
|
|
|
|
int *val2);
|
2011-10-14 16:34:14 +01:00
|
|
|
|
|
|
|
int iio_simple_dummy_write_event_value(struct iio_dev *indio_dev,
|
2013-10-07 15:11:00 +01:00
|
|
|
const struct iio_chan_spec *chan,
|
|
|
|
enum iio_event_type type,
|
|
|
|
enum iio_event_direction dir,
|
|
|
|
enum iio_event_info info, int val,
|
|
|
|
int val2);
|
2011-10-14 16:34:14 +01:00
|
|
|
|
|
|
|
int iio_simple_dummy_events_register(struct iio_dev *indio_dev);
|
2015-05-30 11:20:16 +03:00
|
|
|
void iio_simple_dummy_events_unregister(struct iio_dev *indio_dev);
|
2011-10-14 16:34:14 +01:00
|
|
|
|
|
|
|
#else /* Stubs for when events are disabled at compile time */
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
iio_simple_dummy_events_register(struct iio_dev *indio_dev)
|
|
|
|
{
|
|
|
|
return 0;
|
2016-12-20 17:38:10 +01:00
|
|
|
}
|
2011-10-14 16:34:14 +01:00
|
|
|
|
2015-05-30 11:20:16 +03:00
|
|
|
static inline void
|
2011-10-14 16:34:14 +01:00
|
|
|
iio_simple_dummy_events_unregister(struct iio_dev *indio_dev)
|
2016-12-20 17:38:10 +01:00
|
|
|
{}
|
2011-10-14 16:34:14 +01:00
|
|
|
|
|
|
|
#endif /* CONFIG_IIO_SIMPLE_DUMMY_EVENTS*/
|
|
|
|
|
2011-10-14 16:34:15 +01:00
|
|
|
/**
|
|
|
|
* enum iio_simple_dummy_scan_elements - scan index enum
|
2015-10-26 13:48:23 -07:00
|
|
|
* @DUMMY_INDEX_VOLTAGE_0: the single ended voltage channel
|
|
|
|
* @DUMMY_INDEX_DIFFVOLTAGE_1M2: first differential channel
|
|
|
|
* @DUMMY_INDEX_DIFFVOLTAGE_3M4: second differential channel
|
|
|
|
* @DUMMY_INDEX_ACCELX: acceleration channel
|
2011-10-14 16:34:15 +01:00
|
|
|
*
|
|
|
|
* Enum provides convenient numbering for the scan index.
|
|
|
|
*/
|
|
|
|
enum iio_simple_dummy_scan_elements {
|
2015-10-26 13:48:23 -07:00
|
|
|
DUMMY_INDEX_VOLTAGE_0,
|
|
|
|
DUMMY_INDEX_DIFFVOLTAGE_1M2,
|
|
|
|
DUMMY_INDEX_DIFFVOLTAGE_3M4,
|
|
|
|
DUMMY_INDEX_ACCELX,
|
2011-10-14 16:34:15 +01:00
|
|
|
};
|
2011-10-14 16:34:14 +01:00
|
|
|
|
2011-10-14 16:34:15 +01:00
|
|
|
#ifdef CONFIG_IIO_SIMPLE_DUMMY_BUFFER
|
2014-11-26 18:55:11 +01:00
|
|
|
int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev);
|
2011-10-14 16:34:15 +01:00
|
|
|
void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev);
|
|
|
|
#else
|
2014-12-29 11:50:16 +02:00
|
|
|
static inline int iio_simple_dummy_configure_buffer(struct iio_dev *indio_dev)
|
2011-10-14 16:34:15 +01:00
|
|
|
{
|
|
|
|
return 0;
|
2016-12-20 17:38:10 +01:00
|
|
|
}
|
2015-07-10 17:10:21 +03:00
|
|
|
|
2011-10-14 16:34:15 +01:00
|
|
|
static inline
|
|
|
|
void iio_simple_dummy_unconfigure_buffer(struct iio_dev *indio_dev)
|
2016-12-20 17:38:10 +01:00
|
|
|
{}
|
2014-09-25 16:58:07 +03:00
|
|
|
|
2011-10-14 16:34:15 +01:00
|
|
|
#endif /* CONFIG_IIO_SIMPLE_DUMMY_BUFFER */
|
2014-09-25 16:58:07 +03:00
|
|
|
#endif /* _IIO_SIMPLE_DUMMY_H_ */
|