Skip to content

Commit

Permalink
mtd: mchp23k256: propagate return value of spi_sync()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Antonio Borneo authored and Boris Brezillon committed Dec 17, 2017
1 parent bf65710 commit db601f3
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions drivers/mtd/devices/mchp23k256.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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;
}

Expand All @@ -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);

Expand All @@ -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;
}

Expand Down

0 comments on commit db601f3

Please sign in to comment.