From: Jonathan Cameron <jic23@kernel.org>
To: Lukas Wunner <lukas@wunner.de>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Mathias Duckeck <m.duckeck@kunbus.de>,
Phil Elwell <phil@raspberrypi.org>,
Oskar Andero <oskar.andero@gmail.com>,
Andrea Galbusera <gizero@gmail.com>,
Akinobu Mita <akinobu.mita@gmail.com>,
Manfred Schlaegl <manfred.schlaegl@gmx.at>,
Michael Welling <mwelling@ieee.org>,
Soeren Andersen <san@rosetechnology.dk>,
linux-iio@vger.kernel.org
Subject: Re: [PATCH 3/6] iio: adc: mcp320x: Speed up readout of single-channel ADCs
Date: Sun, 3 Sep 2017 14:48:51 +0100 [thread overview]
Message-ID: <20170903144851.154b295e@archlinux> (raw)
In-Reply-To: <19d008a9c19b9888b74a01adb4541a30acdcab62.1503407738.git.lukas@wunner.de>
On Tue, 22 Aug 2017 15:33:00 +0200
Lukas Wunner <lukas@wunner.de> wrote:
> Single-channel converters such as mcp3001, mcp3201, mcp3301 and the
> upcoming mcp3550/1/3 lack a MOSI pin, so there's no need to call
> mcp320x_channel_to_tx_data() for them.
>
> Moreover, instead of calling spi_read() for these converters, which
> generates an spi_message and spi_transfer on the stack on every readout,
> it's more efficient to use the spi_message and spi_transfer[] included
> in struct mcp320x (as we do for multi-channel ADCs), but initialize the
> spi_message only with the receive transfer.
>
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
Looks good, but I'll hold this for now as the fixes will not show up
in my upstream tree for a least 3-4 weeks.
Please give me a bump if it looks like I have forgotten it, or include
it in updated versions of the rest of the series as appropriate.
Thanks,
Jonathan
> ---
> drivers/iio/adc/mcp320x.c | 31 +++++++++++++------------------
> 1 file changed, 13 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/iio/adc/mcp320x.c b/drivers/iio/adc/mcp320x.c
> index 071dd23a33d9..790d3e857c80 100644
> --- a/drivers/iio/adc/mcp320x.c
> +++ b/drivers/iio/adc/mcp320x.c
> @@ -78,10 +78,6 @@ static int mcp320x_channel_to_tx_data(int device_index,
> int start_bit = 1;
>
> switch (device_index) {
> - case mcp3001:
> - case mcp3201:
> - case mcp3301:
> - return 0;
> case mcp3002:
> case mcp3202:
> return ((start_bit << 4) | (!differential << 3) |
> @@ -104,18 +100,13 @@ static int mcp320x_adc_conversion(struct mcp320x *adc, u8 channel,
>
> adc->rx_buf[0] = 0;
> adc->rx_buf[1] = 0;
> - adc->tx_buf = mcp320x_channel_to_tx_data(device_index,
> - channel, differential);
> + if (adc->chip_info->num_channels > 1)
> + adc->tx_buf = mcp320x_channel_to_tx_data(device_index, channel,
> + differential);
>
> - if (device_index != mcp3001 && device_index != mcp3201 && device_index != mcp3301) {
> - ret = spi_sync(adc->spi, &adc->msg);
> - if (ret < 0)
> - return ret;
> - } else {
> - ret = spi_read(adc->spi, &adc->rx_buf, sizeof(adc->rx_buf));
> - if (ret < 0)
> - return ret;
> - }
> + ret = spi_sync(adc->spi, &adc->msg);
> + if (ret < 0)
> + return ret;
>
> switch (device_index) {
> case mcp3001:
> @@ -330,9 +321,13 @@ static int mcp320x_probe(struct spi_device *spi)
> adc->transfer[0].len = sizeof(adc->tx_buf);
> adc->transfer[1].rx_buf = adc->rx_buf;
> adc->transfer[1].len = sizeof(adc->rx_buf);
> -
> - spi_message_init_with_transfers(&adc->msg, adc->transfer,
> - ARRAY_SIZE(adc->transfer));
> + if (chip_info->num_channels == 1)
> + /* single-channel converters are rx only (no MOSI pin) */
> + spi_message_init_with_transfers(&adc->msg,
> + &adc->transfer[1], 1);
> + else
> + spi_message_init_with_transfers(&adc->msg, adc->transfer,
> + ARRAY_SIZE(adc->transfer));
>
> adc->reg = devm_regulator_get(&spi->dev, "vref");
> if (IS_ERR(adc->reg))
prev parent reply other threads:[~2017-09-03 13:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-22 13:33 [PATCH 0/6] IIO driver for MCP3550/1/3 Lukas Wunner
2017-08-22 13:33 ` [PATCH 6/6] iio: adc: mcp320x: Add support for mcp3550/1/3 Lukas Wunner
2017-09-03 14:22 ` Jonathan Cameron
2017-09-07 6:44 ` Lukas Wunner
2017-09-10 13:40 ` Jonathan Cameron
2017-08-22 13:33 ` [PATCH 5/6] dt-bindings: iio: adc: mcp320x: Update " Lukas Wunner
2017-08-25 19:59 ` Rob Herring
2017-08-27 15:34 ` Lukas Wunner
2017-08-29 7:21 ` Adriana Reus
2017-09-03 13:37 ` Jonathan Cameron
2017-09-03 18:20 ` Lukas Wunner
2017-09-04 12:36 ` Jonathan Cameron
2017-09-04 17:22 ` Mark Brown
2017-09-10 13:36 ` Jonathan Cameron
2017-09-05 18:49 ` Rob Herring
2017-08-22 13:33 ` [PATCH 1/6] iio: adc: mcp320x: Fix oops on module unload Lukas Wunner
2017-09-03 13:41 ` Jonathan Cameron
2017-08-22 13:33 ` [PATCH 2/6] iio: adc: mcp320x: Fix readout of negative voltages Lukas Wunner
2017-09-03 13:44 ` Jonathan Cameron
2017-08-22 13:33 ` [PATCH 4/6] iio: adc: mcp320x: Drop unnecessary of_device_id attributes Lukas Wunner
2017-09-03 13:59 ` Jonathan Cameron
2017-08-22 13:33 ` [PATCH 3/6] iio: adc: mcp320x: Speed up readout of single-channel ADCs Lukas Wunner
2017-09-03 13:48 ` Jonathan Cameron [this message]
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=20170903144851.154b295e@archlinux \
--to=jic23@kernel.org \
--cc=akinobu.mita@gmail.com \
--cc=gizero@gmail.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=m.duckeck@kunbus.de \
--cc=manfred.schlaegl@gmx.at \
--cc=mwelling@ieee.org \
--cc=oskar.andero@gmail.com \
--cc=phil@raspberrypi.org \
--cc=pmeerw@pmeerw.net \
--cc=san@rosetechnology.dk \
/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).