* [PATCH] mtd: mchp23k256: propagate return value of spi_sync()
@ 2017-12-10 15:19 Antonio Borneo
2017-12-14 9:08 ` Andrew Lunn
0 siblings, 1 reply; 3+ messages in thread
From: Antonio Borneo @ 2017-12-10 15:19 UTC (permalink / raw)
To: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
Richard Weinberger, Cyrille Pitchen, Andrew Lunn, Chris Packham,
Rob Herring, linux-mtd
Cc: Antonio Borneo, linux-kernel
The call to spi_sync() can fail.
Check the return value and propagate it.
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
---
To: David Woodhouse <dwmw2@infradead.org>
To: Brian Norris <computersforpeace@gmail.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Marek Vasut <marek.vasut@gmail.com>
To: Richard Weinberger <richard@nod.at>
To: Cyrille Pitchen <cyrille.pitchen@atmel.com>
To: Andrew Lunn <andrew@lunn.ch>
To: Chris Packham <chris.packham@alliedtelesis.co.nz>
To: Rob Herring <robh@kernel.org>
To: linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: mchp23k256: propagate return value of spi_sync()
2017-12-10 15:19 [PATCH] mtd: mchp23k256: propagate return value of spi_sync() Antonio Borneo
@ 2017-12-14 9:08 ` Andrew Lunn
2017-12-18 16:22 ` Boris Brezillon
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2017-12-14 9:08 UTC (permalink / raw)
To: Antonio Borneo
Cc: David Woodhouse, Brian Norris, Boris Brezillon, Marek Vasut,
Richard Weinberger, Cyrille Pitchen, Chris Packham, Rob Herring,
linux-mtd, linux-kernel
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 <borneo.antonio@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: mchp23k256: propagate return value of spi_sync()
2017-12-14 9:08 ` Andrew Lunn
@ 2017-12-18 16:22 ` Boris Brezillon
0 siblings, 0 replies; 3+ messages in thread
From: Boris Brezillon @ 2017-12-18 16:22 UTC (permalink / raw)
To: Andrew Lunn
Cc: Antonio Borneo, Rob Herring, Richard Weinberger, linux-kernel,
Marek Vasut, Chris Packham, linux-mtd, Cyrille Pitchen,
Brian Norris, David Woodhouse
On Thu, 14 Dec 2017 10:08:24 +0100
Andrew Lunn <andrew@lunn.ch> 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 <borneo.antonio@gmail.com>
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Applied.
Thanks,
Boris
>
> Andrew
>
> ______________________________________________________
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-18 16:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-10 15:19 [PATCH] mtd: mchp23k256: propagate return value of spi_sync() Antonio Borneo
2017-12-14 9:08 ` Andrew Lunn
2017-12-18 16:22 ` Boris Brezillon
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).