public inbox for linux-kernel@vger.kernel.org
 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-kernel@vger.kernel.org>,
	<rachna@ti.com>, <mugunthanvnm@ti.com>, <vigneshr@ti.com>,
	<afd@ti.com>
Subject: Re: [PATCH 2/3] iio: adc: ti_am335x_adc: alloc kfifo & IRQ via devm_ functions
Date: Sun, 5 Jul 2020 13:04:46 +0100	[thread overview]
Message-ID: <20200705130446.2261f08c@archlinux> (raw)
In-Reply-To: <20200428111430.71723-2-alexandru.ardelean@analog.com>

On Tue, 28 Apr 2020 14:14:29 +0300
Alexandru Ardelean <alexandru.ardelean@analog.com> wrote:

> This change attaches the life-cycle of the kfifo buffer & IRQ to the
> parent-device. This in turn cleans up the exit & error paths, since we
> don't need to explicitly cleanup these resources.
> 
> The main intent here is to remove the explicit cleanup of the
> 'indio_dev->buffer' via 'iio_kfifo_free(indio_dev->buffer);'.
> 
> As we want to add support for multiple buffers per IIO device, having it
> exposed like this makes it tricky to consider a safe backwards compatible
> approach for it.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Applied.

> ---
>  drivers/iio/adc/ti_am335x_adc.c | 20 +++++---------------
>  1 file changed, 5 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index d932fe383a24..03b2ab649cc3 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -377,7 +377,8 @@ static const struct iio_buffer_setup_ops tiadc_buffer_setup_ops = {
>  	.postdisable = &tiadc_buffer_postdisable,
>  };
>  
> -static int tiadc_iio_buffered_hardware_setup(struct iio_dev *indio_dev,
> +static int tiadc_iio_buffered_hardware_setup(struct device *dev,
> +	struct iio_dev *indio_dev,
>  	irqreturn_t (*pollfunc_bh)(int irq, void *p),
>  	irqreturn_t (*pollfunc_th)(int irq, void *p),
>  	int irq,
> @@ -387,13 +388,13 @@ static int tiadc_iio_buffered_hardware_setup(struct iio_dev *indio_dev,
>  	struct iio_buffer *buffer;
>  	int ret;
>  
> -	buffer = iio_kfifo_allocate();
> +	buffer = devm_iio_kfifo_allocate(dev);
>  	if (!buffer)
>  		return -ENOMEM;
>  
>  	iio_device_attach_buffer(indio_dev, buffer);
>  
> -	ret = request_threaded_irq(irq,	pollfunc_th, pollfunc_bh,
> +	ret = devm_request_threaded_irq(dev, irq, pollfunc_th, pollfunc_bh,
>  				flags, indio_dev->name, indio_dev);
>  	if (ret)
>  		goto error_kfifo_free;
> @@ -408,15 +409,6 @@ static int tiadc_iio_buffered_hardware_setup(struct iio_dev *indio_dev,
>  	return ret;
>  }
>  
> -static void tiadc_iio_buffered_hardware_remove(struct iio_dev *indio_dev)
> -{
> -	struct tiadc_device *adc_dev = iio_priv(indio_dev);
> -
> -	free_irq(adc_dev->mfd_tscadc->irq, indio_dev);
> -	iio_kfifo_free(indio_dev->buffer);
> -}
> -
> -
>  static const char * const chan_name_ain[] = {
>  	"AIN0",
>  	"AIN1",
> @@ -636,7 +628,7 @@ static int tiadc_probe(struct platform_device *pdev)
>  	if (err < 0)
>  		return err;
>  
> -	err = tiadc_iio_buffered_hardware_setup(indio_dev,
> +	err = tiadc_iio_buffered_hardware_setup(&pdev->dev, indio_dev,
>  		&tiadc_worker_h,
>  		&tiadc_irq_h,
>  		adc_dev->mfd_tscadc->irq,
> @@ -661,7 +653,6 @@ static int tiadc_probe(struct platform_device *pdev)
>  err_dma:
>  	iio_device_unregister(indio_dev);
>  err_buffer_unregister:
> -	tiadc_iio_buffered_hardware_remove(indio_dev);
>  err_free_channels:
>  	return err;
>  }
> @@ -679,7 +670,6 @@ static int tiadc_remove(struct platform_device *pdev)
>  		dma_release_channel(dma->chan);
>  	}
>  	iio_device_unregister(indio_dev);
> -	tiadc_iio_buffered_hardware_remove(indio_dev);
>  
>  	step_en = get_adc_step_mask(adc_dev);
>  	am335x_tsc_se_clr(adc_dev->mfd_tscadc, step_en);


  reply	other threads:[~2020-07-05 12:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 11:14 [PATCH 1/3] iio: adc: ti_am335x_adc: alloc channels via devm_kcalloc() Alexandru Ardelean
2020-04-28 11:14 ` [PATCH 2/3] iio: adc: ti_am335x_adc: alloc kfifo & IRQ via devm_ functions Alexandru Ardelean
2020-07-05 12:04   ` Jonathan Cameron [this message]
2020-04-28 11:14 ` [PATCH 3/3] iio: adc: ti_am335x_adc: convert rest of probe to " Alexandru Ardelean
2020-05-03 10:38   ` Jonathan Cameron
2020-07-05 12:04 ` [PATCH 1/3] iio: adc: ti_am335x_adc: alloc channels via devm_kcalloc() 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=20200705130446.2261f08c@archlinux \
    --to=jic23@kernel.org \
    --cc=afd@ti.com \
    --cc=alexandru.ardelean@analog.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mugunthanvnm@ti.com \
    --cc=rachna@ti.com \
    --cc=vigneshr@ti.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