linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <linux-iio@vger.kernel.org>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <mcoquelin.stm32@gmail.com>,
	<alexandre.torgue@st.com>
Subject: Re: [PATCH] iio: stm32-dfsdm-adc: keep a reference to the iio device on the state struct
Date: Sun, 24 May 2020 14:13:06 +0100	[thread overview]
Message-ID: <20200524141306.139d7433@archlinux> (raw)
In-Reply-To: <20200522130804.631508-1-alexandru.ardelean@analog.com>

On Fri, 22 May 2020 16:08:04 +0300
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:

> We may want to get rid of the iio_priv_to_dev() helper. The reason is that
> we will hide some of the members of the iio_dev structure (to prevent
> drivers from accessing them directly), and that will also mean hiding the
> implementation of the iio_priv_to_dev() helper inside the IIO core.
> 
> Hiding the implementation of iio_priv_to_dev() implies that some fast-paths
> may not be fast anymore, so a general idea is to try to get rid of the
> iio_priv_to_dev() altogether.
> The iio_priv() helper won't be affected by the rework.
> 
> For this driver, not using iio_priv_to_dev(), means keeping a reference to
> the IIO device on the state struct.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>

As this one is a bit simpler, I think the case for just changing the callbacks
to take the iio_dev directly is stronger than adding this level of indirection.

Again, perhaps I'm missing something.

Jonathan

