All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Joshua Crofts <joshua.crofts1@gmail.com>
Cc: "Janani Sunil" <janani.sunil@analog.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Mark Brown" <broonie@kernel.org>,
	"Marius Cristea" <marius.cristea@microchip.com>,
	"Marcus Folkesson" <marcus.folkesson@gmail.com>,
	"Kent Gustavsson" <kent@minoris.se>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Daire McNamara" <daire.mcnamara@microchip.com>,
	"Paul Walmsley" <pjw@kernel.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	"Janani Sunil" <jan.sun97@gmail.com>,
	linux-spi@vger.kernel.org, "Kent Gustavsson" <nedo80@gmail.com>,
	linux-riscv@lists.infradead.org
Subject: Re: [PATCH v10 3/3] iio: dac: Add AD5529R DAC driver support
Date: Thu, 27 Aug 2026 12:18:57 +0300	[thread overview]
Message-ID: <apABAXL3OzSVc3AS@ashevche-desk.local> (raw)
In-Reply-To: <20260827103019.00002663@gmail.com>

On Thu, Aug 27, 2026 at 10:30:19AM +0200, Joshua Crofts wrote:
> On Thu, 27 Aug 2026 09:34:48 +0200
> Janani Sunil <janani.sunil@analog.com> wrote:

...

