rtc: stmp3xxx: print message on error
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Sat, 30 Apr 2016 19:11:30 +0000 (20:11 +0100)
committerAlexandre Belloni <alexandre.belloni@free-electrons.com>
Fri, 20 May 2016 10:33:51 +0000 (12:33 +0200)
stmp3xxx_wdt_register() can fail as platform_device_alloc() or
platform_device_add() can fail. But when it fails it failed silently.
Lets print out an error message on failure so that user will atlest
know that there was some error.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
drivers/rtc/rtc-stmp3xxx.c

index ca54d039da3154b10b7b1a0c1356f8a2d28901ab..e6aaaa52e7fe165383806a76ead6311df65e2433 100644 (file)
@@ -107,14 +107,19 @@ static struct stmp3xxx_wdt_pdata wdt_pdata = {
 
 static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev)
 {
+       int rc = -1;
        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);
+               rc = platform_device_add(wdt_pdev);
        }
+
+       if (rc)
+               dev_err(&rtc_pdev->dev,
+                       "failed to register stmp3xxx_rtc_wdt\n");
 }
 #else
 static void stmp3xxx_wdt_register(struct platform_device *rtc_pdev)