diff options
author | Lars-Peter Clausen <lars@metafoo.de> | 2011-11-02 08:40:01 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-11-27 00:39:58 (GMT) |
commit | 19c2aedc54b927ab10d3723038182eedf90438a4 (patch) | |
tree | c097eb93b9f92c37c4c0e8fd0c69cc4435acff8c | |
parent | 43c0364551d3ca0042f6f6a3da701edf1143d62f (diff) | |
download | linux-fsl-qoriq-19c2aedc54b927ab10d3723038182eedf90438a4.tar.xz |
staging:iio: IIO_EVENT_CODE: Clamp channel numbers
Make sure we only use the allotted space for channel numbers in the event mask
and do not let them override other fields.
Since negative values are valid channel number, cast the channel number to
signed when extracting it from an event mask.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/staging/iio/events.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/staging/iio/events.h b/drivers/staging/iio/events.h index 9275954..bfb6340 100644 --- a/drivers/staging/iio/events.h +++ b/drivers/staging/iio/events.h @@ -56,7 +56,8 @@ enum iio_event_direction { type, chan, chan1, chan2) \ (((u64)type << 56) | ((u64)diff << 55) | \ ((u64)direction << 48) | ((u64)modifier << 40) | \ - ((u64)chan_type << 32) | (chan2 << 16) | chan1 | chan) + ((u64)chan_type << 32) | (((u16)chan2) << 16) | ((u16)chan1) | \ + ((u16)chan)) #define IIO_EV_DIR_MAX 4 @@ -95,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) (mask & 0xFFFF) +#define IIO_EVENT_CODE_EXTRACT_NUM(mask) ((__s16)(mask & 0xFFFF)) #define IIO_EVENT_CODE_EXTRACT_MODIFIER(mask) ((mask >> 40) & 0xFF) |