linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Mark Brown <broonie@kernel.org>
Cc: Jean Delvare <khali@linux-fr.org>,
	Guenter Roeck <linux@roeck-us.net>,
	Jonathan Cameron <jic23@kernel.org>,
	lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org,
	linux-iio@vger.kernel.org, linux-spi@vger.kernel.org,
	viresh.linux@gmail.com
Subject: Re: [PATCH 1/3] spi: Add a spi_w8r16be() helper
Date: Fri, 27 Sep 2013 22:01:36 +0200	[thread overview]
Message-ID: <5245E420.2030207@metafoo.de> (raw)
In-Reply-To: <20130927192233.GN19304@sirena.org.uk>

On 09/27/2013 09:22 PM, Mark Brown wrote:
> On Fri, Sep 27, 2013 at 08:46:56PM +0200, Lars-Peter Clausen wrote:
> 
>> According to the documentation of spi_w8r16() it is a feature.
> 
>> 	* The number is returned in wire-order, which is at least sometimes
>>  	* big-endian.
> 
> Indeed.  I don't think that's terribly well thought through though,
> especially not now we have annotations for endianness (as you noticed!).

I wouldn't mind updating spi_w8r16() to do the conversion to big-endian.
Especially considering that a driver using the function will probably always
need to do a endian conversion anyway to work correctly on both
endiannesses. We can add a LE variant if we should ever need it.

> 
>> There seem to be at least two users though which assume that the result is
>> in native endianness drivers/hwmon/ads7871.c and drivers/mfd/stmpe-spi.c
> 
> Yeah, I saw.  The ads7871 is just going to break when run on the
> opposite endianness to the one it was (hopefully) tested on since it
> doesn't make any effort I saw to cope with endianness.  Looking at the
> history it's not terribly obvious which that was but it'd be surprising
> to see a little endian register...
> 
> STMPE is doing a byte swap so it's another user for your function -
> it's for ARM systems so it'll be assuming that little endian is the
> native format.

The STMPE driver might be a candidate for regmap. Considering that the
driver was tested on a LE system it looks as if the driver first writes a 8
bit word for the address then reads a 16 bit word and ignores the upper bits
(of the BE word) and returns the lower 8 bits as the result. But the way I
understand the datasheet the 8-bit data word would follow right after the
8-bit address has been written, so I'm not sure what's going on there.
Viresh maybe you can shed some light on this. Btw. the register write
function of the STMPE driver also seems to be not endian safe.

- Lars

  reply	other threads:[~2013-09-27 20:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-27 14:34 [PATCH 1/3] spi: Add a spi_w8r16be() helper Lars-Peter Clausen
2013-09-27 14:34 ` [PATCH 2/3] hwmon: (adt7310) Use spi_w8r16be() instead spi_w8r16() Lars-Peter Clausen
2013-09-27 16:12   ` Guenter Roeck
2013-10-03 12:53   ` Mark Brown
2013-09-27 14:34 ` [PATCH 3/3] staging:iio:ade7753/ade7754/ade7759: Use spi_w8r16be() instead of spi_w8r16() Lars-Peter Clausen
2013-09-28 10:42   ` Jonathan Cameron
2013-09-27 18:34 ` [PATCH 1/3] spi: Add a spi_w8r16be() helper Mark Brown
2013-09-27 18:46   ` Lars-Peter Clausen
2013-09-27 19:22     ` Mark Brown
2013-09-27 20:01       ` Lars-Peter Clausen [this message]
2013-09-29 12:30         ` Mark Brown
2013-10-03 10:39           ` Lars-Peter Clausen
2013-10-03 10:59             ` Mark Brown
2013-09-27 20:42       ` Guenter Roeck
2013-10-03 12:52 ` Mark Brown

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=5245E420.2030207@metafoo.de \
    --to=lars@metafoo.de \
    --cc=broonie@kernel.org \
    --cc=jic23@kernel.org \
    --cc=khali@linux-fr.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lm-sensors@lm-sensors.org \
    --cc=viresh.linux@gmail.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).