From: Lars-Peter Clausen <lars@metafoo.de>
To: Nicolas Frattaroli <frattaroli.nicolas@gmail.com>,
Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/4] iio: dac: mcp4922: add support for mcp48xx series chips
Date: Wed, 5 Apr 2023 07:18:46 -0700 [thread overview]
Message-ID: <9a203f56-c19a-48f2-f10c-ca0794ce79ed@metafoo.de> (raw)
In-Reply-To: <20230405140114.99011-5-frattaroli.nicolas@gmail.com>
Hi,
Looks very good. A few small comments inline.
[...]
> @@ -50,6 +58,35 @@ struct mcp4922_state {
> }, \
> }
>
> +static bool mcp4922_needs_vref(int device_id)
`enum mcp4922_supported_device_ids` instead of `int`. Same for num_channels() below.
> +{
> + switch (device_id) {
> + case ID_MCP4902:
> + case ID_MCP4912:
> + case ID_MCP4921:
> + case ID_MCP4922:
> + return true;
> + default:
> + return false;
> + }
> +}
> [...]
> static int mcp4922_spi_write(struct mcp4922_state *state, u8 addr, u32 val)
> {
> state->mosi[1] = val & 0xff;
> @@ -108,11 +145,17 @@ static int mcp4922_write_raw(struct iio_dev *indio_dev,
> }
> }
>
> -static const struct iio_chan_spec mcp4922_channels[4][MCP4922_NUM_CHANNELS] = {
> +static const struct iio_chan_spec mcp4922_channels[10][MCP4922_NUM_CHANNELS] = {
mcp4922_channels[][MCP4922_NUM_CHANNELS]
So it does not have to be changed again when adding additional devices
in the future.
> [...]
> @@ -197,11 +244,14 @@ static void mcp4922_remove(struct spi_device *spi)
> {
> struct iio_dev *indio_dev = spi_get_drvdata(spi);
> struct mcp4922_state *state;
> + const struct spi_device_id *id = spi_get_device_id(spi);
>
> iio_device_unregister(indio_dev);
> state = iio_priv(indio_dev);
> regulator_disable(state->vdd_reg);
> - regulator_disable(state->vref_reg);
> + if (mcp4922_needs_vref(id->driver_data)) {
Could be `if (state->vref_reg)`, this way you don't need to lookup the
spi_device_id. But either way is fine.
> + regulator_disable(state->vref_reg);
> + }
> }
>
> [...]
next prev parent reply other threads:[~2023-04-05 14:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 14:01 [PATCH 0/4] Add MCP48XX bindings and driver support Nicolas Frattaroli
2023-04-05 14:01 ` [PATCH 1/4] dt-bindings: iio: dac: mcp4922: add vdd-supply property Nicolas Frattaroli
2023-04-09 20:52 ` Michael Welling
2023-04-05 14:01 ` [PATCH 2/4] iio: dac: mcp4922: get and enable vdd regulator Nicolas Frattaroli
2023-04-05 14:21 ` Lars-Peter Clausen
2023-04-07 17:46 ` Jonathan Cameron
2023-04-07 17:44 ` Jonathan Cameron
2023-04-05 14:01 ` [PATCH 3/4] dt-bindings: iio: dac: add mcp4822 Nicolas Frattaroli
2023-04-05 14:10 ` Krzysztof Kozlowski
2023-04-05 14:17 ` Nicolas Frattaroli
2023-04-06 18:58 ` Krzysztof Kozlowski
2023-04-05 14:01 ` [PATCH 4/4] iio: dac: mcp4922: add support for mcp48xx series chips Nicolas Frattaroli
2023-04-05 14:18 ` Lars-Peter Clausen [this message]
2023-04-07 17:35 ` Jonathan Cameron
2023-04-07 17:40 ` 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=9a203f56-c19a-48f2-f10c-ca0794ce79ed@metafoo.de \
--to=lars@metafoo.de \
--cc=frattaroli.nicolas@gmail.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--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 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.