From: Jonathan Cameron <jic23@kernel.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
linux-iio@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Michal Simek <michal.simek@xilinx.com>,
linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bgolaszewski@baylibre.com>,
linux-arm-kernel@lists.infradead.org,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Hartmut Knaack <knaack.h@gmx.de>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Guenter Roeck <linux@roeck-us.net>
Subject: Re: [PATCH v5 3/3] iio: adc: xilinx-xadc: use devm_krealloc()
Date: Mon, 20 Jul 2020 12:25:26 +0100 [thread overview]
Message-ID: <20200720122526.2662732f@archlinux> (raw)
In-Reply-To: <20200715092528.8136-4-brgl@bgdev.pl>
On Wed, 15 Jul 2020 11:25:28 +0200
Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
>
> Use the managed variant of krealloc() and shrink the code a bit.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Looks good to me.
Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/iio/adc/xilinx-xadc-core.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c
> index d7fecab9252e4..5bdbe502e983a 100644
> --- a/drivers/iio/adc/xilinx-xadc-core.c
> +++ b/drivers/iio/adc/xilinx-xadc-core.c
> @@ -1094,6 +1094,7 @@ MODULE_DEVICE_TABLE(of, xadc_of_match_table);
> static int xadc_parse_dt(struct iio_dev *indio_dev, struct device_node *np,
> unsigned int *conf)
> {
> + struct device *dev = indio_dev->dev.parent;
> struct xadc *xadc = iio_priv(indio_dev);
> struct iio_chan_spec *channels, *chan;
> struct device_node *chan_node, *child;
> @@ -1138,7 +1139,8 @@ static int xadc_parse_dt(struct iio_dev *indio_dev, struct device_node *np,
> *conf |= XADC_CONF0_MUX | XADC_CONF0_CHAN(ext_mux_chan);
> }
>
> - channels = kmemdup(xadc_channels, sizeof(xadc_channels), GFP_KERNEL);
> + channels = devm_kmemdup(dev, xadc_channels,
> + sizeof(xadc_channels), GFP_KERNEL);
> if (!channels)
> return -ENOMEM;
>
> @@ -1174,8 +1176,9 @@ static int xadc_parse_dt(struct iio_dev *indio_dev, struct device_node *np,
> of_node_put(chan_node);
>
> indio_dev->num_channels = num_channels;
> - indio_dev->channels = krealloc(channels, sizeof(*channels) *
> - num_channels, GFP_KERNEL);
> + indio_dev->channels = devm_krealloc(dev, channels,
> + sizeof(*channels) * num_channels,
> + GFP_KERNEL);
> /* If we can't resize the channels array, just use the original */
> if (!indio_dev->channels)
> indio_dev->channels = channels;
> @@ -1229,14 +1232,14 @@ static int xadc_probe(struct platform_device *pdev)
>
> ret = xadc_parse_dt(indio_dev, pdev->dev.of_node, &conf0);
> if (ret)
> - goto err_device_free;
> + return ret;
>
> if (xadc->ops->flags & XADC_FLAGS_BUFFERED) {
> ret = iio_triggered_buffer_setup(indio_dev,
> &iio_pollfunc_store_time, &xadc_trigger_handler,
> &xadc_buffer_ops);
> if (ret)
> - goto err_device_free;
> + return ret;
>
> xadc->convst_trigger = xadc_alloc_trigger(indio_dev, "convst");
> if (IS_ERR(xadc->convst_trigger)) {
> @@ -1354,8 +1357,6 @@ static int xadc_probe(struct platform_device *pdev)
> err_triggered_buffer_cleanup:
> if (xadc->ops->flags & XADC_FLAGS_BUFFERED)
> iio_triggered_buffer_cleanup(indio_dev);
> -err_device_free:
> - kfree(indio_dev->channels);
>
> return ret;
> }
> @@ -1375,7 +1376,6 @@ static int xadc_remove(struct platform_device *pdev)
> cancel_delayed_work_sync(&xadc->zynq_unmask_work);
> clk_disable_unprepare(xadc->clk);
> kfree(xadc->data);
> - kfree(indio_dev->channels);
>
> return 0;
> }
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
prev parent reply other threads:[~2020-07-20 11:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-15 9:25 [PATCH v5 0/3] devres: provide and use devm_krealloc() Bartosz Golaszewski
2020-07-15 9:25 ` [PATCH v5 1/3] devres: provide devm_krealloc() Bartosz Golaszewski
2020-07-15 9:35 ` Andy Shevchenko
2020-07-25 19:20 ` Bartosz Golaszewski
2020-07-15 9:25 ` [PATCH v5 2/3] hwmon: pmbus: use more devres helpers Bartosz Golaszewski
2020-07-15 9:25 ` [PATCH v5 3/3] iio: adc: xilinx-xadc: use devm_krealloc() Bartosz Golaszewski
2020-07-20 11:25 ` 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=20200720122526.2662732f@archlinux \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=bgolaszewski@baylibre.com \
--cc=brgl@bgdev.pl \
--cc=gregkh@linuxfoundation.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=michal.simek@xilinx.com \
--cc=pmeerw@pmeerw.net \
/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).