From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com
Subject: [rtc-linux] Re: [PATCH] rtc: stmp3xxx: check for failure
Date: Fri, 15 Apr 2016 23:07:15 +0200 [thread overview]
Message-ID: <20160415210715.GF25196@piout.net> (raw)
In-Reply-To: <1460392435-23803-1-git-send-email-sudipm.mukherjee@gmail.com>
Hi,
On 11/04/2016 at 22:03:55 +0530, Sudip Mukherjee wrote :
> stmp3xxx_wdt_register() can fail as platform_device_alloc() or
> platform_device_add() can fail. Lets check for the return value from
> both platform_device_alloc() and platform_device_add() and return the
> error value accordingly which is now propagated from probe.
>
Well, this may have been intentional. The RTC doesn't need the watchdog
driver to be present to work correctly. However, I agree that failing
silently is not nice.
Did you have any particular issue? Maybe simply adding a dev_err() or
two would be fine.
> Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
> ---
> drivers/rtc/rtc-stmp3xxx.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
> index ca54d03..e02e827 100644
> --- a/drivers/rtc/rtc-stmp3xxx.c
> +++ b/drivers/rtc/rtc-stmp3xxx.c
> @@ -105,20 +105,22 @@ static struct stmp3xxx_wdt_pdata wdt_pdata = {
> .wdt_set_timeout = stmp3xxx_wdt_set_timeout,
> };
>
> -static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
> +static int stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
> {
> struct platform_device *wdt_pdev =
> platform_device_alloc("stmp3xxx_rtc_wdt", rtc_pdev->id);
>
> - if (wdt_pdev) {
> - wdt_pdev->dev.parent = &rtc_pdev->dev;
> - wdt_pdev->dev.platform_data = &wdt_pdata;
> - platform_device_add(wdt_pdev);
> - }
> + if (!wdt_pdev)
> + return -ENOMEM;
> +
> + wdt_pdev->dev.parent = &rtc_pdev->dev;
> + wdt_pdev->dev.platform_data = &wdt_pdata;
> + return platform_device_add(wdt_pdev);
> }
> #else
> -static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
> +static int stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
> {
> + return 0;
> }
> #endif /* CONFIG_STMP3XXX_RTC_WATCHDOG */
>
> @@ -357,8 +359,7 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
> return err;
> }
>
> - stmp3xxx_wdt_register(pdev);
> - return 0;
> + return stmp3xxx_wdt_register(pdev);
> }
>
> #ifdef CONFIG_PM_SLEEP
> --
> 1.9.1
>
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
linux-kernel@vger.kernel.org, rtc-linux@googlegroups.com
Subject: Re: [PATCH] rtc: stmp3xxx: check for failure
Date: Fri, 15 Apr 2016 23:07:15 +0200 [thread overview]
Message-ID: <20160415210715.GF25196@piout.net> (raw)
In-Reply-To: <1460392435-23803-1-git-send-email-sudipm.mukherjee@gmail.com>
Hi,
On 11/04/2016 at 22:03:55 +0530, Sudip Mukherjee wrote :
> stmp3xxx_wdt_register() can fail as platform_device_alloc() or
> platform_device_add() can fail. Lets check for the return value from
> both platform_device_alloc() and platform_device_add() and return the
> error value accordingly which is now propagated from probe.
>
Well, this may have been intentional. The RTC doesn't need the watchdog
driver to be present to work correctly. However, I agree that failing
silently is not nice.
Did you have any particular issue? Maybe simply adding a dev_err() or
two would be fine.
> Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
> ---
> drivers/rtc/rtc-stmp3xxx.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c
> index ca54d03..e02e827 100644
> --- a/drivers/rtc/rtc-stmp3xxx.c
> +++ b/drivers/rtc/rtc-stmp3xxx.c
> @@ -105,20 +105,22 @@ static struct stmp3xxx_wdt_pdata wdt_pdata = {
> .wdt_set_timeout = stmp3xxx_wdt_set_timeout,
> };
>
> -static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
> +static int stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
> {
> struct platform_device *wdt_pdev =
> platform_device_alloc("stmp3xxx_rtc_wdt", rtc_pdev->id);
>
> - if (wdt_pdev) {
> - wdt_pdev->dev.parent = &rtc_pdev->dev;
> - wdt_pdev->dev.platform_data = &wdt_pdata;
> - platform_device_add(wdt_pdev);
> - }
> + if (!wdt_pdev)
> + return -ENOMEM;
> +
> + wdt_pdev->dev.parent = &rtc_pdev->dev;
> + wdt_pdev->dev.platform_data = &wdt_pdata;
> + return platform_device_add(wdt_pdev);
> }
> #else
> -static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
> +static int stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
> {
> + return 0;
> }
> #endif /* CONFIG_STMP3XXX_RTC_WATCHDOG */
>
> @@ -357,8 +359,7 @@ static int stmp3xxx_rtc_probe(struct platform_device *pdev)
> return err;
> }
>
> - stmp3xxx_wdt_register(pdev);
> - return 0;
> + return stmp3xxx_wdt_register(pdev);
> }
>
> #ifdef CONFIG_PM_SLEEP
> --
> 1.9.1
>
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
next prev parent reply other threads:[~2016-04-15 21:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-11 16:33 [rtc-linux] [PATCH] rtc: stmp3xxx: check for failure Sudip Mukherjee
2016-04-11 16:33 ` Sudip Mukherjee
2016-04-15 21:07 ` Alexandre Belloni [this message]
2016-04-15 21:07 ` Alexandre Belloni
2016-04-30 18:39 ` [rtc-linux] " Sudip Mukherjee
2016-04-30 18:39 ` Sudip Mukherjee
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=20160415210715.GF25196@piout.net \
--to=alexandre.belloni@free-electrons.com \
--cc=a.zummo@towertech.it \
--cc=linux-kernel@vger.kernel.org \
--cc=rtc-linux@googlegroups.com \
--cc=sudipm.mukherjee@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.