From: Lars-Peter Clausen <lars@metafoo.de>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Jonathan Cameron <jic23@cam.ac.uk>,
Michael Hennerich <michael.hennerich@analog.com>,
linux-iio@vger.kernel.org,
device-drivers-devel@blackfin.uclinux.org, drivers@analog.com
Subject: Re: [PATCH 2/3] staging:iio: IIO_EVENT_CODE: Clamp channel numbers
Date: Thu, 27 Oct 2011 11:02:25 +0200 [thread overview]
Message-ID: <4EA91E21.8080705@metafoo.de> (raw)
In-Reply-To: <1319705074-3082-2-git-send-email-lars@metafoo.de>
On 10/27/2011 10:44 AM, Lars-Peter Clausen wrote:
> 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>
> ---
> 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 7cf9306..fc2b7e5 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))
>
Since we want to use it in userspace this should obviously be __s16, sorry.
Will fix this before sending the patch on.
next prev parent reply other threads:[~2011-10-27 9:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-27 8:44 [PATCH 1/3] staging:iio: Make write_event_value callback optional Lars-Peter Clausen
2011-10-27 8:44 ` [PATCH 2/3] staging:iio: IIO_EVENT_CODE: Clamp channel numbers Lars-Peter Clausen
2011-10-27 9:02 ` Lars-Peter Clausen [this message]
2011-10-31 12:30 ` Jonathan Cameron
2011-10-27 8:44 ` [PATCH v2 3/3] staging:iio:dac: Add AD5421 driver Lars-Peter Clausen
2011-10-31 11:28 ` Jonathan Cameron
2011-10-31 12:14 ` Lars-Peter Clausen
-- strict thread matches above, loose matches on Subject: below --
2011-11-02 8:40 [PATCH 1/3] staging:iio: Make write_event_value callback optional Lars-Peter Clausen
2011-11-02 8:40 ` [PATCH 2/3] staging:iio: IIO_EVENT_CODE: Clamp channel numbers Lars-Peter Clausen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EA91E21.8080705@metafoo.de \
--to=lars@metafoo.de \
--cc=device-drivers-devel@blackfin.uclinux.org \
--cc=drivers@analog.com \
--cc=jic23@cam.ac.uk \
--cc=linux-iio@vger.kernel.org \
--cc=michael.hennerich@analog.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox