linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@linux-mips.org>
To: Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Matt Turner <mattst88@gmail.com>,
	linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] rtc: m41t80: Complete error propagation from SMBus calls
Date: Wed, 7 Nov 2018 02:39:51 +0000 (GMT)	[thread overview]
Message-ID: <alpine.LFD.2.21.1811070142240.20378@eddie.linux-mips.org> (raw)

Complement commit 85d77047c4ea ("drivers/rtc/rtc-m41t80.c: propagate 
error value from smbus functions") and correct the remaining places that 
fail to propagate the error code from SMBus calls.

Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
References: 85d77047c4ea ("drivers/rtc/rtc-m41t80.c: propagate error value from smbus functions")
---
Hi,

 I think this does not qualify for backporting, but please feel free to 
decide otherwise.

 This change I did verify at run time to the extent I was able to, but I 
didn't try to trigger artificial errors.  Also the M41T81, which is the 
device I've been using this driver with, does not have battery failure 
indication implemented, so I could not execute the procfs handling path 
(again without making some artificial changes).  These changes should be 
obvious regardless.

 I'll be posting further patches over the coming weeks, based on my 
original effort as archived here: <https://lkml.org/lkml/2008/5/12/385>,
<https://lore.kernel.org/patchwork/project/lkml/list/?series=73524&archive=both> 
However I have just realised they'll need another iteration before I post 
them.  So for now just these two obvious fixes.

 Please apply.

  Maciej
---
 drivers/rtc/rtc-m41t80.c |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

linux-rtc-m41t80-err.diff
Index: linux-20181008-swarm64-eb/drivers/rtc/rtc-m41t80.c
===================================================================
--- linux-20181008-swarm64-eb.orig/drivers/rtc/rtc-m41t80.c
+++ linux-20181008-swarm64-eb/drivers/rtc/rtc-m41t80.c
@@ -217,7 +217,7 @@ static int m41t80_rtc_read_time(struct d
 					    sizeof(buf), buf);
 	if (err < 0) {
 		dev_err(&client->dev, "Unable to read date\n");
-		return -EIO;
+		return err;
 	}
 
 	tm->tm_sec = bcd2bin(buf[M41T80_REG_SEC] & 0x7f);
@@ -274,10 +274,11 @@ static int m41t80_rtc_set_time(struct de
 	if (flags < 0)
 		return flags;
 
-	if (i2c_smbus_write_byte_data(client, M41T80_REG_FLAGS,
-				      flags & ~M41T80_FLAGS_OF)) {
+	err = i2c_smbus_write_byte_data(client, M41T80_REG_FLAGS,
+					flags & ~M41T80_FLAGS_OF);
+	if (err < 0) {
 		dev_err(&client->dev, "Unable to write flags register\n");
-		return -EIO;
+		return err;
 	}
 
 	return err;
@@ -287,10 +288,12 @@ static int m41t80_rtc_proc(struct device
 {
 	struct i2c_client *client = to_i2c_client(dev);
 	struct m41t80_data *clientdata = i2c_get_clientdata(client);
-	u8 reg;
+	int reg;
 
 	if (clientdata->features & M41T80_FEATURE_BL) {
 		reg = i2c_smbus_read_byte_data(client, M41T80_REG_FLAGS);
+		if (reg < 0)
+			return reg;
 		seq_printf(seq, "battery\t\t: %s\n",
 			   (reg & M41T80_FLAGS_BATT_LOW) ? "exhausted" : "ok");
 	}

             reply	other threads:[~2018-11-07  2:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-07  2:39 Maciej W. Rozycki [this message]
2018-11-14  9:48 ` [PATCH] rtc: m41t80: Complete error propagation from SMBus calls Alexandre Belloni
2018-11-14  9:57 ` Alexandre Belloni
2018-11-14 12:05   ` Maciej W. Rozycki
2018-11-14 12:20     ` Alexandre Belloni
2018-11-14 12:50       ` Maciej W. Rozycki

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=alpine.LFD.2.21.1811070142240.20378@eddie.linux-mips.org \
    --to=macro@linux-mips.org \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=mattst88@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 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).