linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-iio@vger.kernel.org, Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Subject: Re: [PATCH v1 2/8] iio: accel: bma220: Convert to use ->read_avail()
Date: Thu, 3 Sep 2020 19:35:51 +0100	[thread overview]
Message-ID: <20200903193551.3b89702e@archlinux> (raw)
In-Reply-To: <20200831090813.78841-2-andriy.shevchenko@linux.intel.com>

On Mon, 31 Aug 2020 12:08:07 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Convert to use ->read_avail() instead of open-coded attribute handling.
> 
> While here, fix the typo in array definition and append comma in case of
> the future extension.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

I missed a build warning inline. Now fixed.

> ---
>  drivers/iio/accel/bma220_spi.c | 36 ++++++++++++++++++++--------------
>  1 file changed, 21 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
> index 3247b9c8abcb..cb634a3a995d 100644
> --- a/drivers/iio/accel/bma220_spi.c
> +++ b/drivers/iio/accel/bma220_spi.c
> @@ -30,7 +30,6 @@
>  #define BMA220_SUSPEND_WAKE			0x00
>  
>  #define BMA220_DEVICE_NAME			"bma220"
> -#define BMA220_SCALE_AVAILABLE			"0.623 1.248 2.491 4.983"
>  
>  #define BMA220_ACCEL_CHANNEL(index, reg, axis) {			\
>  	.type = IIO_ACCEL,						\
> @@ -55,19 +54,8 @@ enum bma220_axis {
>  	AXIS_Z,
>  };
>  
> -static IIO_CONST_ATTR(in_accel_scale_available, BMA220_SCALE_AVAILABLE);
> -
> -static struct attribute *bma220_attributes[] = {
> -	&iio_const_attr_in_accel_scale_available.dev_attr.attr,
> -	NULL,
> -};
> -
> -static const struct attribute_group bma220_attribute_group = {
> -	.attrs = bma220_attributes,
> -};
> -
> -static const int bma220_scale_table[][4] = {
> -	{0, 623000}, {1, 248000}, {2, 491000}, {4, 983000}
> +static const int bma220_scale_table[][2] = {
> +	{0, 623000}, {1, 248000}, {2, 491000}, {4, 983000},
>  };
>  
>  struct bma220_data {
> @@ -182,10 +170,28 @@ static int bma220_write_raw(struct iio_dev *indio_dev,
>  	return -EINVAL;
>  }
>  
> +static int bma220_read_avail(struct iio_dev *indio_dev,
> +			     struct iio_chan_spec const *chan,
> +			     const int **vals, int *type, int *length,
> +			     long mask)
> +{
> +	struct bma220_data *data = iio_priv(indio_dev);
Not used.

> +
> +	switch (mask) {
> +	case IIO_CHAN_INFO_SCALE:
> +		*vals = (int *)bma220_scale_table;
> +		*type = IIO_VAL_INT_PLUS_MICRO;
> +		*length = ARRAY_SIZE(bma220_scale_table) * 2;
> +		return IIO_AVAIL_LIST;
> +	default:
> +		return -EINVAL;
> +	}
> +}
> +
>  static const struct iio_info bma220_info = {
>  	.read_raw		= bma220_read_raw,
>  	.write_raw		= bma220_write_raw,
> -	.attrs			= &bma220_attribute_group,
> +	.read_avail		= bma220_read_avail,
>  };
>  
>  static int bma220_init(struct spi_device *spi)


  reply	other threads:[~2020-09-03 18:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-31  9:08 [PATCH v1 1/8] iio: accel: bma220: Fix returned codes from bma220_init(), bma220_deinit() Andy Shevchenko
2020-08-31  9:08 ` [PATCH v1 2/8] iio: accel: bma220: Convert to use ->read_avail() Andy Shevchenko
2020-09-03 18:35   ` Jonathan Cameron [this message]
2020-09-03 19:33     ` Andy Shevchenko
2020-08-31  9:08 ` [PATCH v1 3/8] iio: accel: bma220: Use dev_get_drvdata() directly Andy Shevchenko
2020-08-31  9:08 ` [PATCH v1 4/8] iio: accel: bma220: Mark PM functions as __maybe_unused Andy Shevchenko
2020-08-31  9:08 ` [PATCH v1 5/8] iio: accel: bma220: Drop ACPI_PTR() and accompanying ifdeffery Andy Shevchenko
2020-08-31  9:19   ` Jonathan Cameron
2020-08-31  9:39     ` Andy Shevchenko
2020-08-31  9:55       ` Jonathan Cameron
2020-08-31 10:17         ` Andy Shevchenko
2020-08-31  9:08 ` [PATCH v1 6/8] iio: accel: bma220: Group IIO headers together Andy Shevchenko
2020-08-31  9:08 ` [PATCH v1 7/8] iio: accel: bma220: Use BIT() and GENMASK() macros Andy Shevchenko
2020-08-31  9:08 ` [PATCH v1 8/8] iio: accel: bma220: Remove unneeded blank lines Andy Shevchenko
2020-08-31  9:21 ` [PATCH v1 1/8] iio: accel: bma220: Fix returned codes from bma220_init(), bma220_deinit() Jonathan Cameron
2020-08-31 11:49   ` Andy Shevchenko
2020-08-31 14:12     ` Jonathan Cameron
2020-09-03  8:21       ` Jonathan Cameron
2020-09-03  9:06         ` 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=20200903193551.3b89702e@archlinux \
    --to=jic23@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --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).