/*
* Get the flash and manufacturer id and lookup if the type is supported.
*/
-struct nand_flash_dev *nand_get_flash_type(struct nand_chip *chip, int *maf_id,
- int *dev_id,
- struct nand_flash_dev *type)
+int nand_get_flash_type(struct nand_chip *chip, int *maf_id,
+ int *dev_id, struct nand_flash_dev *type)
{
struct mtd_info *mtd = &chip->mtd;
const struct nand_manufacturer *manufacturer_desc;
*/
ret = nand_reset(chip, 0);
if (ret)
- return ERR_PTR(ret);
+ return ret;
/* Select the device */
chip->select_chip(mtd, 0);
/* Send the command for reading device ID */
ret = nand_readid_op(chip, 0, id_data, 2);
if (ret)
- return ERR_PTR(ret);
+ return ret;
/* Read manufacturer and device IDs */
*maf_id = id_data[0];
/* Read entire ID string */
ret = nand_readid_op(chip, 0, id_data, 8);
if (ret)
- return ERR_PTR(ret);
+ return ret;
if (id_data[0] != *maf_id || id_data[1] != *dev_id) {
pr_info("second ID read did not match %02x,%02x against %02x,%02x\n",
*maf_id, *dev_id, id_data[0], id_data[1]);
- return ERR_PTR(-ENODEV);
+ return -ENODEV;
}
chip->id.len = nand_id_len(id_data, ARRAY_SIZE(chip->id.data));
}
if (!type->name)
- return ERR_PTR(-ENODEV);
+ return -ENODEV;
if (!mtd->name)
mtd->name = type->name;
pr_warn("bus width %d instead %d bit\n",
(chip->options & NAND_BUSWIDTH_16) ? 16 : 8,
busw ? 16 : 8);
- return ERR_PTR(-EINVAL);
+ return -EINVAL;
}
nand_decode_bbm_options(mtd, chip);
ret = nand_manufacturer_init(chip);
if (ret)
- return ERR_PTR(ret);
+ return ret;
pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n",
*maf_id, *dev_id);
pr_info("%d MiB, %s, erase size: %d KiB, page size: %d, OOB size: %d\n",
(int)(chip->chipsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC",
mtd->erasesize >> 10, mtd->writesize, mtd->oobsize);
- return type;
+ return 0;
}
EXPORT_SYMBOL(nand_get_flash_type);
{
int i, nand_maf_id, nand_dev_id;
struct nand_chip *chip = mtd_to_nand(mtd);
- struct nand_flash_dev *type;
int ret;
if (ofnode_valid(chip->flash_node)) {
nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16);
/* Read the flash type */
- type = nand_get_flash_type(chip, &nand_maf_id,
+ ret = nand_get_flash_type(chip, &nand_maf_id,
&nand_dev_id, table);
- if (IS_ERR(type)) {
+ if (ret) {
if (!(chip->options & NAND_SCAN_SILENT_NODEV))
pr_warn("No NAND device found\n");
chip->select_chip(mtd, -1);
- return PTR_ERR(type);
+ return ret;
}
/* Initialize the ->data_interface field. */