Linux-Devicetree Archive on lore.kernel.org
 help / color / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Christian Eggers <ceggers@arri.de>
Cc: Rob Herring <robh+dt@kernel.org>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Jonathan Cameron <jic23@kernel.org>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-iio <linux-iio@vger.kernel.org>,
	devicetree <devicetree@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 2/2] iio: light: as73211: New driver
Date: Sun, 2 Aug 2020 21:02:35 +0300
Message-ID: <CAHp75Vev64E86OWm+eV=1o4ZDs0Xh_Y1z6V54GmpRwWmjD7=eA@mail.gmail.com> (raw)
In-Reply-To: <20200802163735.76617-3-ceggers@arri.de>

On Sun, Aug 2, 2020 at 7:40 PM Christian Eggers <ceggers@arri.de> wrote:
>
> Support for AMS AS73211 JENCOLOR(R) Digital XYZ Sensor.
>
> This driver has no built-in trigger. In order for making triggered
> measurements, an external (software) trigger driver like
> iio-trig-hrtimer or iio-trig-sysfs is required.
>
> The sensor supports single and continuous measurement modes. The latter
> is not used by design as this would require tight timing synchronization
> between hardware and driver without much benefit.

Thanks for an update, my comments below.

> Datasheet: https://ams.com/documents/20143/36005/AS73211_DS000556_3-01.pdf/a65474c0-b302-c2fd-e30a-c98df87616df

Do we need the UUID after the document file name?

...

> +/* Available sample frequencies are 1.024MHz multiplied by powers of two. */
> +static const int as73211_samp_freq_avail[] = {
> +       AS73211_SAMPLE_FREQ_BASE * 1,
> +       AS73211_SAMPLE_FREQ_BASE * 2,
> +       AS73211_SAMPLE_FREQ_BASE * 4,
> +       AS73211_SAMPLE_FREQ_BASE * 8

+ Comma.

> +};

...

> +#define AS73211_OFFSET_TEMP (-66.9)
> +#define AS73211_SCALE_TEMP  0.05

In the kernel we don't do float arithmetic. How these are being used?

...

> +               *val2 = (AS73211_OFFSET_TEMP - (int)AS73211_OFFSET_TEMP) * 1000000;

> +                       *val2 = (AS73211_SCALE_TEMP - (int)AS73211_SCALE_TEMP) * 1000000;

Magic 1000000 multiplier.

I think here you got them always 0. And to fix that you need to
redefine (with also units included in the name) above constants like
#define ..._OFFSET_TEMP_mC 66500
... _SCALE_TEMP_?? 50

Consider to use definitions from
https://elixir.bootlin.com/linux/latest/source/include/linux/units.h

...

> +       }}
> +
> +       return -EINVAL;

Make it default case.

> +       }
> +
> +       return -EINVAL;

Ditto.

...

> +       }}
> +
> +       return -EINVAL;

Ditto.

...

> +       ret = devm_iio_device_register(dev, indio_dev);
> +       if (ret < 0)
> +               return ret;
> +
> +       return 0;

  return devm_iio_device_register();

And consider to drop ' < 0' for devm_*() calls. As far as I understood
your intention to explicitly leave them because of i2c_*() calls,
though devm_*() and such are different.

-- 
With Best Regards,
Andy Shevchenko

  reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-02 16:37 [PATCH v5 0/2] iio: light: Support AMS AS73211 digital XYZ sensor Christian Eggers
2020-08-02 16:37 ` [PATCH v5 1/2] dt-bindings: iio: light: add AMS AS73211 support Christian Eggers
2020-08-02 16:37 ` [PATCH v5 2/2] iio: light: as73211: New driver Christian Eggers
2020-08-02 18:02   ` Andy Shevchenko [this message]
2020-08-04  7:40     ` Christian Eggers
2020-08-04  8:28       ` Andy Shevchenko
2020-08-04  8:34       ` 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='CAHp75Vev64E86OWm+eV=1o4ZDs0Xh_Y1z6V54GmpRwWmjD7=eA@mail.gmail.com' \
    --to=andy.shevchenko@gmail.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=ceggers@arri.de \
    --cc=devicetree@vger.kernel.org \
    --cc=jic23@kernel.org \
    --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 \
    --cc=robh+dt@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

Linux-Devicetree Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-devicetree/0 linux-devicetree/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-devicetree linux-devicetree/ https://lore.kernel.org/linux-devicetree \
		devicetree@vger.kernel.org
	public-inbox-index linux-devicetree

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-devicetree


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git