[U-Boot] [PATCH 4/5] sf: sf_dataflash: Change the return value of jedec_probe to int
Haikun Wang
haikun.wang at freescale.com
Thu Jul 2 11:12:51 CEST 2015
Signed-off-by: Haikun Wang <haikun.wang at freescale.com>
---
drivers/mtd/spi/sf_dataflash.c | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/spi/sf_dataflash.c b/drivers/mtd/spi/sf_dataflash.c
index 6bf628b..648f3ca 100644
--- a/drivers/mtd/spi/sf_dataflash.c
+++ b/drivers/mtd/spi/sf_dataflash.c
@@ -512,7 +512,8 @@ static struct flash_info dataflash_data[] = {
{ "at45db642d", 0x1f2800, 8192, 1024, 10, SUP_POW2PS | IS_POW2PS},
};
-static struct flash_info *jedec_probe(struct spi_slave *spi, u8 *id)
+static int jedec_probe(struct spi_slave *spi, u8 *id,
+ struct flash_info **pp_info)
{
int tmp;
uint32_t jedec;
@@ -529,7 +530,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi, u8 *id)
* only Atmel sells these chips.
*/
if (id[0] != 0x1f)
- return NULL;
+ return -EINVAL;
jedec = id[0];
jedec = jedec << 8;
@@ -546,17 +547,22 @@ static struct flash_info *jedec_probe(struct spi_slave *spi, u8 *id)
if (status < 0) {
debug("SPI DataFlash: status error %d\n",
status);
- return NULL;
+ return -EIO;
}
if (status & 0x1) {
- if (info->flags & IS_POW2PS)
- return info;
+ if (info->flags & IS_POW2PS) {
+ *pp_info = info;
+ return 0;
+ }
} else {
- if (!(info->flags & IS_POW2PS))
- return info;
+ if (!(info->flags & IS_POW2PS)) {
+ *pp_info = info;
+ return 0;
+ }
}
} else {
- return info;
+ *pp_info = info;
+ return 0;
}
}
}
@@ -569,7 +575,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi, u8 *id)
printf("SPI DataFlash: Unsupported flash IDs: ");
printf("manuf %02x, jedec %04x, ext_jedec %04x\n",
id[0], jedec, id[3] << 8 | id[4]);
- return NULL;
+ return -EPROTONOSUPPORT;
}
/*
@@ -614,8 +620,8 @@ static int spi_dataflash_probe(struct udevice *dev)
* Both support the security register, though with different
* write procedures.
*/
- info = jedec_probe(spi, idcode);
- if (info != NULL)
+ ret = jedec_probe(spi, idcode, &info);
+ if (!ret)
add_dataflash(dev, info->name, info->nr_pages,
info->pagesize, info->pageoffset,
(info->flags & SUP_POW2PS) ? 'd' : 'c');
--
2.1.0.27.g96db324
More information about the U-Boot
mailing list