Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions drivers/mtd/spiflash/spi020_nand.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ static struct nand_flash_dev spinand_flash_ids[] = {
{"DS35Q1GA 1GiB 3.3V",
{ .id = {MFG_ID_DOSILICON, 0x71} },
SZ_2K, SZ_128, SZ_128K, 0, 2, 64 },
{ NULL }
};

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
Expand Down Expand Up @@ -673,18 +674,24 @@ static int drv_nand_read_id(struct drv_nand_dev_info *info, uint32_t *id)
pr_debug("id = 0x%02x 0x%02x 0x%02x 0x%02x\n",
card_id[0], card_id[1], card_id[2], card_id[3]);

for (i = 0; i < ARRAY_SIZE(spinand_flash_ids); i++) {
for (i = 0; spinand_flash_ids[i].name; i++) {
if ((card_id[0] == spinand_flash_ids[i].mfr_id) && \
(card_id[1] == spinand_flash_ids[i].dev_id)) {
id_count = spinand_flash_ids[i].id_len;
memset(card_id + id_count, 0, 4 - id_count);
break;
}
}
*id = card_id[0] | (card_id[1] << 8) | (card_id[2] << 16) | \
(card_id[3] << 24);

ret = E_OK;
if (spinand_flash_ids[i].name) {
*id = card_id[0] | (card_id[1] << 8) |
(card_id[2] << 16) | (card_id[3] << 24);
ret = E_OK;
} else {
dev_err(&info->pdev->dev,
"flash ID 0x%02x 0x%02x is not in the ID table\n",
card_id[0], card_id[1]);
ret = -ENODEV;
}
}

mutex_unlock(&info->lock);
Expand Down Expand Up @@ -1193,7 +1200,6 @@ static int spinand_probe(struct platform_device *pdev)
kfree(info->data_buff);

fail_free_mtd:
kfree(mtd);
return ret;
}

Expand Down
18 changes: 12 additions & 6 deletions drivers/mtd/spiflash/spinand.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ static struct nand_flash_dev spinand_flash_ids[] = {
{"F35SQA512M 512Mbit 3.3V",
{ .id = {MFG_ID_FORESEE, 0x70} },
SZ_2K, SZ_64, SZ_128K, 0, 2, 64 },
{ NULL }
};

#ifdef CONFIG_MTD_SPINAND_HWECC
Expand Down Expand Up @@ -839,7 +840,7 @@ static int drv_nand_read_id(struct drv_nand_dev_info *info, uint32_t *id)
pr_debug("id = 0x%02x 0x%02x 0x%02x 0x%02x\n",
card_id[0], card_id[1], card_id[2], card_id[3]);

for (i = 0; i < ARRAY_SIZE(spinand_flash_ids); i++) {
for (i = 0; spinand_flash_ids[i].name; i++) {
if ((card_id[0] == spinand_flash_ids[i].mfr_id) && \
(card_id[1] == spinand_flash_ids[i].dev_id)) {
id_count = spinand_flash_ids[i].id_len;
Expand All @@ -853,10 +854,16 @@ static int drv_nand_read_id(struct drv_nand_dev_info *info, uint32_t *id)
break;
}
}
*id = card_id[0] | (card_id[1] << 8) | (card_id[2] << 16) | \
(card_id[3] << 24);

ret = E_OK;
if (spinand_flash_ids[i].name) {
*id = card_id[0] | (card_id[1] << 8) |
(card_id[2] << 16) | (card_id[3] << 24);
ret = E_OK;
} else {
dev_err(&info->pdev->dev,
"flash ID 0x%02x 0x%02x is not in the ID table\n",
card_id[0], card_id[1]);
ret = -ENODEV;
}
}

mutex_unlock(&info->lock);
Expand Down Expand Up @@ -1445,7 +1452,6 @@ static int spinand_probe(struct platform_device *pdev)
kfree(info->data_buff);

fail_free_mtd:
kfree(mtd);
return ret;
}

Expand Down