From: Michael Hennerich <michael.hennerich@analog.com>
To: Jonathan Cameron <jic23@cam.ac.uk>
Cc: "linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"ldewangan@nvidia.com" <ldewangan@nvidia.com>,
"shubhrajyoti@ti.com" <shubhrajyoti@ti.com>,
"device-drivers-devel@blackfin.uclinux.org"
<device-drivers-devel@blackfin.uclinux.org>
Subject: Re: [Device-drivers-devel] [PATCH 04/24] staging:iio:gyro:adxrs450 make more use of spi_read and spi_write.
Date: Thu, 30 Jun 2011 16:10:51 +0200 [thread overview]
Message-ID: <4E0C83EB.6060308@analog.com> (raw)
In-Reply-To: <1309348316-7699-5-git-send-email-jic23@cam.ac.uk>
On 06/29/2011 01:51 PM, Jonathan Cameron wrote:
> This needs confirmation that the devices is happy if another part is
> talked to in between the request for a register and the read back.
I don't see a reason why this could break.
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
> Signed-off-by: Jonathan Cameron<jic23@cam.ac.uk>
> ---
> drivers/staging/iio/gyro/adxrs450_core.c | 63 ++++++++----------------------
> 1 files changed, 17 insertions(+), 46 deletions(-)
>
> diff --git a/drivers/staging/iio/gyro/adxrs450_core.c b/drivers/staging/iio/gyro/adxrs450_core.c
> index a756262..2d2916c 100644
> --- a/drivers/staging/iio/gyro/adxrs450_core.c
> +++ b/drivers/staging/iio/gyro/adxrs450_core.c
> @@ -35,21 +35,8 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev,
> u8 reg_address,
> u16 *val)
> {
> - struct spi_message msg;
> struct adxrs450_state *st = iio_priv(indio_dev);
> int ret;
> - struct spi_transfer xfers[] = {
> - {
> - .tx_buf = st->tx,
> - .bits_per_word = 8,
> - .len = 4,
> - .cs_change = 1,
> - }, {
> - .rx_buf = st->rx,
> - .bits_per_word = 8,
> - .len = 4,
> - },
> - };
>
> mutex_lock(&st->buf_lock);
> st->tx[0] = ADXRS450_READ_DATA | (reg_address>> 7);
> @@ -60,10 +47,13 @@ static int adxrs450_spi_read_reg_16(struct iio_dev *indio_dev,
> if (!(hweight32(be32_to_cpu(*(u32 *)st->tx))& 1))
> st->tx[3] |= ADXRS450_P;
>
> - spi_message_init(&msg);
> - spi_message_add_tail(&xfers[0],&msg);
> - spi_message_add_tail(&xfers[1],&msg);
> - ret = spi_sync(st->us,&msg);
> + ret = spi_write(st->us, st->tx, 4);
> + if (ret) {
> + dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n",
> + reg_address);
> + goto error_ret;
> + }
> + ret = spi_read(st->us, st->rx, 4);
> if (ret) {
> dev_err(&st->us->dev, "problem while reading 16 bit register 0x%02x\n",
> reg_address);
> @@ -88,15 +78,8 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev,
> u8 reg_address,
> u16 val)
> {
> - struct spi_message msg;
> struct adxrs450_state *st = iio_priv(indio_dev);
> int ret;
> - struct spi_transfer xfers = {
> - .tx_buf = st->tx,
> - .rx_buf = st->rx,
> - .bits_per_word = 8,
> - .len = 4,
> - };
>
> mutex_lock(&st->buf_lock);
> st->tx[0] = ADXRS450_WRITE_DATA | reg_address>> 7;
> @@ -105,14 +88,12 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev,
> st->tx[3] = val<< 1;
>
> if (!(hweight32(be32_to_cpu(*(u32 *)st->tx))& 1))
> - st->tx[3] |= ADXRS450_P;
> + st->tx[3] |= ADXRS450_P;
>
> - spi_message_init(&msg);
> - spi_message_add_tail(&xfers,&msg);
> - ret = spi_sync(st->us,&msg);
> + ret = spi_write(st->us, st->tx, 4);
> if (ret)
> dev_err(&st->us->dev, "problem while writing 16 bit register 0x%02x\n",
> - reg_address);
> + reg_address);
> msleep(1); /* enforce sequential transfer delay 0.1ms */
> mutex_unlock(&st->buf_lock);
> return ret;
> @@ -125,21 +106,8 @@ static int adxrs450_spi_write_reg_16(struct iio_dev *indio_dev,
> **/
> static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val)
> {
> - struct spi_message msg;
> struct adxrs450_state *st = iio_priv(indio_dev);
> int ret;
> - struct spi_transfer xfers[] = {
> - {
> - .tx_buf = st->tx,
> - .bits_per_word = 8,
> - .len = 4,
> - .cs_change = 1,
> - }, {
> - .rx_buf = st->rx,
> - .bits_per_word = 8,
> - .len = 4,
> - },
> - };
>
> mutex_lock(&st->buf_lock);
> st->tx[0] = ADXRS450_SENSOR_DATA;
> @@ -147,10 +115,13 @@ static int adxrs450_spi_sensor_data(struct iio_dev *indio_dev, s16 *val)
> st->tx[2] = 0;
> st->tx[3] = 0;
>
> - spi_message_init(&msg);
> - spi_message_add_tail(&xfers[0],&msg);
> - spi_message_add_tail(&xfers[1],&msg);
> - ret = spi_sync(st->us,&msg);
> + ret = spi_write(st->us, st->tx, 4);
> + if (ret) {
> + dev_err(&st->us->dev, "Problem while reading sensor data\n");
> + goto error_ret;
> + }
> +
> + ret = spi_read(st->us, st->rx, 4);
> if (ret) {
> dev_err(&st->us->dev, "Problem while reading sensor data\n");
> goto error_ret;
--
Greetings,
Michael
--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif
next prev parent reply other threads:[~2011-06-30 14:20 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-29 11:51 [PATCH 00/24] staging:iio: move chan_spec conversions and general cleanup Jonathan Cameron
2011-06-29 11:51 ` [PATCH 01/24] staging:iio:accel:kxsd9 cleanup and conversion to iio_chan_spec Jonathan Cameron
2011-06-29 11:51 ` [PATCH 02/24] staging:iio: add quadrature correction to chan info types Jonathan Cameron
2011-06-29 11:51 ` [PATCH 03/24] staging:iio:gyro:adxrs450 move to iio_chan_spec registration Jonathan Cameron
2011-06-29 11:51 ` [PATCH 04/24] staging:iio:gyro:adxrs450 make more use of spi_read and spi_write Jonathan Cameron
2011-06-30 14:10 ` Michael Hennerich [this message]
2011-06-29 11:51 ` [PATCH 05/24] staging:iio:gyro:adxrs450 squish some trivial single call point wrappers functions Jonathan Cameron
2011-06-29 11:51 ` [PATCH 06/24] staging:iio:gyro:adis16080 convert to iio_chan_spec Jonathan Cameron
2011-06-29 11:51 ` [PATCH 07/24] staging:iio:gyro:adis16260 remove some unused headers Jonathan Cameron
2011-06-29 11:51 ` [PATCH 08/24] staging:iio:imu:adis16400 remove " Jonathan Cameron
2011-06-29 11:51 ` [PATCH 09/24] staging:iio:magnetometer:ak8975 convert to iio_chan_spec + cleanups Jonathan Cameron
2011-06-29 11:51 ` [PATCH 10/24] staging:iio:magnetometer:hmc5843 iio_chan_spec conversion Jonathan Cameron
2011-06-29 11:51 ` [PATCH 11/24] staging:iio:magnetometer: remove unused header magnet.h Jonathan Cameron
2011-06-29 11:51 ` [PATCH 12/24] staging:iio:gyro:adis16130 fix adis16130_spi_read which was never selecting the channel Jonathan Cameron
2011-06-29 11:51 ` [PATCH 13/24] staging:iio:gyro:adis16130 drop control of adc resolution Jonathan Cameron
2011-06-29 11:51 ` [PATCH 14/24] staging:iio:gyro:adis16130 move to iio_chan_spec registration Jonathan Cameron
2011-06-29 11:51 ` [PATCH 15/24] staging:iio:gyro:adis16060 convert to iio_chan_spec Jonathan Cameron
2011-06-29 11:51 ` [PATCH 16/24] staging:iio:gyro: remove gyro.h Jonathan Cameron
2011-06-29 11:51 ` [PATCH 17/24] staging:iio:accel: usused header removals Jonathan Cameron
2011-06-29 11:51 ` [PATCH 18/24] staging:iio:inclinometer.h remove as now unused Jonathan Cameron
2011-06-29 11:51 ` [PATCH 19/24] staging:iio:adc: unused header removals Jonathan Cameron
2011-06-29 11:51 ` [PATCH 20/24] staging:iio:various header includes that should never have been Jonathan Cameron
2011-06-29 11:51 ` [PATCH 21/24] staging:iio:accel:adis16204: use peak_raw info_mask element + push some defs down from header Jonathan Cameron
2011-06-29 11:51 ` [PATCH 22/24] staging:iio:accel:adis16220 iio_chan_spec conversion Jonathan Cameron
2011-06-29 11:51 ` [PATCH 23/24] staging:iio:accel remove unused accel.h header Jonathan Cameron
2011-06-29 11:51 ` [PATCH 24/24] staging:iio:adc remove unused adc.h Jonathan Cameron
2011-06-30 14:53 ` [PATCH 00/24] staging:iio: move chan_spec conversions and general cleanup 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=4E0C83EB.6060308@analog.com \
--to=michael.hennerich@analog.com \
--cc=device-drivers-devel@blackfin.uclinux.org \
--cc=jic23@cam.ac.uk \
--cc=ldewangan@nvidia.com \
--cc=linux-iio@vger.kernel.org \
--cc=shubhrajyoti@ti.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