Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: Export userspace IIO headers

After UAPI header file split [1] all user-kernel interfaces were
placed under include/uapi/.

This patch moves IIO user specific API from:
* include/linux/iio/events.h => include/uapi/linux/iio/events.h
* include/linux/types.h => include/uapi/linux/types.h

Now there is no need for nasty tricks to compile userspace programs
(e.g iio_event_monitor). Just installing the kernel headers with
make headers_install command does the job.

[1] http://lwn.net/Articles/507794/

Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Daniel Baluta and committed by
Jonathan Cameron
293487c8 e257a16e

+140 -106
+1 -29
include/linux/iio/events.h
··· 9 9 #ifndef _IIO_EVENTS_H_ 10 10 #define _IIO_EVENTS_H_ 11 11 12 - #include <linux/ioctl.h> 13 - #include <linux/types.h> 14 12 #include <linux/iio/types.h> 15 - 16 - /** 17 - * struct iio_event_data - The actual event being pushed to userspace 18 - * @id: event identifier 19 - * @timestamp: best estimate of time of event occurrence (often from 20 - * the interrupt handler) 21 - */ 22 - struct iio_event_data { 23 - __u64 id; 24 - __s64 timestamp; 25 - }; 26 - 27 - #define IIO_GET_EVENT_FD_IOCTL _IOR('i', 0x90, int) 13 + #include <uapi/linux/iio/events.h> 28 14 29 15 /** 30 16 * IIO_EVENT_CODE() - create event identifier ··· 55 69 56 70 #define IIO_UNMOD_EVENT_CODE(chan_type, number, type, direction) \ 57 71 IIO_EVENT_CODE(chan_type, 0, 0, direction, type, number, 0, 0) 58 - 59 - #define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF) 60 - 61 - #define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0x7F) 62 - 63 - #define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF) 64 - 65 - /* Event code number extraction depends on which type of event we have. 66 - * Perhaps review this function in the future*/ 67 - #define IIO_EVENT_CODE_EXTRACT_CHAN(mask) ((__s16)(mask & 0xFFFF)) 68 - #define IIO_EVENT_CODE_EXTRACT_CHAN2(mask) ((__s16)(((mask) >> 16) & 0xFFFF)) 69 - 70 - #define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 40) & 0xFF) 71 - #define IIO_EVENT_CODE_EXTRACT_DIFF(mask) (((mask) >> 55) & 0x1) 72 72 73 73 #endif
+1 -77
include/linux/iio/types.h
··· 10 10 #ifndef _IIO_TYPES_H_ 11 11 #define _IIO_TYPES_H_ 12 12 13 - enum iio_chan_type { 14 - IIO_VOLTAGE, 15 - IIO_CURRENT, 16 - IIO_POWER, 17 - IIO_ACCEL, 18 - IIO_ANGL_VEL, 19 - IIO_MAGN, 20 - IIO_LIGHT, 21 - IIO_INTENSITY, 22 - IIO_PROXIMITY, 23 - IIO_TEMP, 24 - IIO_INCLI, 25 - IIO_ROT, 26 - IIO_ANGL, 27 - IIO_TIMESTAMP, 28 - IIO_CAPACITANCE, 29 - IIO_ALTVOLTAGE, 30 - IIO_CCT, 31 - IIO_PRESSURE, 32 - IIO_HUMIDITYRELATIVE, 33 - IIO_ACTIVITY, 34 - IIO_STEPS, 35 - IIO_ENERGY, 36 - IIO_DISTANCE, 37 - IIO_VELOCITY, 38 - }; 39 - 40 - enum iio_modifier { 41 - IIO_NO_MOD, 42 - IIO_MOD_X, 43 - IIO_MOD_Y, 44 - IIO_MOD_Z, 45 - IIO_MOD_X_AND_Y, 46 - IIO_MOD_X_AND_Z, 47 - IIO_MOD_Y_AND_Z, 48 - IIO_MOD_X_AND_Y_AND_Z, 49 - IIO_MOD_X_OR_Y, 50 - IIO_MOD_X_OR_Z, 51 - IIO_MOD_Y_OR_Z, 52 - IIO_MOD_X_OR_Y_OR_Z, 53 - IIO_MOD_LIGHT_BOTH, 54 - IIO_MOD_LIGHT_IR, 55 - IIO_MOD_ROOT_SUM_SQUARED_X_Y, 56 - IIO_MOD_SUM_SQUARED_X_Y_Z, 57 - IIO_MOD_LIGHT_CLEAR, 58 - IIO_MOD_LIGHT_RED, 59 - IIO_MOD_LIGHT_GREEN, 60 - IIO_MOD_LIGHT_BLUE, 61 - IIO_MOD_QUATERNION, 62 - IIO_MOD_TEMP_AMBIENT, 63 - IIO_MOD_TEMP_OBJECT, 64 - IIO_MOD_NORTH_MAGN, 65 - IIO_MOD_NORTH_TRUE, 66 - IIO_MOD_NORTH_MAGN_TILT_COMP, 67 - IIO_MOD_NORTH_TRUE_TILT_COMP, 68 - IIO_MOD_RUNNING, 69 - IIO_MOD_JOGGING, 70 - IIO_MOD_WALKING, 71 - IIO_MOD_STILL, 72 - IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z, 73 - }; 74 - 75 - enum iio_event_type { 76 - IIO_EV_TYPE_THRESH, 77 - IIO_EV_TYPE_MAG, 78 - IIO_EV_TYPE_ROC, 79 - IIO_EV_TYPE_THRESH_ADAPTIVE, 80 - IIO_EV_TYPE_MAG_ADAPTIVE, 81 - IIO_EV_TYPE_CHANGE, 82 - }; 13 + #include <uapi/linux/iio/types.h> 83 14 84 15 enum iio_event_info { 85 16 IIO_EV_INFO_ENABLE, 86 17 IIO_EV_INFO_VALUE, 87 18 IIO_EV_INFO_HYSTERESIS, 88 19 IIO_EV_INFO_PERIOD, 89 - }; 90 - 91 - enum iio_event_direction { 92 - IIO_EV_DIR_EITHER, 93 - IIO_EV_DIR_RISING, 94 - IIO_EV_DIR_FALLING, 95 - IIO_EV_DIR_NONE, 96 20 }; 97 21 98 22 #define IIO_VAL_INT 1
+1
include/uapi/linux/Kbuild
··· 6 6 header-y += dvb/ 7 7 header-y += hdlc/ 8 8 header-y += hsi/ 9 + header-y += iio/ 9 10 header-y += isdn/ 10 11 header-y += mmc/ 11 12 header-y += nfsd/
+3
include/uapi/linux/iio/Kbuild
··· 1 + # UAPI Header export list 2 + header-y += events.h 3 + header-y += types.h
+42
include/uapi/linux/iio/events.h
··· 1 + /* The industrial I/O - event passing to userspace 2 + * 3 + * Copyright (c) 2008-2011 Jonathan Cameron 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms of the GNU General Public License version 2 as published by 7 + * the Free Software Foundation. 8 + */ 9 + #ifndef _UAPI_IIO_EVENTS_H_ 10 + #define _UAPI_IIO_EVENTS_H_ 11 + 12 + #include <linux/ioctl.h> 13 + #include <linux/types.h> 14 + 15 + /** 16 + * struct iio_event_data - The actual event being pushed to userspace 17 + * @id: event identifier 18 + * @timestamp: best estimate of time of event occurrence (often from 19 + * the interrupt handler) 20 + */ 21 + struct iio_event_data { 22 + __u64 id; 23 + __s64 timestamp; 24 + }; 25 + 26 + #define IIO_GET_EVENT_FD_IOCTL _IOR('i', 0x90, int) 27 + 28 + #define IIO_EVENT_CODE_EXTRACT_TYPE(mask) ((mask >> 56) & 0xFF) 29 + 30 + #define IIO_EVENT_CODE_EXTRACT_DIR(mask) ((mask >> 48) & 0x7F) 31 + 32 + #define IIO_EVENT_CODE_EXTRACT_CHAN_TYPE(mask) ((mask >> 32) & 0xFF) 33 + 34 + /* Event code number extraction depends on which type of event we have. 35 + * Perhaps review this function in the future*/ 36 + #define IIO_EVENT_CODE_EXTRACT_CHAN(mask) ((__s16)(mask & 0xFFFF)) 37 + #define IIO_EVENT_CODE_EXTRACT_CHAN2(mask) ((__s16)(((mask) >> 16) & 0xFFFF)) 38 + 39 + #define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 40) & 0xFF) 40 + #define IIO_EVENT_CODE_EXTRACT_DIFF(mask) (((mask) >> 55) & 0x1) 41 + 42 + #endif /* _UAPI_IIO_EVENTS_H_ */
+92
include/uapi/linux/iio/types.h
··· 1 + /* industrial I/O data types needed both in and out of kernel 2 + * 3 + * Copyright (c) 2008 Jonathan Cameron 4 + * 5 + * This program is free software; you can redistribute it and/or modify it 6 + * under the terms of the GNU General Public License version 2 as published by 7 + * the Free Software Foundation. 8 + */ 9 + 10 + #ifndef _UAPI_IIO_TYPES_H_ 11 + #define _UAPI_IIO_TYPES_H_ 12 + 13 + enum iio_chan_type { 14 + IIO_VOLTAGE, 15 + IIO_CURRENT, 16 + IIO_POWER, 17 + IIO_ACCEL, 18 + IIO_ANGL_VEL, 19 + IIO_MAGN, 20 + IIO_LIGHT, 21 + IIO_INTENSITY, 22 + IIO_PROXIMITY, 23 + IIO_TEMP, 24 + IIO_INCLI, 25 + IIO_ROT, 26 + IIO_ANGL, 27 + IIO_TIMESTAMP, 28 + IIO_CAPACITANCE, 29 + IIO_ALTVOLTAGE, 30 + IIO_CCT, 31 + IIO_PRESSURE, 32 + IIO_HUMIDITYRELATIVE, 33 + IIO_ACTIVITY, 34 + IIO_STEPS, 35 + IIO_ENERGY, 36 + IIO_DISTANCE, 37 + IIO_VELOCITY, 38 + }; 39 + 40 + enum iio_modifier { 41 + IIO_NO_MOD, 42 + IIO_MOD_X, 43 + IIO_MOD_Y, 44 + IIO_MOD_Z, 45 + IIO_MOD_X_AND_Y, 46 + IIO_MOD_X_AND_Z, 47 + IIO_MOD_Y_AND_Z, 48 + IIO_MOD_X_AND_Y_AND_Z, 49 + IIO_MOD_X_OR_Y, 50 + IIO_MOD_X_OR_Z, 51 + IIO_MOD_Y_OR_Z, 52 + IIO_MOD_X_OR_Y_OR_Z, 53 + IIO_MOD_LIGHT_BOTH, 54 + IIO_MOD_LIGHT_IR, 55 + IIO_MOD_ROOT_SUM_SQUARED_X_Y, 56 + IIO_MOD_SUM_SQUARED_X_Y_Z, 57 + IIO_MOD_LIGHT_CLEAR, 58 + IIO_MOD_LIGHT_RED, 59 + IIO_MOD_LIGHT_GREEN, 60 + IIO_MOD_LIGHT_BLUE, 61 + IIO_MOD_QUATERNION, 62 + IIO_MOD_TEMP_AMBIENT, 63 + IIO_MOD_TEMP_OBJECT, 64 + IIO_MOD_NORTH_MAGN, 65 + IIO_MOD_NORTH_TRUE, 66 + IIO_MOD_NORTH_MAGN_TILT_COMP, 67 + IIO_MOD_NORTH_TRUE_TILT_COMP, 68 + IIO_MOD_RUNNING, 69 + IIO_MOD_JOGGING, 70 + IIO_MOD_WALKING, 71 + IIO_MOD_STILL, 72 + IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z, 73 + }; 74 + 75 + enum iio_event_type { 76 + IIO_EV_TYPE_THRESH, 77 + IIO_EV_TYPE_MAG, 78 + IIO_EV_TYPE_ROC, 79 + IIO_EV_TYPE_THRESH_ADAPTIVE, 80 + IIO_EV_TYPE_MAG_ADAPTIVE, 81 + IIO_EV_TYPE_CHANGE, 82 + }; 83 + 84 + enum iio_event_direction { 85 + IIO_EV_DIR_EITHER, 86 + IIO_EV_DIR_RISING, 87 + IIO_EV_DIR_FALLING, 88 + IIO_EV_DIR_NONE, 89 + }; 90 + 91 + #endif /* _UAPI_IIO_TYPES_H_ */ 92 +