> ---
>  drivers/iio/adc/stm32-dfsdm-adc.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c
> index 76a60d93fe23..ff7a6afa4558 100644
> --- a/drivers/iio/adc/stm32-dfsdm-adc.c
> +++ b/drivers/iio/adc/stm32-dfsdm-adc.c
> @@ -69,6 +69,7 @@ struct stm32_dfsdm_dev_data {
>  
>  struct stm32_dfsdm_adc {
>  	struct stm32_dfsdm *dfsdm;
> +	struct iio_dev *indio_dev;
>  	const struct stm32_dfsdm_dev_data *dev_data;
>  	unsigned int fl_id;
>  	unsigned int nconv;
> @@ -332,7 +333,7 @@ static int stm32_dfsdm_compute_all_osrs(struct iio_dev *indio_dev,
>  
>  static int stm32_dfsdm_start_channel(struct stm32_dfsdm_adc *adc)
>  {
> -	struct iio_dev *indio_dev = iio_priv_to_dev(adc);
> +	struct iio_dev *indio_dev = adc->indio_dev;
>  	struct regmap *regmap = adc->dfsdm->regmap;
>  	const struct iio_chan_spec *chan;
>  	unsigned int bit;
> @@ -352,7 +353,7 @@ static int stm32_dfsdm_start_channel(struct stm32_dfsdm_adc *adc)
>  
>  static void stm32_dfsdm_stop_channel(struct stm32_dfsdm_adc *adc)
>  {
> -	struct iio_dev *indio_dev = iio_priv_to_dev(adc);
> +	struct iio_dev *indio_dev = adc->indio_dev;
>  	struct regmap *regmap = adc->dfsdm->regmap;
>  	const struct iio_chan_spec *chan;
>  	unsigned int bit;
> @@ -422,7 +423,7 @@ static int stm32_dfsdm_filter_set_trig(struct stm32_dfsdm_adc *adc,
>  				       unsigned int fl_id,
>  				       struct iio_trigger *trig)
>  {
> -	struct iio_dev *indio_dev = iio_priv_to_dev(adc);
> +	struct iio_dev *indio_dev = adc->indio_dev;
>  	struct regmap *regmap = adc->dfsdm->regmap;
>  	u32 jextsel = 0, jexten = STM32_DFSDM_JEXTEN_DISABLED;
>  	int ret;
> @@ -451,7 +452,7 @@ static int stm32_dfsdm_channels_configure(struct stm32_dfsdm_adc *adc,
>  					  unsigned int fl_id,
>  					  struct iio_trigger *trig)
>  {
> -	struct iio_dev *indio_dev = iio_priv_to_dev(adc);
> +	struct iio_dev *indio_dev = adc->indio_dev;
>  	struct regmap *regmap = adc->dfsdm->regmap;
>  	struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[fl_id];
>  	struct stm32_dfsdm_filter_osr *flo = &fl->flo[0];
> @@ -495,7 +496,7 @@ static int stm32_dfsdm_filter_configure(struct stm32_dfsdm_adc *adc,
>  					unsigned int fl_id,
>  					struct iio_trigger *trig)
>  {
> -	struct iio_dev *indio_dev = iio_priv_to_dev(adc);
> +	struct iio_dev *indio_dev = adc->indio_dev;
>  	struct regmap *regmap = adc->dfsdm->regmap;
>  	struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[fl_id];
>  	struct stm32_dfsdm_filter_osr *flo = &fl->flo[fl->fast];
> @@ -1314,7 +1315,7 @@ static const struct iio_info stm32_dfsdm_info_adc = {
>  static irqreturn_t stm32_dfsdm_irq(int irq, void *arg)
>  {
>  	struct stm32_dfsdm_adc *adc = arg;
> -	struct iio_dev *indio_dev = iio_priv_to_dev(adc);
> +	struct iio_dev *indio_dev = adc->indio_dev;
>  	struct regmap *regmap = adc->dfsdm->regmap;
>  	unsigned int status, int_en;
>  
> @@ -1569,6 +1570,7 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
>  
>  	adc = iio_priv(iio);
>  	adc->dfsdm = dev_get_drvdata(dev->parent);
> +	adc->indio_dev = iio;
>  
>  	iio->dev.parent = dev;
>  	iio->dev.of_node = np;
> @@ -1651,7 +1653,7 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev)
>  static int stm32_dfsdm_adc_remove(struct platform_device *pdev)
>  {
>  	struct stm32_dfsdm_adc *adc = platform_get_drvdata(pdev);
> -	struct iio_dev *indio_dev = iio_priv_to_dev(adc);
> +	struct iio_dev *indio_dev = adc->indio_dev;
>  
>  	if (adc->dev_data->type == DFSDM_AUDIO)
>  		of_platform_depopulate(&pdev->dev);
> @@ -1664,7 +1666,7 @@ static int stm32_dfsdm_adc_remove(struct platform_device *pdev)
>  static int __maybe_unused stm32_dfsdm_adc_suspend(struct device *dev)
>  {
>  	struct stm32_dfsdm_adc *adc = dev_get_drvdata(dev);
> -	struct iio_dev *indio_dev = iio_priv_to_dev(adc);
> +	struct iio_dev *indio_dev = adc->indio_dev;
>  
>  	if (iio_buffer_enabled(indio_dev))
>  		__stm32_dfsdm_predisable(indio_dev);
> @@ -1675,7 +1677,7 @@ static int __maybe_unused stm32_dfsdm_adc_suspend(struct device *dev)
>  static int __maybe_unused stm32_dfsdm_adc_resume(struct device *dev)
>  {
>  	struct stm32_dfsdm_adc *adc = dev_get_drvdata(dev);
> -	struct iio_dev *indio_dev = iio_priv_to_dev(adc);
> +	struct iio_dev *indio_dev = adc->indio_dev;
>  	const struct iio_chan_spec *chan;
>  	struct stm32_dfsdm_channel *ch;
>  	int i, ret;


  reply	other threads:[~2020-05-24 13:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-22 13:08 [PATCH] iio: stm32-dfsdm-adc: keep a reference to the iio device on the state struct Alexandru Ardelean
2020-05-24 13:13 ` Jonathan Cameron [this message]
2020-05-25  8:26 ` [PATCH v2] iio: stm32-dfsdm-adc: remove usage of iio_priv_to_dev() helper Alexandru Ardelean
2020-05-31 14:45   ` Jonathan Cameron
2020-06-19  8:00     ` Ardelean, Alexandru
2020-06-20 16:27       ` 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=20200524141306.139d7433@archlinux \
    --to=jic23@kernel.org \
    --cc=alexandre.torgue@st.com \
    --cc=alexandru.ardelean@analog.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    /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).