lkml.org 
[lkml]   [2017]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] rtc-da9063: Use common error handling code in da9063_rtc_probe()
Date
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 2 Nov 2017 09:45:46 +0100

* Add a jump target so that a specific error message is stored only once
at the end of this function implementation.

* Replace two calls of the function "dev_err" by goto statements.

* Adjust two condition checks.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/rtc/rtc-da9063.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/rtc/rtc-da9063.c b/drivers/rtc/rtc-da9063.c
index f85cae240f12..c5cbd40666aa 100644
--- a/drivers/rtc/rtc-da9063.c
+++ b/drivers/rtc/rtc-da9063.c
@@ -436,19 +436,15 @@ static int da9063_rtc_probe(struct platform_device *pdev)
config->rtc_alarm_secs_reg,
config->rtc_alarm_status_mask,
0);
- if (ret < 0) {
- dev_err(&pdev->dev, "Failed to access RTC alarm register\n");
- return ret;
- }
+ if (ret)
+ goto report_access_failure;

ret = regmap_update_bits(rtc->regmap,
config->rtc_alarm_secs_reg,
DA9063_ALARM_STATUS_ALARM,
DA9063_ALARM_STATUS_ALARM);
- if (ret < 0) {
- dev_err(&pdev->dev, "Failed to access RTC alarm register\n");
- return ret;
- }
+ if (ret)
+ goto report_access_failure;

ret = regmap_update_bits(rtc->regmap,
config->rtc_alarm_year_reg,
@@ -490,6 +486,10 @@ static int da9063_rtc_probe(struct platform_device *pdev)
irq_alarm, ret);

return ret;
+
+report_access_failure:
+ dev_err(&pdev->dev, "Failed to access RTC alarm register\n");
+ return ret;
}

static struct platform_driver da9063_rtc_driver = {
--
2.14.3
\
 
 \ /
  Last update: 2017-11-02 10:18    [W:0.203 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site