Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1450535
| From | John Keeping <john@metanate.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 1/4] iio: adc: rockchip_saradc: reset saradc controller before programming it |
| Date | 2016-07-26 13:20 +0200 |
| Message-ID | <rZ8z0-1ge-3@gated-at.bofh.it> (permalink) |
| References | <rZ3SF-6Uk-7@gated-at.bofh.it> <rZ6xb-5m-5@gated-at.bofh.it> <rZ8fD-UK-11@gated-at.bofh.it> |
| Organization | Metanate Ltd |
On Tue, 26 Jul 2016 18:49:56 +0800, Caesar Wang wrote:
>
> On 2016年07月26日 17:00, John Keeping wrote:
> > On Tue, 26 Jul 2016 14:11:47 +0800, Caesar Wang wrote:
> >
> >> SARADC controller needs to be reset before programming it, otherwise
> >> it will not function properly.
> >>
> >> Signed-off-by: Caesar Wang <wxt@rock-chips.com>
> >> Cc: Jonathan Cameron <jic23@kernel.org>
> >> Cc: Heiko Stuebner <heiko@sntech.de>
> >> Cc: Rob Herring <robh+dt@kernel.org>
> >> Cc: linux-iio@vger.kernel.org
> >> Cc: linux-rockchip@lists.infradead.org
> >> ---
> >>
> >> diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c
> >> index f9ad6c2..2f0e110 100644
> >> --- a/drivers/iio/adc/rockchip_saradc.c
> >> +++ b/drivers/iio/adc/rockchip_saradc.c
> >> @@ -218,6 +231,13 @@ static int rockchip_saradc_probe(struct platform_device *pdev)
> >> if (IS_ERR(info->regs))
> >> return PTR_ERR(info->regs);
> >>
> >> + info->reset = devm_reset_control_get(&pdev->dev, "saradc-apb");
> >> + if (IS_ERR(info->reset)) {
> >> + ret = PTR_ERR(info->reset);
> >> + dev_err(&pdev->dev, "failed to get saradc reset: %d\n", ret);
> >> + return ret;
> >> + }
> > Does this need to handle ENOENT so as to avoid failing with old device
> > tree blobs?
>
> I'm no sure why we have to support the old device tree,
> We can apply this series patches if we need to support the reset property.
> ---
>
> Maybe, I can follow you suggestion to handle the ENOENT, as following:
>
> + /*
> + * The reset should be an optional property, as it should work
> + * with old devicetrees as well
> + */
> + info->reset = devm_reset_control_get(&pdev->dev, "saradc-apb");
> + if (IS_ERR(info->reset)) {
> + if (PTR_ERR(info->reset) == -EPROBE_DEFER) {
> + ret = -EPROBE_DEFER;
> + return ret;
> + }
> + dev_dbg(&pdev->dev, "no reset control found\n");
> + info->reset = NULL;
> + }
> ...
>
> How about it?
I think it's better to handle ENOENT specifically, we still want to fail
if some other errors like EINVAL is returned.
Something like this, perhaps?
if (IS_ERR(info->reset)) {
ret = PTR_ERR(info->reset);
if (ret != -ENOENT)
return ret;
dev_dbg(&pdev->dev, "no reset control found\n");
info->reset = NULL;
}
Although I do wonder if a devm_reset_control_get_optional() helper would
be useful (this isn't the first time I've seen reset control added to
existing drivers).
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 1/4] iio: adc: rockchip_saradc: reset saradc controller before programming it Caesar Wang <wxt@rock-chips.com> - 2016-07-26 08:20 +0200
[PATCH 2/4] arm64: dts: rockchip: add the saradc for rk3399 Caesar Wang <wxt@rock-chips.com> - 2016-07-26 08:20 +0200
Re: [PATCH 1/4] iio: adc: rockchip_saradc: reset saradc controller before programming it John Keeping <john@metanate.com> - 2016-07-26 11:10 +0200
Re: [PATCH 1/4] iio: adc: rockchip_saradc: reset saradc controller before programming it Caesar Wang <wxt@rock-chips.com> - 2016-07-26 13:00 +0200
Re: [PATCH 1/4] iio: adc: rockchip_saradc: reset saradc controller before programming it John Keeping <john@metanate.com> - 2016-07-26 13:20 +0200
Re: [PATCH 1/4] iio: adc: rockchip_saradc: reset saradc controller before programming it Heiko Stübner <heiko@sntech.de> - 2016-07-26 11:20 +0200
csiph-web