summaryrefslogtreecommitdiff
path: root/drivers/mtd/devices/mchp23k256.c
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2017-12-10 18:19:56 +0300
committerBoris Brezillon <boris.brezillon@free-electrons.com>2017-12-17 11:10:14 +0300
commitdb601f3ad3f7e0e8acac230c658aa434f26e48cd (patch)
treeb48a76202457ff8c57c330e2f78af4158e21509b /drivers/mtd/devices/mchp23k256.c
parentbf6571057f0830ab5132be8b6045d2677baad281 (diff)
downloadlinux-db601f3ad3f7e0e8acac230c658aa434f26e48cd.tar.xz
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@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Diffstat (limited to 'drivers/mtd/devices/mchp23k256.c')
-rw-r--r--drivers/mtd/devices/mchp23k256.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/drivers/mtd/devices/mchp23k256.c b/drivers/mtd/devices/mchp23k256.c
index 8956b7dcc984..75f71d166fd6 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;
}