2017-12-10 15:20:39

by Antonio Borneo

[permalink] [raw]
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 <[email protected]>
---
To: David Woodhouse <[email protected]>
To: Brian Norris <[email protected]>
To: Boris Brezillon <[email protected]>
To: Marek Vasut <[email protected]>
To: Richard Weinberger <[email protected]>
To: Cyrille Pitchen <[email protected]>
To: Andrew Lunn <[email protected]>
To: Chris Packham <[email protected]>
To: Rob Herring <[email protected]>
To: [email protected]
Cc: [email protected]
---
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


2017-12-14 09:08:57

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH] mtd: mchp23k256: propagate return value of spi_sync()

On Sun, Dec 10, 2017 at 04:19:56PM +0100, Antonio Borneo wrote:
> The call to spi_sync() can fail.
> Check the return value and propagate it.
>
> Signed-off-by: Antonio Borneo <[email protected]>

Reviewed-by: Andrew Lunn <[email protected]>

Andrew

2017-12-18 16:22:18

by Boris Brezillon

[permalink] [raw]
Subject: Re: [PATCH] mtd: mchp23k256: propagate return value of spi_sync()

On Thu, 14 Dec 2017 10:08:24 +0100
Andrew Lunn <[email protected]> wrote:

> On Sun, Dec 10, 2017 at 04:19:56PM +0100, Antonio Borneo wrote:
> > The call to spi_sync() can fail.
> > Check the return value and propagate it.
> >
> > Signed-off-by: Antonio Borneo <[email protected]>
>
> Reviewed-by: Andrew Lunn <[email protected]>

Applied.

Thanks,

Boris

>
> Andrew
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/