All of lore.kernel.org
 help / color / mirror / Atom feed
From: Giuliano Belinassi <giuliano.belinassi@gmail.com>
To: joe@perches.com
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Michael Hennerich <Michael.Hennerich@analog.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, kernel-usp@googlegroups.com
Subject: Re: [PATCH] staging: iio: ad7280a: Lines should not end with a '(' - style
Date: Tue, 16 Oct 2018 19:48:10 -0300	[thread overview]
Message-ID: <CAG4RSAFMGSFyUqutRD2SRMsBt5RHVo5RUQsBq7fis6OVWxSZbg@mail.gmail.com> (raw)
In-Reply-To: <5717d448daad72d7eb142732ca88e9ed30854088.camel@perches.com>

[-- Attachment #1: Type: text/plain, Size: 5545 bytes --]

Hello,
    Thank you for your review :-).
    Sorry, but I am a newbie on this, and now I am confused about my next
step. Should I make a v2 based on your changes, or do you want to submit
your changes?



On Tue, Oct 16, 2018 at 6:59 PM Joe Perches <joe@perches.com> wrote:

> On Tue, 2018-10-16 at 18:09 -0300, Giuliano Belinassi wrote:
> > A number of macro calls cause a checkpatch issue:
> >
> >     "Lines should not end with a '('"
> >
> > This was fixed by moving the first '(' token to the line of the first
> > argument.
>
> Please try to make the code more readable instead of
> following mindless checkpatch messages.
>
> For instance, this could be shorter, simpler, smaller
> object code size, and easier to humans to read as:
> ---
>  drivers/staging/iio/adc/ad7280a.c | 68
> +++++++++++++++++----------------------
>  1 file changed, 30 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/staging/iio/adc/ad7280a.c
> b/drivers/staging/iio/adc/ad7280a.c
> index 58420dcb406d..a69ae76b5616 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -701,46 +701,38 @@ static irqreturn_t ad7280_event_handler(int irq,
> void *private)
>                 goto out;
>
>         for (i = 0; i < st->scan_cnt; i++) {
> -               if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6)
> {
> -                       if (((channels[i] >> 11) & 0xFFF) >=
> -                               st->cell_threshhigh)
> -                               iio_push_event(indio_dev,
> -                                              IIO_EVENT_CODE(IIO_VOLTAGE,
> -                                                       1,
> -                                                       0,
> -                                                       IIO_EV_DIR_RISING,
> -                                                       IIO_EV_TYPE_THRESH,
> -                                                       0, 0, 0),
> -                                              iio_get_time_ns(indio_dev));
> -                       else if (((channels[i] >> 11) & 0xFFF) <=
> -                               st->cell_threshlow)
> -                               iio_push_event(indio_dev,
> -                                              IIO_EVENT_CODE(IIO_VOLTAGE,
> -                                                       1,
> -                                                       0,
> -                                                       IIO_EV_DIR_FALLING,
> -                                                       IIO_EV_TYPE_THRESH,
> -                                                       0, 0, 0),
> -                                              iio_get_time_ns(indio_dev));
> +               unsigned int voltage = (channels[i] >> 23) & 0xF;
> +               unsigned int val = (channels[i] >> 11) & 0xFFF;
> +               u64 code = 0;
> +
> +               if (voltage <= AD7280A_CELL_VOLTAGE_6) {
> +                       if (val >= st->cell_threshhigh) {
> +                               code = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
> +                                                     IIO_EV_DIR_RISING,
> +                                                     IIO_EV_TYPE_THRESH,
> +                                                     0, 0, 0);
> +                       } else if (val <= st->cell_threshlow) {
> +                               code = IIO_EVENT_CODE(IIO_VOLTAGE, 1, 0,
> +                                                     IIO_EV_DIR_FALLING,
> +                                                     IIO_EV_TYPE_THRESH,
> +                                                     0, 0, 0);
> +                       } else {
> +                               continue;
> +                       }
>                 } else {
> -                       if (((channels[i] >> 11) & 0xFFF) >=
> st->aux_threshhigh)
> -                               iio_push_event(indio_dev,
> -                                              IIO_UNMOD_EVENT_CODE(
> -                                                       IIO_TEMP,
> -                                                       0,
> -                                                       IIO_EV_TYPE_THRESH,
> -                                                       IIO_EV_DIR_RISING),
> -                                              iio_get_time_ns(indio_dev));
> -                       else if (((channels[i] >> 11) & 0xFFF) <=
> -                               st->aux_threshlow)
> -                               iio_push_event(indio_dev,
> -                                              IIO_UNMOD_EVENT_CODE(
> -                                                       IIO_TEMP,
> -                                                       0,
> -                                                       IIO_EV_TYPE_THRESH,
> -
>  IIO_EV_DIR_FALLING),
> -                                              iio_get_time_ns(indio_dev));
> +                       if (val >= st->aux_threshhigh) {
> +                               code = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
> +
>  IIO_EV_TYPE_THRESH,
> +
>  IIO_EV_DIR_RISING);
> +                       } else if (val <= st->aux_threshlow) {
> +                               code = IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
> +
>  IIO_EV_TYPE_THRESH,
> +
>  IIO_EV_DIR_FALLING);
> +                       } else {
> +                               continue;
> +                       }
>                 }
> +               iio_push_event(indio_dev, code,
> iio_get_time_ns(indio_dev));
>         }
>
>  out:
>
>
>

[-- Attachment #2: Type: text/html, Size: 7995 bytes --]

  reply	other threads:[~2018-10-16 22:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-16 21:09 [PATCH] staging: iio: ad7280a: Lines should not end with a '(' - style Giuliano Belinassi
2018-10-16 21:59 ` Joe Perches
2018-10-16 22:48   ` Giuliano Belinassi [this message]
2018-10-16 23:07     ` Joe Perches
2018-10-16 23:29       ` Giuliano Augusto Faulin Belinassi
2018-10-16 23:57         ` Joe Perches
2018-10-16 23:57           ` Joe Perches

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=CAG4RSAFMGSFyUqutRD2SRMsBt5RHVo5RUQsBq7fis6OVWxSZbg@mail.gmail.com \
    --to=giuliano.belinassi@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=joe@perches.com \
    --cc=kernel-usp@googlegroups.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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 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.