Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1210097

Re: [PATCH 2/3] iio: temperature: add max6675 thermocouple converter driver

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Matt Porter <mporter@konsulko.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/3] iio: temperature: add max6675 thermocouple converter driver
Date Thu, 20 Aug 2015 02:30:02 +0200
Message-ID <pZlTY-5bn-7@gated-at.bofh.it> (permalink)
References <pTuZX-5Um-5@gated-at.bofh.it> <pTuZY-5Um-19@gated-at.bofh.it> <pTvt1-6Ny-37@gated-at.bofh.it> <pUxj8-7uZ-59@gated-at.bofh.it> <pVaDM-5Uh-27@gated-at.bofh.it>
X-Original-To Jonathan Cameron <jic23@kernel.org>
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=KZ1QNC1tDFEsDpJL/xqttf4MfkNrcRnHed3Gk9PC5g0=; b=V9mWYHIm+eTREKQS6jgSV+DXvbZfjShBLC9F3GCYW9m3o+CTO9xFxY2ASTlJqUHA8N oaVET6CQSjgDfnsLIXU8VcmmTzEHFcQMeXbyJTwgZkzSN/Xps4QePnjMsWEjZ6BH6at7 lFO279/MStBJF9QUzJFs2IY3M9RAKdJxluTowy4OqbUolB1bOtPs6teQXEB5F9HEK2um ykcnEEiecknRgkxU0K7weiMF0Ye6/da9cEAO2hVDjJN8DZbcyTH2wHuGoJB/hBxTsrBA yi58HqsefBYkN2hiJ0YvrIiw745YwYXSHjJfcxLyUK5QLt7HyOYmtdJq6O/3pQLr05rL wD6Q==
X-Gm-Message-State ALoCoQkr8FPlfkka66ITbHuYxcj/S7ryLPl9WTk6TBxkgJgu0OK/wTI9/0f7S4NEYDuvUWq0bkzD
X-Received by 10.50.64.179 with SMTP id p19mr32586418igs.55.1440030191433; Wed, 19 Aug 2015 17:23:11 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.5.23 (2014-03-12)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 46
Organization linux.* mail to news gateway
X-Original-Cc Peter Meerwald <pmeerw@pmeerw.net>, Linux IIO List <linux-iio@vger.kernel.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
X-Original-Date Wed, 19 Aug 2015 20:23:07 -0400
X-Original-Message-ID <20150820002307.GD6276@beef>
X-Original-References <1438635410-3757-1-git-send-email-mporter@konsulko.com> <1438635410-3757-3-git-send-email-mporter@konsulko.com> <alpine.DEB.2.02.1508032313380.17732@pmeerw.net> <20150806173844.GI23173@beef> <55C5EA7C.70906@kernel.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1210097

Show key headers only | View raw


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.

-Matt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 2/3] iio: temperature: add max6675 thermocouple converter  driver Matt Porter <mporter@konsulko.com> - 2015-08-06 19:40 +0200
  Re: [PATCH 2/3] iio: temperature: add max6675 thermocouple converter  driver Jonathan Cameron <jic23@kernel.org> - 2015-08-08 13:40 +0200
    Re: [PATCH 2/3] iio: temperature: add max6675 thermocouple converter  driver Matt Porter <mporter@konsulko.com> - 2015-08-20 02:30 +0200
      Re: [PATCH 2/3] iio: temperature: add max6675 thermocouple converter  driver Jonathan Cameron <jic23@kernel.org> - 2015-08-23 17:50 +0200

csiph-web