All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: linux-iio <linux-iio@vger.kernel.org>,
	Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	kernel@pengutronix.de,
	Oliver Lang <Oliver.Lang@gossenmetrawatt.com>
Subject: Re: [PATCH 3/4] iio: ltr501: ltr501_read_ps(): add missing endianness conversion
Date: Thu, 10 Jun 2021 15:31:35 +0200	[thread overview]
Message-ID: <20210610133135.tsu4lnyhab7ysmcn@pengutronix.de> (raw)
In-Reply-To: <CAHp75Ve=bp=iHKeHmSb8MzfMt=tP+gsgG0GTwxhQV_ej_+BqPA@mail.gmail.com>

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

On 10.06.2021 16:21:30, Andy Shevchenko wrote:
> On Thu, Jun 10, 2021 at 3:55 PM Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> >
> > From: Oliver Lang <Oliver.Lang@gossenmetrawatt.com>
> >
> > The PS ADC Channel data is spread over 2 registers in little-endian
> > form. This patch adds the missing endianness conversion.
> >
> > Fixes: 2690be905123 ("iio: Add Lite-On ltr501 ambient light / proximity sensor driver")
> > Signed-off-by: Oliver Lang <Oliver.Lang@gossenmetrawatt.com>
> > Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
> > ---
> >  drivers/iio/light/ltr501.c | 16 ++++++----------
> >  1 file changed, 6 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
> > index 79898b72fe73..0e3f97ef3cdd 100644
> > --- a/drivers/iio/light/ltr501.c
> > +++ b/drivers/iio/light/ltr501.c
> > @@ -407,20 +407,16 @@ static int ltr501_read_als(const struct ltr501_data *data, __le16 buf[2])
> >                                 buf, 2 * sizeof(__le16));
> >  }
> >
> > -static int ltr501_read_ps(const struct ltr501_data *data)
> > +static int ltr501_read_ps(const struct ltr501_data *data, __le16 *buf)
> >  {
> > -       int ret, status;
> > +       int ret;
> >
> >         ret = ltr501_drdy(data, LTR501_STATUS_PS_RDY);
> >         if (ret < 0)
> >                 return ret;
> >
> > -       ret = regmap_bulk_read(data->regmap, LTR501_PS_DATA,
> > -                              &status, 2);
> > -       if (ret < 0)
> > -               return ret;
> > -
> > -       return status;
> > +       return regmap_bulk_read(data->regmap, LTR501_PS_DATA,
> > +                               buf, sizeof(__le16));
> 
> This is slightly weird since we pass a pointer to a buffer of one
> element (buffer can be longer, but here it's always one element is in
> use). The original code is better (initially). Also making caller to
> do endiannes conversion each time is not good.

We decided to implement the same semantics as ltr501_read_als(), where
the caller does the endianness conversion. I'll change the code and send
a v2 (with a proper cover letter subject :))

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2021-06-10 13:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10 12:53 [PATCH 1/4] iio: ltr501: fix regmap, initialization of ltr559, endianness and mark structs as const Marc Kleine-Budde
2021-06-10 12:53 ` [PATCH 1/4] iio: ltr501: mark register holding upper 8 bits of ALS_DATA{0,1} and PS_DATA as volatile, too Marc Kleine-Budde
2021-06-10 12:53 ` [PATCH 2/4] iio: ltr501: ltr559: fix initialization of LTR501_ALS_CONTR Marc Kleine-Budde
2021-06-10 12:53 ` [PATCH 3/4] iio: ltr501: ltr501_read_ps(): add missing endianness conversion Marc Kleine-Budde
2021-06-10 13:21   ` Andy Shevchenko
2021-06-10 13:31     ` Marc Kleine-Budde [this message]
2021-06-10 13:34       ` Andy Shevchenko
2021-06-10 12:53 ` [PATCH 4/4] iio: ltr501: mark ltr501_chip_info as const Marc Kleine-Budde
2021-06-10 13:09 ` [PATCH 1/4] iio: ltr501: fix regmap, initialization of ltr559, endianness and mark structs " Andy Shevchenko
2021-06-10 13:22 ` Andy Shevchenko

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=20210610133135.tsu4lnyhab7ysmcn@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=Oliver.Lang@gossenmetrawatt.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=jic23@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --subject='Re: [PATCH 3/4] iio: ltr501: ltr501_read_ps(): add missing endianness conversion' \
    /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

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.