public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Akhilesh Patil <akhilesh@ee.iitb.ac.in>
Cc: Andy Shevchenko <andy.shevchenko@gmail.com>,
	jic23@kernel.org, dlechner@baylibre.com, robh@kernel.org,
	krzk+dt@kernel.org, conor+dt@kernel.org, nuno.sa@analog.com,
	andy@kernel.org, marcelo.schmitt1@gmail.com,
	vassilisamir@gmail.com, salah.triki@gmail.com,
	skhan@linuxfoundation.org, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	akhileshpatilvnit@gmail.com
Subject: Re: [PATCH 2/2] iio: pressure: adp810: Add driver for adp810 sensor
Date: Thu, 23 Oct 2025 21:58:45 +0300	[thread overview]
Message-ID: <aPp65bmTGk1qfPSE@smile.fi.intel.com> (raw)
In-Reply-To: <20251013-144614-1551316@bhairav-test.ee.iitb.ac.in>

On Mon, Oct 13, 2025 at 08:16:14PM +0530, Akhilesh Patil wrote:
> On Sat, Oct 11, 2025 at 05:10:58PM +0300, Andy Shevchenko wrote:
> > On Sat, Oct 11, 2025 at 3:25 PM Akhilesh Patil <akhilesh@ee.iitb.ac.in> wrote:

...

> > > +struct adp810_read_buf {
> > > +       u8 dp_msb;
> > > +       u8 dp_lsb;
> > > +       u8 dp_crc;
> > > +       u8 tmp_msb;
> > > +       u8 tmp_lsb;
> > > +       u8 tmp_crc;
> > > +       u8 sf_msb;
> > > +       u8 sf_lsb;
> > > +       u8 sf_crc;
> > > +} __packed;
> > 
> > Why __packed?
> 
> Yes. This is the structure used as a buffer to store sensor values read.
> Each entry in this structure should be contiguous in the memory because
> reference of this structure will be passed to i2c_master_recv() to
> receive and fill the data.
> __packed will avoid any compiler generated paddings in the structure to
> force alignments on certain architectures. We do not want these paddings
> and want our struct members to be sequentially ordered as shown, with
> no padding and size of the struct should also be 9 bytes as only 9 bytes of
> data should be read from the sensor as per the specification.
> 
> I could have used array here. But I preferred strcture for better
> readability of the code as one can easily see what values are expected
> from sensor while reading and in which order.

Right, but in this form packed only affects the last member size (due to
alignment), in any case since it's HW mandated requirement, perhaps add a
comment. (Since we also going to use __be16 types, the __packed is required
for that to be properly placed in the memory.)


...

> > > +struct adp810_data {
> > > +       struct i2c_client *client;
> > > +       /* Use lock to synchronize access to device during read sequence */
> > > +       struct mutex lock;
> > > +};
> > 
> > Is there a deliberate choice to not use regmap I²C APIs?
> 
> Yes. I explored that possibility. However this sensor follows simple I2C
> client protocol. It does not expose the concept of I2C registers. It
> does not follow smbus. Specifically, while reading the measurement from
> the sensor, we need to only send the device address with read bit on the bus,
> and start reading 9 bytes following that. That is, no register address
> should be sent. I am not sure if regmap API has some hack to achive
> similar because these APIs expect register addresses to read/write which
> this sensor does not follow. Hence using raw i2c functions. I also
> thought regmap abstraction is not needed here as this sensor has very
> limited commands to send and not many command/configurations.

Ah, makes sense.

-- 
With Best Regards,
Andy Shevchenko



  reply	other threads:[~2025-10-23 18:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-11 12:24 [PATCH 0/2] iio: pressure: add driver and bindings for adp810 Akhilesh Patil
2025-10-11 12:25 ` [PATCH 1/2] dt-bindings: iio: pressure: Add Aosong adp810 Akhilesh Patil
2025-10-12  3:13   ` Krzysztof Kozlowski
2025-10-13 15:25     ` Akhilesh Patil
2025-10-11 12:25 ` [PATCH 2/2] iio: pressure: adp810: Add driver for adp810 sensor Akhilesh Patil
2025-10-11 14:10   ` Andy Shevchenko
2025-10-12  3:12     ` Krzysztof Kozlowski
2025-10-23 18:51       ` Andy Shevchenko
2025-10-24  6:18         ` Krzysztof Kozlowski
2025-10-24  8:34           ` Andy Shevchenko
2025-10-24  8:37             ` Andy Shevchenko
2025-10-24 17:50               ` Akhilesh Patil
2025-10-27  8:24                 ` Andy Shevchenko
2025-10-27  8:45                   ` Akhilesh Patil
2025-10-13 14:46     ` Akhilesh Patil
2025-10-23 18:58       ` Andy Shevchenko [this message]
2025-10-25  5:55         ` Akhilesh Patil
2025-10-12 19:36   ` Jonathan Cameron
2025-10-13 16:06     ` Akhilesh Patil

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=aPp65bmTGk1qfPSE@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=akhilesh@ee.iitb.ac.in \
    --cc=akhileshpatilvnit@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo.schmitt1@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    --cc=salah.triki@gmail.com \
    --cc=skhan@linuxfoundation.org \
    --cc=vassilisamir@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