From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Jacopo Mondi <jacopo@jmondi.org>
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
Magnus Damm <magnus.damm@gmail.com>,
Jonathan Cameron <jic23@kernel.org>,
Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald <pmeerw@pmeerw.net>,
linux-iio@vger.kernel.org,
Linux-Renesas <linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCHv2] iio: adc: Add Maxim MAX11100 driver
Date: Tue, 13 Dec 2016 14:21:00 +0100 [thread overview]
Message-ID: <CAMuHMdUCuBs9Fm+YvsqEc1J_a_2sgg104DDBf39oUD2JQRxXtg@mail.gmail.com> (raw)
In-Reply-To: <1481632629-18826-1-git-send-email-jacopo@jmondi.org>
Hi Jacopo,
On Tue, Dec 13, 2016 at 1:37 PM, Jacopo Mondi <jacopo@jmondi.org> wrote:
> Add IIO driver for Maxim MAX11100 single-channel ADC.
> Add DT bindings documentation.
>
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
> --- a/drivers/iio/adc/Makefile
> +++ b/drivers/iio/adc/Makefile
> @@ -29,6 +29,7 @@ obj-$(CONFIG_LP8788_ADC) += lp8788_adc.o
> obj-$(CONFIG_LPC18XX_ADC) += lpc18xx_adc.o
> obj-$(CONFIG_LTC2485) += ltc2485.o
> obj-$(CONFIG_MAX1027) += max1027.o
> +obj-$(CONFIG_MAX11100) += max11100.o
> obj-$(CONFIG_MAX1363) += max1363.o
> obj-$(CONFIG_MCP320X) += mcp320x.o
> obj-$(CONFIG_MCP3422) += mcp3422.o
> diff --git a/drivers/iio/adc/max11100.c b/drivers/iio/adc/max11100.c
> new file mode 100644
> index 0000000..f372ad8
> --- /dev/null
> +++ b/drivers/iio/adc/max11100.c
> +/*
> + * LSB is the ADC single digital step
> + * 1 LSB = (vref / 2 ^ 16)
> + * AIN = (DIN * LSB)
> + */
> +#define MAX11100_LSB_DIV (1 << 16)
> +#define MAX11100_LSB(vref) (vref / MAX11100_LSB_DIV)
DIV_ROUND_CLOSEST()?
> +struct max11100_state {
> + const struct max11100_chip_desc *desc;
> + struct spi_device *spi;
> + int vref_uv;
unsi
It's good practice to move the smaller members to the end of the structure,
to avoid gaps due to alignment rules (struct mutex needs to be 64-bit aligned
on 64-bit platforms).
> + struct mutex lock;
> +};
> +static struct max11100_chip_desc {
> + unsigned int num_chan;
> + const struct iio_chan_spec *channels;
Same here (but it won't have any effect for now).
> +} max11100_desc = {
> + .num_chan = ARRAY_SIZE(max11100_channels),
> + .channels = max11100_channels,
> +};
> +static int max11100_read_raw(struct iio_dev *indio_dev,
> + struct iio_chan_spec const *chan,
> + int *val, int *val2, long mask)
> +{
> + int ret;
> + struct max11100_state *state = iio_priv(indio_dev);
> + uint8_t buffer[3];
> + *val = be16_to_cpu(*(uint16_t *)&buffer[1]);
Reading the uint16_t will be an unaligned load, which is not supported on all
platforms. So you either have to use get_unaligned_le16(), or assemble the
value yourself, like you did in v1.
> + *val = *val * MAX11100_LSB(state->vref_uv) / 1000;
DIV_ROUND_CLOSEST()?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
next prev parent reply other threads:[~2016-12-13 13:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-06 16:30 [PATCH] iio: Add Maxim MAX11100 driver Jacopo Mondi
2016-12-06 21:00 ` Peter Meerwald-Stadler
2016-12-07 8:15 ` Geert Uytterhoeven
2016-12-07 8:29 ` jacopo
2016-12-07 12:22 ` Geert Uytterhoeven
2016-12-10 17:54 ` Jonathan Cameron
2016-12-10 18:04 ` Jonathan Cameron
2016-12-12 18:11 ` jacopo
2016-12-13 12:37 ` [PATCHv2] iio: adc: " Jacopo Mondi
2016-12-13 13:21 ` Geert Uytterhoeven [this message]
2016-12-13 15:53 ` Wolfram Sang
2016-12-30 16:09 ` Jonathan Cameron
2016-12-14 11:54 ` jacopo
2016-12-14 12:14 ` Geert Uytterhoeven
2016-12-13 20:33 ` Peter Meerwald-Stadler
2016-12-14 12:00 ` jacopo
2016-12-30 16:31 ` Jonathan Cameron
2017-01-02 9:19 ` jacopo mondi
2017-01-02 18:02 ` Jonathan Cameron
2016-12-30 16:08 ` Jonathan Cameron
2017-01-02 8:41 ` jacopo mondi
2016-12-30 16:35 ` Jonathan Cameron
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=CAMuHMdUCuBs9Fm+YvsqEc1J_a_2sgg104DDBf39oUD2JQRxXtg@mail.gmail.com \
--to=geert@linux-m68k.org \
--cc=jacopo@jmondi.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=pmeerw@pmeerw.net \
--cc=wsa+renesas@sang-engineering.com \
/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).