* [PATCH] staging: comedi: dt2811: add parentheses to fix logic on s->subdev_flags
@ 2016-07-25 22:25 Colin King
2016-07-26 9:19 ` Ian Abbott
2016-08-21 15:07 ` Greg Kroah-Hartman
0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2016-07-25 22:25 UTC (permalink / raw)
To: Ian Abbott, H Hartley Sweeten, Greg Kroah-Hartman, devel; +Cc: linux-kernel
From: Colin Ian King <colin.king@canonical.com>
We need to add parentheses around ternary operations because currently
the expression SDF_READABLE | (it->options[2] == 1) always evaluates to
true, meaning s->subdev_flags is always assigned SDF_DIFF. Putting the
parentheses around the ternarary operations results in the intended
expression of SDF_REABLE logically or'd with one of SDF_DIFF,
SDF_COMMON or SDF_GROUND.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/staging/comedi/drivers/dt2811.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c
index 904f6377..8bbd938 100644
--- a/drivers/staging/comedi/drivers/dt2811.c
+++ b/drivers/staging/comedi/drivers/dt2811.c
@@ -588,8 +588,8 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
s = &dev->subdevices[0];
s->type = COMEDI_SUBD_AI;
s->subdev_flags = SDF_READABLE |
- (it->options[2] == 1) ? SDF_DIFF :
- (it->options[2] == 2) ? SDF_COMMON : SDF_GROUND;
+ ((it->options[2] == 1) ? SDF_DIFF :
+ (it->options[2] == 2) ? SDF_COMMON : SDF_GROUND);
s->n_chan = (it->options[2] == 1) ? 8 : 16;
s->maxdata = 0x0fff;
s->range_table = board->is_pgh ? &dt2811_pgh_ai_ranges
--
2.8.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: comedi: dt2811: add parentheses to fix logic on s->subdev_flags
2016-07-25 22:25 [PATCH] staging: comedi: dt2811: add parentheses to fix logic on s->subdev_flags Colin King
@ 2016-07-26 9:19 ` Ian Abbott
2016-08-21 15:07 ` Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Ian Abbott @ 2016-07-26 9:19 UTC (permalink / raw)
To: Colin King, H Hartley Sweeten, Greg Kroah-Hartman, devel; +Cc: linux-kernel
On 25/07/16 23:25, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> We need to add parentheses around ternary operations because currently
> the expression SDF_READABLE | (it->options[2] == 1) always evaluates to
> true, meaning s->subdev_flags is always assigned SDF_DIFF. Putting the
> parentheses around the ternarary operations results in the intended
> expression of SDF_REABLE logically or'd with one of SDF_DIFF,
> SDF_COMMON or SDF_GROUND.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> drivers/staging/comedi/drivers/dt2811.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/dt2811.c b/drivers/staging/comedi/drivers/dt2811.c
> index 904f6377..8bbd938 100644
> --- a/drivers/staging/comedi/drivers/dt2811.c
> +++ b/drivers/staging/comedi/drivers/dt2811.c
> @@ -588,8 +588,8 @@ static int dt2811_attach(struct comedi_device *dev, struct comedi_devconfig *it)
> s = &dev->subdevices[0];
> s->type = COMEDI_SUBD_AI;
> s->subdev_flags = SDF_READABLE |
> - (it->options[2] == 1) ? SDF_DIFF :
> - (it->options[2] == 2) ? SDF_COMMON : SDF_GROUND;
> + ((it->options[2] == 1) ? SDF_DIFF :
> + (it->options[2] == 2) ? SDF_COMMON : SDF_GROUND);
> s->n_chan = (it->options[2] == 1) ? 8 : 16;
> s->maxdata = 0x0fff;
> s->range_table = board->is_pgh ? &dt2811_pgh_ai_ranges
>
Thanks for catching that.
Fixes: 7c9574090d30 ("staging: comedi: dt2811: simplify A/D reference
configuration"
Cc: <stable@vger.kernel.org> # 4.7+
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Web: http://www.mev.co.uk/ )=-
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] staging: comedi: dt2811: add parentheses to fix logic on s->subdev_flags
2016-07-25 22:25 [PATCH] staging: comedi: dt2811: add parentheses to fix logic on s->subdev_flags Colin King
2016-07-26 9:19 ` Ian Abbott
@ 2016-08-21 15:07 ` Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2016-08-21 15:07 UTC (permalink / raw)
To: Colin King; +Cc: Ian Abbott, H Hartley Sweeten, devel, linux-kernel
On Mon, Jul 25, 2016 at 11:25:25PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> We need to add parentheses around ternary operations because currently
> the expression SDF_READABLE | (it->options[2] == 1) always evaluates to
> true, meaning s->subdev_flags is always assigned SDF_DIFF. Putting the
> parentheses around the ternarary operations results in the intended
> expression of SDF_REABLE logically or'd with one of SDF_DIFF,
> SDF_COMMON or SDF_GROUND.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> Fixes: 7c9574090d30 ("staging: comedi: dt2811: simplify A/D reference configuration")
> Cc: <stable@vger.kernel.org> # 4.7+
> Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Dan sent a patch for this before you did :(
And this went into 4.8-rc1, not 4.7.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-08-21 21:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-25 22:25 [PATCH] staging: comedi: dt2811: add parentheses to fix logic on s->subdev_flags Colin King
2016-07-26 9:19 ` Ian Abbott
2016-08-21 15:07 ` Greg Kroah-Hartman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.