linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ian Abbott <abbotti@mev.co.uk>
To: Colin King <colin.king@canonical.com>,
	H Hartley Sweeten <hsweeten@visionengravers.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	devel@driverdev.osuosl.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: comedi: dt2811: add parentheses to fix logic on s->subdev_flags
Date: Tue, 26 Jul 2016 10:19:09 +0100	[thread overview]
Message-ID: <d5a36dc0-642d-6dd9-dc28-7111ff033016@mev.co.uk> (raw)
In-Reply-To: <1469485525-17632-1-git-send-email-colin.king@canonical.com>

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/  )=-

  reply	other threads:[~2016-07-26  9:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2016-08-21 15:07 ` Greg Kroah-Hartman

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=d5a36dc0-642d-6dd9-dc28-7111ff033016@mev.co.uk \
    --to=abbotti@mev.co.uk \
    --cc=colin.king@canonical.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hsweeten@visionengravers.com \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).