Skip to contentSkip to conversation

Error checking for spi_setup during probe function added to rtc-m41t94 driver

PATCH New Nur Hussein 1 participant 1 message Mar 3, 2023 Real time clock (RTC)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Error checking for spi_setup during probe function added to rtc-m41t94 driver

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".

---
 drivers/rtc/rtc-m41t94.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/rtc/rtc-m41t94.c +6 -1
index 6803b0273302..4bdee2336228 100644
@@ -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) {
Signature · 1 line
2.34.1