[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171210151956.2053-1-borneo.antonio@gmail.com>
Date: Sun, 10 Dec 2017 16:19:56 +0100
From: Antonio Borneo <borneo.antonio@...il.com>
To: David Woodhouse <dwmw2@...radead.org>,
Brian Norris <computersforpeace@...il.com>,
Boris Brezillon <boris.brezillon@...e-electrons.com>,
Marek Vasut <marek.vasut@...il.com>,
Richard Weinberger <richard@....at>,
Cyrille Pitchen <cyrille.pitchen@...el.com>,
Andrew Lunn <andrew@...n.ch>,
Chris Packham <chris.packham@...iedtelesis.co.nz>,
Rob Herring <robh@...nel.org>, linux-mtd@...ts.infradead.org
Cc: Antonio Borneo <borneo.antonio@...il.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH] mtd: mchp23k256: propagate return value of spi_sync()
The call to spi_sync() can fail.
Check the return value and propagate it.
Signed-off-by: Antonio Borneo <borneo.antonio@...il.com>
---
To: David Woodhouse <dwmw2@...radead.org>
To: Brian Norris <computersforpeace@...il.com>
To: Boris Brezillon <boris.brezillon@...e-electrons.com>
To: Marek Vasut <marek.vasut@...il.com>
To: Richard Weinberger <richard@....at>
To: Cyrille Pitchen <cyrille.pitchen@...el.com>
To: Andrew Lunn <andrew@...n.ch>
To: Chris Packham <chris.packham@...iedtelesis.co.nz>
To: Rob Herring <robh@...nel.org>
To: linux-mtd@...ts.infradead.org
Cc: linux-kernel@...r.kernel.org
---
drivers/mtd/devices/mchp23k256.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c
index 787e9ec7..4c91c0e 100644
--- a/drivers/mtd/devices/mchp23k256.c
+++ b/drivers/mtd/devices/mchp23k256.c
@@ -68,6 +68,7 @@ static int mchp23k256_write(struct mtd_info *mtd, loff_t to, size_t len,
struct spi_transfer transfer[2] = {};
struct spi_message message;
unsigned char command[MAX_CMD_SIZE];
+ int ret;
spi_message_init(&message);
@@ -84,12 +85,16 @@ static int mchp23k256_write(struct mtd_info *mtd, loff_t to, size_t len,
mutex_lock(&flash->lock);
- spi_sync(flash->spi, &message);
+ ret = spi_sync(flash->spi, &message);
+
+ mutex_unlock(&flash->lock);
+
+ if (ret)
+ return ret;
if (retlen && message.actual_length > sizeof(command))
*retlen += message.actual_length - sizeof(command);
- mutex_unlock(&flash->lock);
return 0;
}
@@ -100,6 +105,7 @@ static int mchp23k256_read(struct mtd_info *mtd, loff_t from, size_t len,
struct spi_transfer transfer[2] = {};
struct spi_message message;
unsigned char command[MAX_CMD_SIZE];
+ int ret;
spi_message_init(&message);
@@ -117,12 +123,16 @@ static int mchp23k256_read(struct mtd_info *mtd, loff_t from, size_t len,
mutex_lock(&flash->lock);
- spi_sync(flash->spi, &message);
+ ret = spi_sync(flash->spi, &message);
+
+ mutex_unlock(&flash->lock);
+
+ if (ret)
+ return ret;
if (retlen && message.actual_length > sizeof(command))
*retlen += message.actual_length - sizeof(command);
- mutex_unlock(&flash->lock);
return 0;
}
--
2.7.4
Powered by blists - more mailing lists