mirror of
https://github.com/torvalds/linux.git
synced 2024-11-28 23:21:31 +00:00
mtd: spi-nor: don't overwrite errno in spi_nor_get_map_in_use()
Don't overwrite the errno from spi_nor_read_raw(). Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
This commit is contained in:
parent
c797bd81d1
commit
b9f07cc820
@ -2856,11 +2856,13 @@ static u8 spi_nor_smpt_read_dummy(const struct spi_nor *nor, const u32 settings)
|
|||||||
* @nor: pointer to a 'struct spi_nor'
|
* @nor: pointer to a 'struct spi_nor'
|
||||||
* @smpt: pointer to the sector map parameter table
|
* @smpt: pointer to the sector map parameter table
|
||||||
* @smpt_len: sector map parameter table length
|
* @smpt_len: sector map parameter table length
|
||||||
|
*
|
||||||
|
* Return: pointer to the map in use, ERR_PTR(-errno) otherwise.
|
||||||
*/
|
*/
|
||||||
static const u32 *spi_nor_get_map_in_use(struct spi_nor *nor, const u32 *smpt,
|
static const u32 *spi_nor_get_map_in_use(struct spi_nor *nor, const u32 *smpt,
|
||||||
u8 smpt_len)
|
u8 smpt_len)
|
||||||
{
|
{
|
||||||
const u32 *ret = NULL;
|
const u32 *ret;
|
||||||
u32 addr;
|
u32 addr;
|
||||||
int err;
|
int err;
|
||||||
u8 i;
|
u8 i;
|
||||||
@ -2884,8 +2886,10 @@ static const u32 *spi_nor_get_map_in_use(struct spi_nor *nor, const u32 *smpt,
|
|||||||
addr = smpt[i + 1];
|
addr = smpt[i + 1];
|
||||||
|
|
||||||
err = spi_nor_read_raw(nor, addr, 1, &data_byte);
|
err = spi_nor_read_raw(nor, addr, 1, &data_byte);
|
||||||
if (err)
|
if (err) {
|
||||||
|
ret = ERR_PTR(err);
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Build an index value that is used to select the Sector Map
|
* Build an index value that is used to select the Sector Map
|
||||||
@ -2901,6 +2905,7 @@ static const u32 *spi_nor_get_map_in_use(struct spi_nor *nor, const u32 *smpt,
|
|||||||
*
|
*
|
||||||
* Find the matching configuration map.
|
* Find the matching configuration map.
|
||||||
*/
|
*/
|
||||||
|
ret = ERR_PTR(-EINVAL);
|
||||||
while (i < smpt_len) {
|
while (i < smpt_len) {
|
||||||
if (SMPT_MAP_ID(smpt[i]) == map_id) {
|
if (SMPT_MAP_ID(smpt[i]) == map_id) {
|
||||||
ret = smpt + i;
|
ret = smpt + i;
|
||||||
@ -3041,8 +3046,8 @@ static int spi_nor_parse_smpt(struct spi_nor *nor,
|
|||||||
smpt[i] = le32_to_cpu(smpt[i]);
|
smpt[i] = le32_to_cpu(smpt[i]);
|
||||||
|
|
||||||
sector_map = spi_nor_get_map_in_use(nor, smpt, smpt_header->length);
|
sector_map = spi_nor_get_map_in_use(nor, smpt, smpt_header->length);
|
||||||
if (!sector_map) {
|
if (IS_ERR(sector_map)) {
|
||||||
ret = -EINVAL;
|
ret = PTR_ERR(sector_map);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user