Linux-IIO Archive on lore.kernel.org
 help / color / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Beniamin Bia <beniamin.bia@analog.com>
Cc: <linux-iio@vger.kernel.org>, <biabeniamin@outlook.com>
Subject: Re: [PATCH 2/5] iio: adc: ad7606: Move spi dependent features to spi file
Date: Sun, 28 Jul 2019 08:57:39 +0100
Message-ID: <20190728085733.3ca64de3@archlinux> (raw)
In-Reply-To: <20190718062734.17306-2-beniamin.bia@analog.com>

On Thu, 18 Jul 2019 09:27:31 +0300
Beniamin Bia <beniamin.bia@analog.com> wrote:

> Because software mode and register access are only available in spi, they
> were moved in spi file and are accessbile via bops structure.
> The write_os/scale will be overwritten by sw_mode_config function.
> This patch was made in order to support devices in software mode without
> making the driver dependent to spi and increase the abstraction of the
> core.
> 
> Signed-off-by: Beniamin Bia <beniamin.bia@analog.com>
> Acked-by: Jonathan Cameron <jic23@kernel.org>
Applied.

thanks,

Jonathan

> ---
> Changes in v2:
> -nothing changed
> 
>  drivers/iio/adc/ad7606.c | 20 ++------------------
>  drivers/iio/adc/ad7606.h | 12 +++---------
>  2 files changed, 5 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index a49dc106a21c..9eec3db01a17 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -597,7 +597,7 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
>  	st->write_scale = ad7606_write_scale_hw;
>  	st->write_os = ad7606_write_os_hw;
>  
> -	if (st->chip_info->sw_mode_config)
> +	if (st->bops->sw_mode_config)
>  		st->sw_mode_en = device_property_present(st->dev,
>  							 "adi,sw-mode");
>  
> @@ -606,23 +606,7 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
>  		memset32(st->range, 2, ARRAY_SIZE(st->range));
>  		indio_dev->info = &ad7606_info_os_and_range;
>  
> -		/*
> -		 * In software mode, the range gpio has no longer its function.
> -		 * Instead, the scale can be configured individually for each
> -		 * channel from the range registers.
> -		 */
> -		if (st->chip_info->write_scale_sw)
> -			st->write_scale = st->chip_info->write_scale_sw;
> -
> -		/*
> -		 * In software mode, the oversampling is no longer configured
> -		 * with GPIO pins. Instead, the oversampling can be configured
> -		 * in configuratiion register.
> -		 */
> -		if (st->chip_info->write_os_sw)
> -			st->write_os = st->chip_info->write_os_sw;
> -
> -		ret = st->chip_info->sw_mode_config(indio_dev);
> +		ret = st->bops->sw_mode_config(indio_dev);
>  		if (ret < 0)
>  			return ret;
>  	}
> diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h
> index d547e88f4c9d..a6aac33aa33c 100644
> --- a/drivers/iio/adc/ad7606.h
> +++ b/drivers/iio/adc/ad7606.h
> @@ -39,12 +39,6 @@
>   *			oversampling ratios.
>   * @oversampling_num	number of elements stored in oversampling_avail array
>   * @os_req_reset	some devices require a reset to update oversampling
> - * @write_scale_sw	pointer to the function which writes the scale via spi
> -			in software mode
> - * @write_os_sw		pointer to the function which writes the os via spi
> -			in software mode
> - * @sw_mode_config:	pointer to a function which configured the device
> - *			for software mode
>   */
>  struct ad7606_chip_info {
>  	const struct iio_chan_spec	*channels;
> @@ -52,9 +46,6 @@ struct ad7606_chip_info {
>  	const unsigned int		*oversampling_avail;
>  	unsigned int			oversampling_num;
>  	bool				os_req_reset;
> -	int (*write_scale_sw)(struct iio_dev *indio_dev, int ch, int val);
> -	int (*write_os_sw)(struct iio_dev *indio_dev, int val);
> -	int (*sw_mode_config)(struct iio_dev *indio_dev);
>  };
>  
>  /**
> @@ -124,10 +115,13 @@ struct ad7606_state {
>  /**
>   * struct ad7606_bus_ops - driver bus operations
>   * @read_block		function pointer for reading blocks of data
> + * @sw_mode_config:	pointer to a function which configured the device
> + *			for software mode
>   */
>  struct ad7606_bus_ops {
>  	/* more methods added in future? */
>  	int (*read_block)(struct device *dev, int num, void *data);
> +	int (*sw_mode_config)(struct iio_dev *indio_dev);
>  };
>  
>  int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,


  reply index

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-18  6:27 [PATCH 1/5] iio: adc: ad7606: Move common channel definition to header Beniamin Bia
2019-07-18  6:27 ` [PATCH 2/5] iio: adc: ad7606: Move spi dependent features to spi file Beniamin Bia
2019-07-28  7:57   ` Jonathan Cameron [this message]
2019-07-18  6:27 ` [PATCH 3/5] iio: adc: ad7606: Allow reconfigration after reset Beniamin Bia
2019-07-28  7:57   ` Jonathan Cameron
2019-07-18  6:27 ` [PATCH 4/5] iio: adc: ad7606: Add support for software mode for ad7616 Beniamin Bia
2019-07-28  7:58   ` Jonathan Cameron
2019-07-18  6:27 ` [PATCH 5/5] iio: adc: ad7606: Add debug " Beniamin Bia
2019-07-28  7:58   ` Jonathan Cameron
2019-07-28  7:57 ` [PATCH 1/5] iio: adc: ad7606: Move common channel definition to header Jonathan Cameron
  -- strict thread matches above, loose matches on Subject: below --
2019-07-03 14:36 Beniamin Bia
2019-07-03 14:36 ` [PATCH 2/5] iio: adc: ad7606: Move spi dependent features to spi file Beniamin Bia

Reply instructions:

You may reply publically 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=20190728085733.3ca64de3@archlinux \
    --to=jic23@kernel.org \
    --cc=beniamin.bia@analog.com \
    --cc=biabeniamin@outlook.com \
    --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

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org linux-iio@archiver.kernel.org
	public-inbox-index linux-iio


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/ public-inbox