All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: linux-iio@vger.kernel.org
Subject: Re: [PATCH 1/3] iio:ad5064: Fix address of the second channel for ad5065/ad5045/ad5025
Date: Sat, 02 Mar 2013 16:23:22 +0000	[thread overview]
Message-ID: <5132277A.5040304@kernel.org> (raw)
In-Reply-To: <1362143239-891-1-git-send-email-lars@metafoo.de>

On 03/01/2013 01:07 PM, Lars-Peter Clausen wrote:
> The ad5065, ad5045, ad5025 use address '3' for the second channel, so they need
> their own channel spec.
Obviously! (another candidate for weird hardware designer of the day :)
> 
> Note that ad5064_sync_powerdown_mode() also needs to be slightly updated since
> it was relying on the fact that chan->address always equaled chan->channel.
> 
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
applied to fixes-togreg branch of iio.git

> ---
>  drivers/iio/dac/ad5064.c | 49 ++++++++++++++++++++++++++++--------------------
>  1 file changed, 29 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c
> index eb281a2..e19b73f 100644
> --- a/drivers/iio/dac/ad5064.c
> +++ b/drivers/iio/dac/ad5064.c
> @@ -27,7 +27,6 @@
>  #define AD5064_ADDR(x)				((x) << 20)
>  #define AD5064_CMD(x)				((x) << 24)
>  
> -#define AD5064_ADDR_DAC(chan)			(chan)
>  #define AD5064_ADDR_ALL_DAC			0xF
>  
>  #define AD5064_CMD_WRITE_INPUT_N		0x0
> @@ -131,15 +130,15 @@ static int ad5064_write(struct ad5064_state *st, unsigned int cmd,
>  }
>  
>  static int ad5064_sync_powerdown_mode(struct ad5064_state *st,
> -	unsigned int channel)
> +	const struct iio_chan_spec *chan)
>  {
>  	unsigned int val;
>  	int ret;
>  
> -	val = (0x1 << channel);
> +	val = (0x1 << chan->address);
>  
> -	if (st->pwr_down[channel])
> -		val |= st->pwr_down_mode[channel] << 8;
> +	if (st->pwr_down[chan->channel])
> +		val |= st->pwr_down_mode[chan->channel] << 8;
>  
>  	ret = ad5064_write(st, AD5064_CMD_POWERDOWN_DAC, 0, val, 0);
>  
> @@ -169,7 +168,7 @@ static int ad5064_set_powerdown_mode(struct iio_dev *indio_dev,
>  	mutex_lock(&indio_dev->mlock);
>  	st->pwr_down_mode[chan->channel] = mode + 1;
>  
> -	ret = ad5064_sync_powerdown_mode(st, chan->channel);
> +	ret = ad5064_sync_powerdown_mode(st, chan);
>  	mutex_unlock(&indio_dev->mlock);
>  
>  	return ret;
> @@ -205,7 +204,7 @@ static ssize_t ad5064_write_dac_powerdown(struct iio_dev *indio_dev,
>  	mutex_lock(&indio_dev->mlock);
>  	st->pwr_down[chan->channel] = pwr_down;
>  
> -	ret = ad5064_sync_powerdown_mode(st, chan->channel);
> +	ret = ad5064_sync_powerdown_mode(st, chan);
>  	mutex_unlock(&indio_dev->mlock);
>  	return ret ? ret : len;
>  }
> @@ -292,34 +291,44 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = {
>  	{ },
>  };
>  
> -#define AD5064_CHANNEL(chan, bits) {				\
> +#define AD5064_CHANNEL(chan, addr, bits) {			\
>  	.type = IIO_VOLTAGE,					\
>  	.indexed = 1,						\
>  	.output = 1,						\
>  	.channel = (chan),					\
>  	.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |		\
>  	IIO_CHAN_INFO_SCALE_SEPARATE_BIT,			\
> -	.address = AD5064_ADDR_DAC(chan),			\
> +	.address = addr,					\
>  	.scan_type = IIO_ST('u', (bits), 16, 20 - (bits)),	\
>  	.ext_info = ad5064_ext_info,				\
>  }
>  
>  #define DECLARE_AD5064_CHANNELS(name, bits) \
>  const struct iio_chan_spec name[] = { \
> -	AD5064_CHANNEL(0, bits), \
> -	AD5064_CHANNEL(1, bits), \
> -	AD5064_CHANNEL(2, bits), \
> -	AD5064_CHANNEL(3, bits), \
> -	AD5064_CHANNEL(4, bits), \
> -	AD5064_CHANNEL(5, bits), \
> -	AD5064_CHANNEL(6, bits), \
> -	AD5064_CHANNEL(7, bits), \
> +	AD5064_CHANNEL(0, 0, bits), \
> +	AD5064_CHANNEL(1, 1, bits), \
> +	AD5064_CHANNEL(2, 2, bits), \
> +	AD5064_CHANNEL(3, 3, bits), \
> +	AD5064_CHANNEL(4, 4, bits), \
> +	AD5064_CHANNEL(5, 5, bits), \
> +	AD5064_CHANNEL(6, 6, bits), \
> +	AD5064_CHANNEL(7, 7, bits), \
> +}
> +
> +#define DECLARE_AD5065_CHANNELS(name, bits) \
> +const struct iio_chan_spec name[] = { \
> +	AD5064_CHANNEL(0, 0, bits), \
> +	AD5064_CHANNEL(1, 3, bits), \
>  }
>  
>  static DECLARE_AD5064_CHANNELS(ad5024_channels, 12);
>  static DECLARE_AD5064_CHANNELS(ad5044_channels, 14);
>  static DECLARE_AD5064_CHANNELS(ad5064_channels, 16);
>  
> +static DECLARE_AD5065_CHANNELS(ad5025_channels, 12);
> +static DECLARE_AD5065_CHANNELS(ad5045_channels, 14);
> +static DECLARE_AD5065_CHANNELS(ad5065_channels, 16);
> +
>  static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
>  	[ID_AD5024] = {
>  		.shared_vref = false,
> @@ -328,7 +337,7 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
>  	},
>  	[ID_AD5025] = {
>  		.shared_vref = false,
> -		.channels = ad5024_channels,
> +		.channels = ad5025_channels,
>  		.num_channels = 2,
>  	},
>  	[ID_AD5044] = {
> @@ -338,7 +347,7 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
>  	},
>  	[ID_AD5045] = {
>  		.shared_vref = false,
> -		.channels = ad5044_channels,
> +		.channels = ad5045_channels,
>  		.num_channels = 2,
>  	},
>  	[ID_AD5064] = {
> @@ -353,7 +362,7 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
>  	},
>  	[ID_AD5065] = {
>  		.shared_vref = false,
> -		.channels = ad5064_channels,
> +		.channels = ad5065_channels,
>  		.num_channels = 2,
>  	},
>  	[ID_AD5628_1] = {
> 

      parent reply	other threads:[~2013-03-02 16:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-01 13:07 [PATCH 1/3] iio:ad5064: Fix address of the second channel for ad5065/ad5045/ad5025 Lars-Peter Clausen
2013-03-01 13:07 ` [PATCH 2/3] iio:ad5064: Fix off by one in DAC value range check Lars-Peter Clausen
2013-03-02 16:24   ` Jonathan Cameron
2013-03-01 13:07 ` [PATCH 3/3] iio:ad5064: Initialize register cache correctly Lars-Peter Clausen
2013-03-02 16:25   ` Jonathan Cameron
2013-03-02 16:23 ` Jonathan Cameron [this message]

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=5132277A.5040304@kernel.org \
    --to=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --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.