* [PATCH 0/3] iio: finish cleanup of IIO_EVENT_CODE macros
@ 2024-11-01 22:17 David Lechner
2024-11-01 22:17 ` [PATCH 1/3] iio: dummy: use specialized event code macros David Lechner
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: David Lechner @ 2024-11-01 22:17 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, David Lechner
Since [1], there are only a couple of users IIO_EVENT_CODE left in the
kernel. We can clean these up too. Then we can make that macro "private"
do discourage others from using it in the future.
[1]: https://lore.kernel.org/linux-iio/20241028-iio-add-macro-for-even-identifier-for-differential-channels-v1-0-b452c90f7ea6@baylibre.com/
---
David Lechner (3):
iio: dummy: use specialized event code macros
iio: accel: mma9553: use specialized event code macros
iio: events: make IIO_EVENT_CODE macro private
drivers/iio/accel/mma9553.c | 24 +++++++++++------------
drivers/iio/dummy/iio_simple_dummy_events.c | 30 ++++++++++++++---------------
include/linux/iio/events.h | 15 +++++++++------
3 files changed, 34 insertions(+), 35 deletions(-)
---
base-commit: c218214db564ca7d6885fa5859541a86197856c0
change-id: 20241101-iio-fix-event-macro-use-cb374ab30c99
Best regards,
--
David Lechner <dlechner@baylibre.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] iio: dummy: use specialized event code macros
2024-11-01 22:17 [PATCH 0/3] iio: finish cleanup of IIO_EVENT_CODE macros David Lechner
@ 2024-11-01 22:17 ` David Lechner
2024-11-01 22:17 ` [PATCH 2/3] iio: accel: mma9553: " David Lechner
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: David Lechner @ 2024-11-01 22:17 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, David Lechner
Simplify the code by using IIO_UNMOD_EVENT_CODE and IIO_MOD_EVENT_CODE
instead of IIO_EVENT_CODE.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/dummy/iio_simple_dummy_events.c | 30 ++++++++++++++---------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/drivers/iio/dummy/iio_simple_dummy_events.c b/drivers/iio/dummy/iio_simple_dummy_events.c
index c7f2d3a4d60b..b51ec21b6309 100644
--- a/drivers/iio/dummy/iio_simple_dummy_events.c
+++ b/drivers/iio/dummy/iio_simple_dummy_events.c
@@ -183,36 +183,34 @@ static irqreturn_t iio_simple_dummy_event_handler(int irq, void *private)
switch (st->regs->reg_data) {
case 0:
iio_push_event(indio_dev,
- IIO_EVENT_CODE(IIO_VOLTAGE, 0, 0,
- IIO_EV_DIR_RISING,
- IIO_EV_TYPE_THRESH, 0, 0, 0),
+ IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 0,
+ IIO_EV_TYPE_THRESH,
+ IIO_EV_DIR_RISING),
st->event_timestamp);
break;
case 1:
if (st->activity_running > st->event_val)
iio_push_event(indio_dev,
- IIO_EVENT_CODE(IIO_ACTIVITY, 0,
- IIO_MOD_RUNNING,
- IIO_EV_DIR_RISING,
- IIO_EV_TYPE_THRESH,
- 0, 0, 0),
+ IIO_MOD_EVENT_CODE(IIO_ACTIVITY, 0,
+ IIO_MOD_RUNNING,
+ IIO_EV_TYPE_THRESH,
+ IIO_EV_DIR_RISING),
st->event_timestamp);
break;
case 2:
if (st->activity_walking < st->event_val)
iio_push_event(indio_dev,
- IIO_EVENT_CODE(IIO_ACTIVITY, 0,
- IIO_MOD_WALKING,
- IIO_EV_DIR_FALLING,
- IIO_EV_TYPE_THRESH,
- 0, 0, 0),
+ IIO_MOD_EVENT_CODE(IIO_ACTIVITY, 0,
+ IIO_MOD_WALKING,
+ IIO_EV_TYPE_THRESH,
+ IIO_EV_DIR_FALLING),
st->event_timestamp);
break;
case 3:
iio_push_event(indio_dev,
- IIO_EVENT_CODE(IIO_STEPS, 0, IIO_NO_MOD,
- IIO_EV_DIR_NONE,
- IIO_EV_TYPE_CHANGE, 0, 0, 0),
+ IIO_UNMOD_EVENT_CODE(IIO_STEPS, 0,
+ IIO_EV_TYPE_CHANGE,
+ IIO_EV_DIR_NONE),
st->event_timestamp);
break;
default:
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] iio: accel: mma9553: use specialized event code macros
2024-11-01 22:17 [PATCH 0/3] iio: finish cleanup of IIO_EVENT_CODE macros David Lechner
2024-11-01 22:17 ` [PATCH 1/3] iio: dummy: use specialized event code macros David Lechner
@ 2024-11-01 22:17 ` David Lechner
2024-11-01 22:17 ` [PATCH 3/3] iio: events: make IIO_EVENT_CODE macro private David Lechner
2024-11-02 15:00 ` [PATCH 0/3] iio: finish cleanup of IIO_EVENT_CODE macros Jonathan Cameron
3 siblings, 0 replies; 5+ messages in thread
From: David Lechner @ 2024-11-01 22:17 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, David Lechner
Simplify the code by using IIO_UNMOD_EVENT_CODE and IIO_MOD_EVENT_CODE
instead of IIO_EVENT_CODE.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
drivers/iio/accel/mma9553.c | 24 +++++++++++-------------
1 file changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c
index 43ba04c606a4..8536743a6886 100644
--- a/drivers/iio/accel/mma9553.c
+++ b/drivers/iio/accel/mma9553.c
@@ -1031,9 +1031,9 @@ static irqreturn_t mma9553_event_handler(int irq, void *private)
if (ev_step_detect->enabled && (stepcnt != data->stepcnt)) {
data->stepcnt = stepcnt;
iio_push_event(indio_dev,
- IIO_EVENT_CODE(IIO_STEPS, 0, IIO_NO_MOD,
- IIO_EV_DIR_NONE,
- IIO_EV_TYPE_CHANGE, 0, 0, 0),
+ IIO_UNMOD_EVENT_CODE(IIO_STEPS, 0,
+ IIO_EV_TYPE_CHANGE,
+ IIO_EV_DIR_NONE),
data->timestamp);
}
@@ -1042,20 +1042,18 @@ static irqreturn_t mma9553_event_handler(int irq, void *private)
/* ev_activity can be NULL if activity == ACTIVITY_UNKNOWN */
if (ev_prev_activity && ev_prev_activity->enabled)
iio_push_event(indio_dev,
- IIO_EVENT_CODE(IIO_ACTIVITY, 0,
- ev_prev_activity->info->mod,
- IIO_EV_DIR_FALLING,
- IIO_EV_TYPE_THRESH, 0, 0,
- 0),
+ IIO_MOD_EVENT_CODE(IIO_ACTIVITY, 0,
+ ev_prev_activity->info->mod,
+ IIO_EV_TYPE_THRESH,
+ IIO_EV_DIR_FALLING),
data->timestamp);
if (ev_activity && ev_activity->enabled)
iio_push_event(indio_dev,
- IIO_EVENT_CODE(IIO_ACTIVITY, 0,
- ev_activity->info->mod,
- IIO_EV_DIR_RISING,
- IIO_EV_TYPE_THRESH, 0, 0,
- 0),
+ IIO_MOD_EVENT_CODE(IIO_ACTIVITY, 0,
+ ev_activity->info->mod,
+ IIO_EV_TYPE_THRESH,
+ IIO_EV_DIR_RISING),
data->timestamp);
}
mutex_unlock(&data->mutex);
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] iio: events: make IIO_EVENT_CODE macro private
2024-11-01 22:17 [PATCH 0/3] iio: finish cleanup of IIO_EVENT_CODE macros David Lechner
2024-11-01 22:17 ` [PATCH 1/3] iio: dummy: use specialized event code macros David Lechner
2024-11-01 22:17 ` [PATCH 2/3] iio: accel: mma9553: " David Lechner
@ 2024-11-01 22:17 ` David Lechner
2024-11-02 15:00 ` [PATCH 0/3] iio: finish cleanup of IIO_EVENT_CODE macros Jonathan Cameron
3 siblings, 0 replies; 5+ messages in thread
From: David Lechner @ 2024-11-01 22:17 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, linux-kernel, David Lechner
Make IIO_EVENT_CODE "private" by adding a leading underscore.
There are no more users of this macro in the kernel so we can make it
"private" and encourage developers to use the specialized versions of
the macro instead.
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
include/linux/iio/events.h | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/include/linux/iio/events.h b/include/linux/iio/events.h
index eeaba5e1525e..72062a0c7c87 100644
--- a/include/linux/iio/events.h
+++ b/include/linux/iio/events.h
@@ -10,7 +10,7 @@
#include <uapi/linux/iio/events.h>
/**
- * IIO_EVENT_CODE() - create event identifier
+ * _IIO_EVENT_CODE() - create event identifier
* @chan_type: Type of the channel. Should be one of enum iio_chan_type.
* @diff: Whether the event is for an differential channel or not.
* @modifier: Modifier for the channel. Should be one of enum iio_modifier.
@@ -19,10 +19,13 @@
* @chan: Channel number for non-differential channels.
* @chan1: First channel number for differential channels.
* @chan2: Second channel number for differential channels.
+ *
+ * Drivers should use the specialized macros below instead of using this one
+ * directly.
*/
-#define IIO_EVENT_CODE(chan_type, diff, modifier, direction, \
- type, chan, chan1, chan2) \
+#define _IIO_EVENT_CODE(chan_type, diff, modifier, direction, \
+ type, chan, chan1, chan2) \
(((u64)type << 56) | ((u64)diff << 55) | \
((u64)direction << 48) | ((u64)modifier << 40) | \
((u64)chan_type << 32) | (((u16)chan2) << 16) | ((u16)chan1) | \
@@ -41,7 +44,7 @@
#define IIO_MOD_EVENT_CODE(chan_type, number, modifier, \
type, direction) \
- IIO_EVENT_CODE(chan_type, 0, modifier, direction, type, number, 0, 0)
+ _IIO_EVENT_CODE(chan_type, 0, modifier, direction, type, number, 0, 0)
/**
* IIO_UNMOD_EVENT_CODE() - create event identifier for unmodified (non
@@ -53,7 +56,7 @@
*/
#define IIO_UNMOD_EVENT_CODE(chan_type, number, type, direction) \
- IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0)
+ _IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0)
/**
* IIO_DIFF_EVENT_CODE() - create event identifier for differential channels
@@ -65,6 +68,6 @@
*/
#define IIO_DIFF_EVENT_CODE(chan_type, chan1, chan2, type, direction) \
- IIO_EVENT_CODE(chan_type, 1, 0, direction, type, 0, chan1, chan2)
+ _IIO_EVENT_CODE(chan_type, 1, 0, direction, type, 0, chan1, chan2)
#endif
--
2.43.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] iio: finish cleanup of IIO_EVENT_CODE macros
2024-11-01 22:17 [PATCH 0/3] iio: finish cleanup of IIO_EVENT_CODE macros David Lechner
` (2 preceding siblings ...)
2024-11-01 22:17 ` [PATCH 3/3] iio: events: make IIO_EVENT_CODE macro private David Lechner
@ 2024-11-02 15:00 ` Jonathan Cameron
3 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2024-11-02 15:00 UTC (permalink / raw)
To: David Lechner; +Cc: linux-iio, linux-kernel
On Fri, 01 Nov 2024 17:17:07 -0500
David Lechner <dlechner@baylibre.com> wrote:
> Since [1], there are only a couple of users IIO_EVENT_CODE left in the
> kernel. We can clean these up too. Then we can make that macro "private"
> do discourage others from using it in the future.
>
> [1]: https://lore.kernel.org/linux-iio/20241028-iio-add-macro-for-even-identifier-for-differential-channels-v1-0-b452c90f7ea6@baylibre.com/
Seems resonable. Applied to the togreg branch of iio.git
and pushed out as testing.
Thanks,
Jonathan
>
> ---
> David Lechner (3):
> iio: dummy: use specialized event code macros
> iio: accel: mma9553: use specialized event code macros
> iio: events: make IIO_EVENT_CODE macro private
>
> drivers/iio/accel/mma9553.c | 24 +++++++++++------------
> drivers/iio/dummy/iio_simple_dummy_events.c | 30 ++++++++++++++---------------
> include/linux/iio/events.h | 15 +++++++++------
> 3 files changed, 34 insertions(+), 35 deletions(-)
> ---
> base-commit: c218214db564ca7d6885fa5859541a86197856c0
> change-id: 20241101-iio-fix-event-macro-use-cb374ab30c99
>
> Best regards,
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-11-02 15:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-01 22:17 [PATCH 0/3] iio: finish cleanup of IIO_EVENT_CODE macros David Lechner
2024-11-01 22:17 ` [PATCH 1/3] iio: dummy: use specialized event code macros David Lechner
2024-11-01 22:17 ` [PATCH 2/3] iio: accel: mma9553: " David Lechner
2024-11-01 22:17 ` [PATCH 3/3] iio: events: make IIO_EVENT_CODE macro private David Lechner
2024-11-02 15:00 ` [PATCH 0/3] iio: finish cleanup of IIO_EVENT_CODE macros Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®