All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH 07/11] iio:adc:ad7793: use samp_freq element of info_mask_shared_by_all.
Date: Mon, 18 Nov 2013 19:29:23 +0100	[thread overview]
Message-ID: <528A5C83.9020200@metafoo.de> (raw)
In-Reply-To: <1384701302-26564-8-git-send-email-jic23@kernel.org>

On 11/17/2013 04:14 PM, Jonathan Cameron wrote:
> This replaces the previous use of a custom attribute to create the same
> interface.  One big advantage is that this allows in kernel access.

Looks mostly good, can probably also be merged without waiting for the reset
of the series

[...]
> @@ -512,6 +457,10 @@ static int ad7793_read_raw(struct iio_dev *indio_dev,
>  			*val -= offset;
>  		}
>  		return IIO_VAL_INT;
> +	case IIO_CHAN_INFO_SAMP_FREQ:
> +		*val = st->chip_info->
> +			sample_freq_avail[AD7793_MODE_RATE(st->mode)];
> +		return IIO_VAL_INT;
>  	}
>  	return -EINVAL;
>  }
> @@ -551,6 +500,20 @@ static int ad7793_write_raw(struct iio_dev *indio_dev,
>  				break;
>  			}
>  		break;
> +	case IIO_CHAN_INFO_SAMP_FREQ:
> +		if (val == 0)
> +			return -EINVAL;
> +
> +		ret = -EINVAL;
> +		for (i = 0; i < 16; i++)
> +			if (val == st->chip_info->sample_freq_avail[i]) {
> +				st->mode &= ~AD7793_MODE_RATE(-1);
> +				st->mode |= AD7793_MODE_RATE(i);
> +				ad_sd_write_reg(&st->sd, AD7793_REG_MODE,
> +						sizeof(st->mode), st->mode);
> +				ret = 0;
> +			}

In order to keep the indentation level low I'd put this into it's own function.

> +		break;
>  	default:
>  		ret = -EINVAL;
>  	}
[...]
>  #define DECLARE_AD7799_CHANNELS(_name, _b, _sb) \
>  const struct iio_chan_spec _name##_channels[] = { \
>  	AD_SD_DIFF_CHANNEL(0, 0, 0, AD7793_CH_AIN1P_AIN1M, (_b), (_sb), 0, \
> -	0, 0, 0), \
> +	BIT(IIO_CHAN_INFO_SAMP_FREQ), 0, 0), \
>  	AD_SD_DIFF_CHANNEL(1, 1, 1, AD7793_CH_AIN2P_AIN2M, (_b), (_sb), 0, \
> -	0, 0, 0), \
> +	BIT(IIO_CHAN_INFO_SAMP_FREQ), 0, 0), \
>  	AD_SD_DIFF_CHANNEL(2, 2, 2, AD7793_CH_AIN3P_AIN3M, (_b), (_sb), 0, \
> -	0, 0, 0), \
> +	BIT(IIO_CHAN_INFO_SAMP_FREQ), 0, 0), \
>  	AD_SD_SHORTED_CHANNEL(3, 0, AD7793_CH_AIN1M_AIN1M, (_b), (_sb), 0, \
> -	0, 0, 0), \
> +	BIT(IIO_CHAN_INFO_SAMP_FREQ), 0, 0), \
>  	AD_SD_SUPPLY_CHANNEL(4, 3, AD7793_CH_AVDD_MONITOR, (_b), (_sb), 0, \
> -	0, 0, 0), \
> +	BIT(IIO_CHAN_INFO_SAMP_FREQ), 0, 0), \
>  	IIO_CHAN_SOFT_TIMESTAMP(5), \
>  }

Do we actually have any channels that won't have the SAMP_FREQ attribute set?

  reply	other threads:[~2013-11-18 18:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-17 15:14 [RFC PATCH 00/11] IIO: Add core support for _available interfaces Jonathan Cameron
2013-11-17 15:14 ` [PATCH 01/11] iio:core: add a callback to allow drivers to provide _available attributes Jonathan Cameron
2013-11-17 15:14 ` [PATCH 02/11] staging:iio:dummy driver: Add example usecases for the new *_available interface Jonathan Cameron
2013-11-17 15:14 ` [PATCH 03/11] iio:accel:bma180 use new read_avail to replace *_available attrs Jonathan Cameron
2013-11-17 15:14 ` [PATCH 04/11] iio:accel:kxsd9 use new read_avail to replace accel_scan_available Jonathan Cameron
2013-11-17 15:14 ` [PATCH 05/11] iio:st sensors: remove custom sampling frequence attribute in favour of core support Jonathan Cameron
2013-11-18 18:25   ` Lars-Peter Clausen
2013-11-17 15:14 ` [PATCH 06/11] iio: ad_sigma_delta provide macro parameters for available info masks Jonathan Cameron
2013-11-17 15:14 ` [PATCH 07/11] iio:adc:ad7793: use samp_freq element of info_mask_shared_by_all Jonathan Cameron
2013-11-18 18:29   ` Lars-Peter Clausen [this message]
2013-11-18 20:52     ` Jonathan Cameron
2013-11-17 15:14 ` [PATCH 08/11] iio:adc:ad7793: Use the read_avail callback to provide the scale and sampling frequency interfaces Jonathan Cameron
2013-11-17 15:15 ` [PATCH 09/11] iio:adc:ad7791 Provide sampling frequency and scale_available access via core Jonathan Cameron
2013-11-17 15:15 ` [PATCH 10/11] staging:iio:adc:ad7192 use infomask* to provide access to sampling frequency and scale_available Jonathan Cameron
2013-11-17 15:15 ` [PATCH 11/11] iio:adc:mcp3422: use core to provide _available information rather than custom attrs 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=528A5C83.9020200@metafoo.de \
    --to=lars@metafoo.de \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.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.