> > +#include <linux/array_size.h>
> > +#include <linux/bits.h>
> > +#include <linux/delay.h>
> > +#include <linux/dev_printk.h>
> > +#include <linux/err.h>
> > +#include <linux/errno.h>
> > +#include <linux/iio/iio.h>
> 
> IIO specific headers should go after the generic <linux/*> headers,
> it's just convention.
> 
> > +#include <linux/module.h>
> > +#include <linux/property.h>
> > +#include <linux/regmap.h>
> > +#include <linux/regulator/consumer.h>
> > +#include <linux/reset.h>
> > +#include <linux/spi/spi.h>
> > +#include <linux/types.h>
> > +#include <linux/units.h>

When it's a single header we don't strict this too much.

...

> > +static int ad5529r_write_raw(struct iio_dev *indio_dev,
> > +			     struct iio_chan_spec const *chan,
> > +			     int val, int val2, long mask)
> > +{
> > +	struct ad5529r_state *st = iio_priv(indio_dev);
> > +	unsigned int reg_addr;
> > +
> > +	switch (mask) {
> > +	case IIO_CHAN_INFO_RAW:
> > +		if (val < 0 || val > GENMASK(st->model_data->resolution - 1, 0))
> 
> There is a function for this - in_range(), in linux/minmax.h.

This is a trade-off and sometimes open-coded variants are okay.
I'm fine with either.

> > +			return -EINVAL;
> > +
> > +		reg_addr = AD5529R_REG_DAC_INPUT_A(chan->channel);
> > +
> > +		return regmap_write(st->regmap_16bit, reg_addr, val);
> > +	default:
> > +		return -EINVAL;
> > +	}
> > +}

-- 
With Best Regards,
Andy Shevchenko



WARNING: multiple messages have this Message-ID (diff)
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Joshua Crofts <joshua.crofts1@gmail.com>
Cc: "Janani Sunil" <janani.sunil@analog.com>,
	"Lars-Peter Clausen" <lars@metafoo.de>,
	"Michael Hennerich" <Michael.Hennerich@analog.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Philipp Zabel" <p.zabel@pengutronix.de>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Shuah Khan" <skhan@linuxfoundation.org>,
	"Mark Brown" <broonie@kernel.org>,
	"Marius Cristea" <marius.cristea@microchip.com>,
	"Marcus Folkesson" <marcus.folkesson@gmail.com>,
	"Kent Gustavsson" <kent@minoris.se>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	"Daire McNamara" <daire.mcnamara@microchip.com>,
	"Paul Walmsley" <pjw@kernel.org>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
	"Janani Sunil" <jan.sun97@gmail.com>,
	linux-spi@vger.kernel.org, "Kent Gustavsson" <nedo80@gmail.com>,
	linux-riscv@lists.infradead.org
Subject: Re: [PATCH v10 3/3] iio: dac: Add AD5529R DAC driver support
Date: Thu, 27 Aug 2026 12:18:57 +0300	[thread overview]
Message-ID: <apABAXL3OzSVc3AS@ashevche-desk.local> (raw)
In-Reply-To: <20260827103019.00002663@gmail.com>

On Thu, Aug 27, 2026 at 10:30:19AM +0200, Joshua Crofts wrote:
> On Thu, 27 Aug 2026 09:34:48 +0200
> Janani Sunil <janani.sunil@analog.com> wrote:

...

> > +#include <linux/array_size.h>
> > +#include <linux/bits.h>
> > +#include <linux/delay.h>
> > +#include <linux/dev_printk.h>
> > +#include <linux/err.h>
> > +#include <linux/errno.h>
> > +#include <linux/iio/iio.h>
> 
> IIO specific headers should go after the generic <linux/*> headers,
> it's just convention.
> 
> > +#include <linux/module.h>
> > +#include <linux/property.h>
> > +#include <linux/regmap.h>
> > +#include <linux/regulator/consumer.h>
> > +#include <linux/reset.h>
> > +#include <linux/spi/spi.h>
> > +#include <linux/types.h>
> > +#include <linux/units.h>

When it's a single header we don't strict this too much.

...

> > +static int ad5529r_write_raw(struct iio_dev *indio_dev,
> > +			     struct iio_chan_spec const *chan,
> > +			     int val, int val2, long mask)
> > +{
> > +	struct ad5529r_state *st = iio_priv(indio_dev);
> > +	unsigned int reg_addr;
> > +
> > +	switch (mask) {
> > +	case IIO_CHAN_INFO_RAW:
> > +		if (val < 0 || val > GENMASK(st->model_data->resolution - 1, 0))
> 
> There is a function for this - in_range(), in linux/minmax.h.

This is a trade-off and sometimes open-coded variants are okay.
I'm fine with either.

> > +			return -EINVAL;
> > +
> > +		reg_addr = AD5529R_REG_DAC_INPUT_A(chan->channel);
> > +
> > +		return regmap_write(st->regmap_16bit, reg_addr, val);
> > +	default:
> > +		return -EINVAL;
> > +	}
> > +}

-- 
With Best Regards,
Andy Shevchenko



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  reply	other threads:[~2026-08-27  9:19 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-27  7:34 [PATCH v10 0/3] iio: dac: Add support for AD5529R DAC Janani Sunil
2026-08-27  7:34 ` Janani Sunil
2026-08-27  7:34 ` [PATCH v10 1/3] spi: dt-bindings: Add spi-device-addr peripheral property Janani Sunil
2026-08-27  7:34   ` Janani Sunil
2026-08-27  7:34 ` [PATCH v10 2/3] dt-bindings: iio: dac: Add AD5529R Janani Sunil
2026-08-27  7:34   ` Janani Sunil
2026-08-27  7:44   ` sashiko-bot
2026-08-27  7:34 ` [PATCH v10 3/3] iio: dac: Add AD5529R DAC driver support Janani Sunil
2026-08-27  7:34   ` Janani Sunil
2026-08-27  7:50   ` sashiko-bot
2026-08-27  8:23   ` Andy Shevchenko
2026-08-27  8:23     ` Andy Shevchenko
2026-08-27 11:17     ` Janani Sunil
2026-08-27 11:17       ` Janani Sunil
2026-08-27 12:47       ` Andy Shevchenko
2026-08-27 12:47         ` Andy Shevchenko
2026-08-30 23:16     ` Jonathan Cameron
2026-08-30 23:16       ` Jonathan Cameron
2026-08-31  7:10       ` Andy Shevchenko
2026-08-31  7:10         ` Andy Shevchenko
2026-09-01  1:38         ` Jonathan Cameron
2026-09-01  1:38           ` Jonathan Cameron
2026-08-27  8:30   ` Joshua Crofts
2026-08-27  8:30     ` Joshua Crofts
2026-08-27  9:18     ` Andy Shevchenko [this message]
2026-08-27  9:18       ` Andy Shevchenko
2026-08-30 23:30   ` Jonathan Cameron
2026-08-30 23:30     ` Jonathan Cameron
2026-09-02  8:48     ` Janani Sunil
2026-09-02  8:48       ` Janani Sunil
2026-09-02 11:02       ` Andy Shevchenko
2026-09-02 11:02         ` Andy Shevchenko

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=apABAXL3OzSVc3AS@ashevche-desk.local \
    --to=andriy.shevchenko@intel.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=alex@ghiti.fr \
    --cc=andy@kernel.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=broonie@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=conor.dooley@microchip.com \
    --cc=corbet@lwn.net \
    --cc=daire.mcnamara@microchip.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jan.sun97@gmail.com \
    --cc=janani.sunil@analog.com \
    --cc=jic23@kernel.org \
    --cc=joshua.crofts1@gmail.com \
    --cc=kent@minoris.se \
    --cc=krzk+dt@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=marcus.folkesson@gmail.com \
    --cc=marius.cristea@microchip.com \
    --cc=nedo80@gmail.com \
    --cc=nuno.sa@analog.com \
    --cc=p.zabel@pengutronix.de \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=robh@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.