linux-rtc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nur Hussein <hussein@unixcat.org>
To: a.zummo@towertech.it, alexandre.belloni@bootlin.com,
	linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Nur Hussein <hussein@unixcat.org>
Subject: [PATCH] Error checking for spi_setup during probe function added to rtc-m41t94 driver
Date: Sat,  4 Mar 2023 05:45:26 +0800	[thread overview]
Message-ID: <20230303214526.1831504-1-hussein@unixcat.org> (raw)

The m41t94_probe() function calls spi_setup() but does not check for an
error upon return. I have added this check, and returns the error and
sets the error message via dev_error to "spi_setup failed".

Signed-off-by: Nur Hussein <hussein@unixcat.org>
---
 drivers/rtc/rtc-m41t94.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-m41t94.c b/drivers/rtc/rtc-m41t94.c
index 6803b0273302..4bdee2336228 100644
--- a/drivers/rtc/rtc-m41t94.c
+++ b/drivers/rtc/rtc-m41t94.c
@@ -112,7 +112,12 @@ static int m41t94_probe(struct spi_device *spi)
 	int res;
 
 	spi->bits_per_word = 8;
-	spi_setup(spi);
+
+	res = spi_setup(spi);
+	if (res < 0) {
+		dev_err(&spi->dev, "spi setup failed.\n");
+		return res;
+	}
 
 	res = spi_w8r8(spi, M41T94_REG_SECONDS);
 	if (res < 0) {
-- 
2.34.1


                 reply	other threads:[~2023-03-03 21:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230303214526.1831504-1-hussein@unixcat.org \
    --to=hussein@unixcat.org \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    /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).