linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Matt Porter <mporter@konsulko.com>
Cc: Peter Meerwald <pmeerw@pmeerw.net>,
	Linux IIO List <linux-iio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/3] iio: temperature: add max6675 thermocouple converter driver
Date: Sun, 23 Aug 2015 16:44:31 +0100	[thread overview]
Message-ID: <55D9EA5F.4040206@kernel.org> (raw)
In-Reply-To: <20150820002307.GD6276@beef>

On 20/08/15 01:23, Matt Porter wrote:
> On Sat, Aug 08, 2015 at 12:39:40PM +0100, Jonathan Cameron wrote:
>> On 06/08/15 18:38, Matt Porter wrote:
>>> On Mon, Aug 03, 2015 at 11:26:12PM +0200, Peter Meerwald wrote:
>>>> On Mon, 3 Aug 2015, Matt Porter wrote:
>>>
>>> ...
>>>
>>>>> +static int max6675_read(struct max6675_state *st, int *val)
>>>>> +{
>>>>> +	int ret;
>>>>> +
>>>>> +	ret = spi_read(st->spi, val, 2);
>>>>> +	if (ret < 0)
>>>>> +		return ret;
>>>>> +
>>>>> +	/* Temperature is bits 14..3 */
>>>>> +	*val = (*val >> 3) & 0xfff;
>>>>
>>>> what about endianness conversion?
>>>> use be16_to_cpu()
>>>
>>> Apologies, I spoke before engaging the brain on my first reply to this
>>> As specified by the SPI subsystem docs, SPI buffers are always stored
>>> in native endian order. There is no need for endianness conversion here.
>> First of all, which doc say this?
>> Secondly how does SPI know the endianness of the sensor which is what
>> actually matters here?  I2C can in theory make these guarantees as there
>> is an expected byte order on the wire (even if quite a few drivers don't
>> conform to the spec anyway). No such guarantee can exist for SPI.
> 
> include/linux/spi/spi.h:
> 
>  * In-memory data values are always in native CPU byte order, translated
>  * from the wire byte order (big-endian except with SPI_LSB_FIRST).  So
>  * for example when bits_per_word is sixteen, buffers are 2N bytes long
>  * (@len = 2N) and hold N sixteen bit words in CPU byte order.
> 
> So, as you mention, there's no standardized byte order but it's
> controlled with the per transfer flag and big endian by default.
> 
Thanks, I'd never picked up on that before!

Jonathan
> 


  reply	other threads:[~2015-08-23 15:44 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-03 20:56 [PATCH 0/3] MAX6675 IIO temperature driver Matt Porter
2015-08-03 20:56 ` [PATCH 1/3] iio: temperature: add max6675 dt binding Matt Porter
2015-08-03 20:56 ` [PATCH 2/3] iio: temperature: add max6675 thermocouple converter driver Matt Porter
2015-08-03 21:26   ` Peter Meerwald
2015-08-03 23:13     ` Matt Porter
2015-08-06 17:38     ` Matt Porter
2015-08-08 11:39       ` Jonathan Cameron
2015-08-20  0:23         ` Matt Porter
2015-08-23 15:44           ` Jonathan Cameron [this message]
2015-08-03 22:39   ` Matt Ranostay
2015-08-03 23:10     ` Matt Porter
2015-08-04  7:50   ` Daniel Baluta
2015-08-04 13:01     ` Matt Porter
2015-08-04  9:30   ` Paul Bolle
2015-08-04 13:18     ` Matt Porter
2015-08-03 20:56 ` [PATCH 3/3] MAINTAINERS: add max6675 driver Matt Porter
2015-08-04 16:52 ` [PATCH 0/3] MAX6675 IIO temperature driver Jonathan Cameron
2015-08-04 17:34   ` Matt Porter
2015-08-05  8:33     ` Daniel Baluta
2015-08-05 11:43       ` Matt Porter
2015-08-08 11:36     ` 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=55D9EA5F.4040206@kernel.org \
    --to=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mporter@konsulko.com \
    --cc=pmeerw@pmeerw.net \
    /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).