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 1/3] iio: adc: ti_am335x_adc: alloc channels via devm_kcalloc()
Date: Sun, 5 Jul 2020 13:04:14 +0100	[thread overview]
Message-ID: <20200705130414.0aa2ac9b@archlinux> (raw)
In-Reply-To: <20200428111430.71723-1-alexandru.ardelean@analog.com>

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

> This change attaches the life-cycle of the channels array to the parent
> device object that is attached to the IIO device.
> This way we can remove from the cleanup code, the explicit
> tiadc_channels_remove() which simply does a kfree() on the channels array.
> 
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Still not sure on patch 3 but I'll pick up the first 2 so we can forget
about those.

Applied to the togreg branch of iio.git and pushed out as testing for
all the usual reasons.

Thanks,

Jonathan

> ---
> 
> The reason I'm targetting this driver, is because it's among the few
> places where 'indio_dev->buffer' is accessed directly in the driver, and
> that makes it difficult to think of a sane-backwards-compatible way to
> do multiple IIO buffers.
> 
>  drivers/iio/adc/ti_am335x_adc.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
> index 9d984f2a8ba7..d932fe383a24 100644
> --- a/drivers/iio/adc/ti_am335x_adc.c
> +++ b/drivers/iio/adc/ti_am335x_adc.c
> @@ -428,7 +428,8 @@ static const char * const chan_name_ain[] = {
>  	"AIN7",
>  };
>  
> -static int tiadc_channel_init(struct iio_dev *indio_dev, int channels)
> +static int tiadc_channel_init(struct device *dev, struct iio_dev *indio_dev,
> +			      int channels)
>  {
>  	struct tiadc_device *adc_dev = iio_priv(indio_dev);
>  	struct iio_chan_spec *chan_array;
> @@ -436,7 +437,8 @@ static int tiadc_channel_init(struct iio_dev *indio_dev, int channels)
>  	int i;
>  
>  	indio_dev->num_channels = channels;
> -	chan_array = kcalloc(channels, sizeof(*chan_array), GFP_KERNEL);
> +	chan_array = devm_kcalloc(dev, channels, sizeof(*chan_array),
> +				  GFP_KERNEL);
>  	if (chan_array == NULL)
>  		return -ENOMEM;
>  
> @@ -459,11 +461,6 @@ static int tiadc_channel_init(struct iio_dev *indio_dev, int channels)
>  	return 0;
>  }
>  
> -static void tiadc_channels_remove(struct iio_dev *indio_dev)
> -{
> -	kfree(indio_dev->channels);
> -}
> -
>  static int tiadc_read_raw(struct iio_dev *indio_dev,
>  		struct iio_chan_spec const *chan,
>  		int *val, int *val2, long mask)
> @@ -635,7 +632,7 @@ static int tiadc_probe(struct platform_device *pdev)
>  	tiadc_writel(adc_dev, REG_FIFO1THR, FIFO1_THRESHOLD);
>  	mutex_init(&adc_dev->fifo1_lock);
>  
> -	err = tiadc_channel_init(indio_dev, adc_dev->channels);
> +	err = tiadc_channel_init(&pdev->dev, indio_dev, adc_dev->channels);
>  	if (err < 0)
>  		return err;
>  
> @@ -666,7 +663,6 @@ static int tiadc_probe(struct platform_device *pdev)
>  err_buffer_unregister:
>  	tiadc_iio_buffered_hardware_remove(indio_dev);
>  err_free_channels:
> -	tiadc_channels_remove(indio_dev);
>  	return err;
>  }
>  
> @@ -684,7 +680,6 @@ static int tiadc_remove(struct platform_device *pdev)
>  	}
>  	iio_device_unregister(indio_dev);
>  	tiadc_iio_buffered_hardware_remove(indio_dev);
> -	tiadc_channels_remove(indio_dev);
>  
>  	step_en = get_adc_step_mask(adc_dev);
>  	am335x_tsc_se_clr(adc_dev->mfd_tscadc, step_en);


      parent 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
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 ` 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=20200705130414.0aa2ac9b@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