|
@@ -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_transfer transfer[2] = {};
|
|
struct spi_message message;
|
|
struct spi_message message;
|
|
unsigned char command[MAX_CMD_SIZE];
|
|
unsigned char command[MAX_CMD_SIZE];
|
|
|
|
+ int ret;
|
|
|
|
|
|
spi_message_init(&message);
|
|
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);
|
|
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))
|
|
if (retlen && message.actual_length > sizeof(command))
|
|
*retlen += message.actual_length - sizeof(command);
|
|
*retlen += message.actual_length - sizeof(command);
|
|
|
|
|
|
- mutex_unlock(&flash->lock);
|
|
|
|
return 0;
|
|
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_transfer transfer[2] = {};
|
|
struct spi_message message;
|
|
struct spi_message message;
|
|
unsigned char command[MAX_CMD_SIZE];
|
|
unsigned char command[MAX_CMD_SIZE];
|
|
|
|
+ int ret;
|
|
|
|
|
|
spi_message_init(&message);
|
|
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);
|
|
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))
|
|
if (retlen && message.actual_length > sizeof(command))
|
|
*retlen += message.actual_length - sizeof(command);
|
|
*retlen += message.actual_length - sizeof(command);
|
|
|
|
|
|
- mutex_unlock(&flash->lock);
|
|
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|