staging:iio:events: Remove obsolete documentation
Subsystems (3)
PATCH 1/4 staging:iio:events: Remove obsolete documentation
Commit 43ba1100 ("staging:iio:events: Use waitqueue lock to protect event queue") removed the event_list_lock field from the iio_event_interface struct, but missed to remove the same field from the documentation for that function.
--- drivers/staging/iio/industrialio-event.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
drivers/staging/iio/industrialio-event.c +0 -1
@@ -28,7 +28,6 @@/** * struct iio_event_interface - chrdev interface for an event line * @wait: wait queue to allow blocking reads of events -* @event_list_lock: mutex to protect the list of detected events * @det_events: list of detected events * @dev_attr_list: list of event interface sysfs attribute * @flags: file operations related flags including busy flag.
Signature · 1 line
1.7.9
PATCH 2/4 staging:iio: Rename IIO_EVENT_CODE_EXTRACT_NUM to IIO_EVENT_CODE_EXTRACT_CHAN
We call this field "chan" throughout IIO with the exception of this one macro. Rename it to be more consistent.
--- drivers/staging/iio/events.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/iio/events.h +1 -1
@@ -96,7 +96,7 @@ enum iio_event_direction {/* Event code number extraction depends on which type of event we have. * Perhaps review this function in the future*/ -#define IIO_EVENT_CODE_EXTRACT_NUM (mask) ((__s16)(mask & 0xFFFF)) +#define IIO_EVENT_CODE_EXTRACT_CHAN (mask) ((__s16)(mask & 0xFFFF))#define IIO_EVENT_CODE_EXTRACT_MODIFIER (mask) ((mask >> 40) & 0xFF)
Signature · 1 line
1.7.9
PATCH 4/4 staging:iio: Add event monitor example application
In reply to Lars-Peter ClausenAdd a small evtest like application to monitor events generated by an IIO device. The application can be used as an example on how to listen for IIO events and also is usful for testing and debugging device drivers which generate IIO events.
--- .../staging/iio/Documentation/iio_event_monitor.c | 241 ++++++++++++++++++++ 1 files changed, 241 insertions(+), 0 deletions(-) create mode 100644 drivers/staging/iio/Documentation/iio_event_monitor.c
drivers/staging/iio/Documentation/iio_event_monitor.c new file +241 -0
@@ -0,0 +1,241 @@ +/* Industrialio buffer test code. +* +* Copyright (c) 2011-2012 Lars-Peter Clausen <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 as published by +* the Free Software Foundation. +* +* This program is primarily intended as an example application. +* Reads the current buffer setup from sysfs and starts a short capture +* from the specified device, pretty printing the result after appropriate +* conversion. +* +* Usage: +* iio_event_monitor <device_name> +* +*/ + +#define _GNU_SOURCE + +#include <unistd.h> +#include <stdbool.h> +#include <stdio.h> +#include <errno.h> +#include <string.h> +#include <poll.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include "iio_utils.h" +#include "../events.h" + +static const char *const iio_chan_type_name_spec[] = { + [IIO_VOLTAGE ] ="voltage" , + [IIO_CURRENT ] ="current" , + [IIO_POWER ] ="power" , + [IIO_ACCEL ] ="accel" , + [IIO_ANGL_VEL ] ="anglvel" , + [IIO_MAGN ] ="magn" , + [IIO_LIGHT ] ="illuminance" , + [IIO_INTENSITY ] ="intensity" , + [IIO_PROXIMITY ] ="proximity" , + [IIO_TEMP ] ="temp" , + [IIO_INCLI ] ="incli" , + [IIO_ROT ] ="rot" , + [IIO_ANGL ] ="angl" , + [IIO_TIMESTAMP ] ="timestamp" , + [IIO_CAPACITANCE ] ="capacitance" , +}; + +static const char *const iio_ev_type_text[] = { + [IIO_EV_TYPE_THRESH ] ="thresh" , + [IIO_EV_TYPE_MAG ] ="mag" , + [IIO_EV_TYPE_ROC ] ="roc" , + [IIO_EV_TYPE_THRESH_ADAPTIVE ] ="thresh_adaptive" , + [IIO_EV_TYPE_MAG_ADAPTIVE ] ="mag_adaptive" , +}; + +static const char *const iio_ev_dir_text[] = { + [IIO_EV_DIR_EITHER ] ="either" , + [IIO_EV_DIR_RISING ] ="rising" , + [IIO_EV_DIR_FALLING ] ="falling" +}; + +static const char *const iio_modifier_names[] = { + [IIO_MOD_X ] ="x" , + [IIO_MOD_Y ] ="y" , + [IIO_MOD_Z ] ="z" , + [IIO_MOD_LIGHT_BOTH ] ="both" , + [IIO_MOD_LIGHT_IR ] ="ir" , +}; + +static bool event_is_known (struct iio_event_data *event) +{ +enum iio_chan_type type =IIO_EVENT_CODE_EXTRACT_CHAN_TYPE (event->id); +enum iio_modifier mod =IIO_EVENT_CODE_EXTRACT_MODIFIER (event->id); +enum iio_event_type ev_type =IIO_EVENT_CODE_EXTRACT_TYPE (event->id); +enum iio_event_direction dir =IIO_EVENT_CODE_EXTRACT_DIR (event->id); + +switch (type) { +case IIO_VOLTAGE : +case IIO_CURRENT : +case IIO_POWER : +case IIO_ACCEL : +case IIO_ANGL_VEL : +case IIO_MAGN : +case IIO_LIGHT : +case IIO_INTENSITY : +case IIO_PROXIMITY : +case IIO_TEMP : +case IIO_INCLI : +case IIO_ROT : +case IIO_ANGL : +case IIO_TIMESTAMP : +case IIO_CAPACITANCE : +break ; +default : +return false; + } + +switch (mod) { +case IIO_NO_MOD : +case IIO_MOD_X : +case IIO_MOD_Y : +case IIO_MOD_Z : +case IIO_MOD_LIGHT_BOTH : +case IIO_MOD_LIGHT_IR : +break ; +default : +return false; + } + +switch (ev_type) { +case IIO_EV_TYPE_THRESH : +case IIO_EV_TYPE_MAG : +case IIO_EV_TYPE_ROC : +case IIO_EV_TYPE_THRESH_ADAPTIVE : +case IIO_EV_TYPE_MAG_ADAPTIVE : +break ; +default : +return false; + } + +switch (dir) { +case IIO_EV_DIR_EITHER : +case IIO_EV_DIR_RISING : +case IIO_EV_DIR_FALLING : +break ; +default : +return false; + } + +return true; +} + +static void print_event (struct iio_event_data *event) +{ +enum iio_chan_type type =IIO_EVENT_CODE_EXTRACT_CHAN_TYPE (event->id); +enum iio_modifier mod =IIO_EVENT_CODE_EXTRACT_MODIFIER (event->id); +enum iio_event_type ev_type =IIO_EVENT_CODE_EXTRACT_TYPE (event->id); +enum iio_event_direction dir =IIO_EVENT_CODE_EXTRACT_DIR (event->id); +int chan =IIO_EVENT_CODE_EXTRACT_CHAN (event->id); +int chan2 =IIO_EVENT_CODE_EXTRACT_CHAN2 (event->id); +bool diff =IIO_EVENT_CODE_EXTRACT_DIFF (event->id); + +if (!event_is_known (event)) { +printf ("Unknown event: time: %lld, id: %llx\n" , + event->timestamp, event->id); +return ; + } + +printf ("Event: time: %lld, " , event->timestamp); + +if (mod !=IIO_NO_MOD ) { +printf ("type: %s(%s), " , + iio_chan_type_name_spec[type], + iio_modifier_names[mod]); + }else { +printf ("type: %s, " , + iio_chan_type_name_spec[type]); + } + +if (diff && chan >=0 && chan2 >=0 ) +printf ("channel: %d-%d, " , chan, chan2); +else if (chan >=0 ) +printf ("channel: %d, " , chan); + +printf ("evtype: %s, direction: %s\n" , + iio_ev_type_text[ev_type], + iio_ev_dir_text[dir]); +} + +int main (int argc,char **argv) +{ +struct iio_event_data event; +const char *device_name; +char *chrdev_name; +int ret; +int dev_num; +int fd, event_fd; + +if (argc <=1 ) { +printf ("Usage: %s <device_name>\n" , argv[0 ]); +return -1 ; + } + + device_name = argv[1 ]; + + dev_num =find_type_by_name (device_name,"iio:device" ); +if (dev_num >=0 ) { +printf ("Found IIO device with name %s with device number %d\n" , + device_name, dev_num); + ret =asprintf (&chrdev_name,"/dev/iio:device%d" , dev_num); +if (ret <0 ) { + ret = -ENOMEM ; + goto error_ret; + } + }else { +/* If we can't find a IIO device by name assume device_name is a +IIO chrdev */ + chrdev_name =strdup (device_name); + } + + fd =open (chrdev_name,0 ); +if (fd ==-1 ) { +fprintf (stdout,"Failed to open %s\n" , chrdev_name); + ret = -errno; + goto error_free_chrdev_name; + } + + ret =ioctl (fd,IIO_GET_EVENT_FD_IOCTL , &event_fd); + +close (fd); + +if (ret ==-1 || event_fd ==-1 ) { +fprintf (stdout,"Failed to retrieve event fd\n" ); + ret = -errno; + goto error_free_chrdev_name; + } + +while (true) { + ret =read (event_fd, &event,sizeof (event)); +if (ret ==-1 ) { +if (errno ==EAGAIN ) { +printf ("nothing available\n" ); +continue ; + }else { +perror ("Failed to read event from device" ); + ret = -errno; +break ; + } + } + +print_event (&event); + } + +close (event_fd); +error_free_chrdev_name: +free (chrdev_name); +error_ret: +return ret; +}
Signature · 1 line
1.7.9
PATCH 3/4 staging:iio: Add missing event code extract macros
In reply to Lars-Peter ClausenAdd macros for extracting whether the event is for a differential channel and the second channel number from the event code. These were the only two fields which did not have such an macro yet.
--- drivers/staging/iio/events.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/staging/iio/events.h +2 -0
@@ -97,7 +97,9 @@ enum iio_event_direction {/* Event code number extraction depends on which type of event we have. * Perhaps review this function in the future*/ #define IIO_EVENT_CODE_EXTRACT_CHAN (mask) ((__s16)(mask & 0xFFFF)) +#define IIO_EVENT_CODE_EXTRACT_CHAN2 (mask) ((__s16)(((mask) >> 16) & 0xFFFF))#define IIO_EVENT_CODE_EXTRACT_MODIFIER (mask) ((mask >> 40) & 0xFF) +#define IIO_EVENT_CODE_EXTRACT_DIFF (mask) (((mask) >> 55) & 0x1)#endif
Signature · 1 line
1.7.9
Greg Kroah-Hartman
maintainerRe: [PATCH 2/4] staging:iio: Rename IIO_EVENT_CODE_EXTRACT_NUM to IIO_EVENT_CODE_EXTRACT_CHAN
In reply to Lars-Peter ClausenQuoted 1 line · Lars-Peter Clausen
We call this field "chan" throughout IIO with the exception of this one=
macro.
drivers/staging/iio/events.=
Quoted 9 lines
Rename it to be more consistent.
=20Signed-off-by Lars-Peter Clausen <[email protected]>Acked-by Jonathan Cameron <[email protected]>--- drivers/staging/iio/events.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)=20
drivers/staging/iio/events.= renamed from drivers/staging/iio/events.h +0
-0
h
Quoted 6 lines
index bfb6340..416800e 100644
drivers/staging/iio/events.h +0
-0@@ -96,7 +96,7 @@ enum iio_event_direction {=20
/* Event code number extraction depends on which type of event we have=
.
drivers/staging/iio/events.h enum iio_event_direction { · line 99
Quoted 3 lines
* Perhaps review this function in the future*/
drivers/staging/iio/events.h +1
-1-#define IIO_EVENT_CODE_EXTRACT_NUM (mask) ((__s16)(mask & 0xFFFF)) +#define IIO_EVENT_CODE_EXTRACT_CHAN (mask) ((__s16)(mask & 0xFFFF))
Nice, but then you just broke the build:
drivers/staging/iio/adc/ad799x_core.c: In function =E2=80=98ad799x_write_= event_value=E2=80=99:drivers/staging/iio/adc/ad799x_core.c:259:2: error: implicit declaration = of function =E2=80=98IIO_EVENT_CODE_EXTRACT_NUM=E2=80=99 [-Werror=3Dimpli= cit-function-declaration]
cc1: some warnings being treated as errors
Please be more careful when sending patches, I've dropped all 4 of these...
greg k-h
Re: [PATCH 2/4] staging:iio: Rename IIO_EVENT_CODE_EXTRACT_NUM to IIO_EVENT_CODE_EXTRACT_CHAN
In reply to Lars-Peter ClausenQuoted 14 lines · Lars-Peter Clausen
We call this field "chan" throughout IIO with the exception of this one macro. Rename it to be more consistent.
Signed-off-by Lars-Peter Clausen <[email protected]>Acked-by Jonathan Cameron <[email protected]>--- drivers/staging/iio/events.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/staging/iio/events.h +0
-0
drivers/staging/iio/events.h enum iio_event_direction { · line 102
Quoted 8 lines
drivers/staging/iio/events.h +1
-1@@ -96,7 +96,7 @@ enum iio_event_direction {/* Event code number extraction depends on which type of event we have. * Perhaps review this function in the future*/ -#define IIO_EVENT_CODE_EXTRACT_NUM (mask) ((__s16)(mask & 0xFFFF)) +#define IIO_EVENT_CODE_EXTRACT_CHAN (mask) ((__s16)(mask & 0xFFFF))#define IIO_EVENT_CODE_EXTRACT_MODIFIER (mask) ((mask >> 40) & 0xFF)
Uh... What? This breaks the build.
regards,
dan carpenter
Re: [PATCH 3/4] staging:iio: Add missing event code extract macros
In reply to Lars-Peter ClausenQuoted 15 lines · Lars-Peter Clausen
Add macros for extracting whether the event is for a differential channel and the second channel number from the event code. These were the only two fields which did not have such an macro yet.
Signed-off-by Lars-Peter Clausen <[email protected]>Acked-by Jonathan Cameron <[email protected]>--- drivers/staging/iio/events.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/staging/iio/events.h +0
-0
drivers/staging/iio/events.h enum iio_event_direction { · line 104
Quoted 8 lines
drivers/staging/iio/events.h +2
-0@@ -97,7 +97,9 @@ enum iio_event_direction {/* Event code number extraction depends on which type of event we have. * Perhaps review this function in the future*/ #define IIO_EVENT_CODE_EXTRACT_CHAN (mask) ((__s16)(mask & 0xFFFF)) +#define IIO_EVENT_CODE_EXTRACT_CHAN2 (mask) ((__s16)(((mask) >> 16) & 0xFFFF))#define IIO_EVENT_CODE_EXTRACT_MODIFIER (mask) ((mask >> 40) & 0xFF) +#define IIO_EVENT_CODE_EXTRACT_DIFF (mask) (((mask) >> 55) & 0x1)
Breaks the build.
regards,
dan carpenter
Re: [PATCH 3/4] staging:iio: Add missing event code extract macros
Quoted 21 lines · Dan Carpenter
Quoted 20 lines · Lars-Peter Clausen
Add macros for extracting whether the event is for a differential channel and the second channel number from the event code. These were the only two fields which did not have such an macro yet.
Signed-off-by Lars-Peter Clausen <[email protected]>Acked-by Jonathan Cameron <[email protected]>--- drivers/staging/iio/events.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/staging/iio/events.h +1
-0@@ -97,7 +97,9 @@ enum iio_event_direction {/* Event code number extraction depends on which type of event we have. * Perhaps review this function in the future*/ #define IIO_EVENT_CODE_EXTRACT_CHAN (mask) ((__s16)(mask & 0xFFFF)) +#define IIO_EVENT_CODE_EXTRACT_CHAN2 (mask) ((__s16)(((mask) >> 16) & 0xFFFF))
Quoted 6 lines
drivers/staging/iio/events.h enum iio_event_direction { · line 104
Quoted 3 lines
drivers/staging/iio/events.h +1
-0#define IIO_EVENT_CODE_EXTRACT_MODIFIER (mask) ((mask >> 40) & 0xFF) +#define IIO_EVENT_CODE_EXTRACT_DIFF (mask) (((mask) >> 55) & 0x1)Breaks the build.
Oops. This isn't a rename. It doesn't break the build. Why are we adding macros which nobody uses?
regards,
dan carpenter
Re: [PATCH 3/4] staging:iio: Add missing event code extract macros
Quoted 29 lines · Dan Carpenter
Quoted 21 lines · Dan Carpenter
Quoted 20 lines · Lars-Peter Clausen
Add macros for extracting whether the event is for a differential channel and the second channel number from the event code. These were the only two fields which did not have such an macro yet.
Signed-off-by Lars-Peter Clausen <[email protected]>Acked-by Jonathan Cameron <[email protected]>--- drivers/staging/iio/events.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/staging/iio/events.h +1
-0@@ -97,7 +97,9 @@ enum iio_event_direction {/* Event code number extraction depends on which type of event we have. * Perhaps review this function in the future*/ #define IIO_EVENT_CODE_EXTRACT_CHAN (mask) ((__s16)(mask & 0xFFFF)) +#define IIO_EVENT_CODE_EXTRACT_CHAN2 (mask) ((__s16)(((mask) >> 16) & 0xFFFF))Quoted 6 lines
drivers/staging/iio/events.h enum iio_event_direction { · line 104
Quoted 3 lines
drivers/staging/iio/events.h +1
-0#define IIO_EVENT_CODE_EXTRACT_MODIFIER (mask) ((mask >> 40) & 0xFF) +#define IIO_EVENT_CODE_EXTRACT_DIFF (mask) (((mask) >> 55) & 0x1)Breaks the build.
Quoted 2 lines
Oops. This isn't a rename. It doesn't break the build. Why are we adding macros which nobody uses?
Patch 4 in this series adds a user.
Re: [PATCH 3/4] staging:iio: Add missing event code extract macros
Quoted 8 lines · Lars-Peter Clausen
Quoted 6 lines
Quoted 3 lines
Breaks the build.
Oops. This isn't a rename. It doesn't break the build. Why are we adding macros which nobody uses?
Patch 4 in this series adds a user.
Ah. That's fine then. My bad. Sorry for that.
regards,
dan carpenter