Commit 4722c0e9 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Boris Brezillon

mtd: nand: change return type of nand_get_flash_type() to int

Since commit d1e1f4e4 ("mtd: nand: add support for reading ONFI
parameters from NAND device"), the returned "type" is never used in
nand_scan_ident().

Make nand_get_flash_type() simply return an integer value in order
to avoid unnecessary ERR_PTR/PTR_ERR dance.
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarBoris Brezillon <boris.brezillon@free-electrons.com>
parent a1a26170
...@@ -3999,10 +3999,9 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip, ...@@ -3999,10 +3999,9 @@ static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip,
/* /*
* Get the flash and manufacturer id and lookup if the type is supported. * Get the flash and manufacturer id and lookup if the type is supported.
*/ */
static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, static int nand_get_flash_type(struct mtd_info *mtd, struct nand_chip *chip,
struct nand_chip *chip, int *maf_id, int *dev_id,
int *maf_id, int *dev_id, struct nand_flash_dev *type)
struct nand_flash_dev *type)
{ {
int busw; int busw;
int i, maf_idx; int i, maf_idx;
...@@ -4040,7 +4039,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, ...@@ -4040,7 +4039,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
if (id_data[0] != *maf_id || id_data[1] != *dev_id) { 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", pr_info("second ID read did not match %02x,%02x against %02x,%02x\n",
*maf_id, *dev_id, id_data[0], id_data[1]); *maf_id, *dev_id, id_data[0], id_data[1]);
return ERR_PTR(-ENODEV); return -ENODEV;
} }
if (!type) if (!type)
...@@ -4067,7 +4066,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, ...@@ -4067,7 +4066,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
} }
if (!type->name) if (!type->name)
return ERR_PTR(-ENODEV); return -ENODEV;
if (!mtd->name) if (!mtd->name)
mtd->name = type->name; mtd->name = type->name;
...@@ -4112,7 +4111,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, ...@@ -4112,7 +4111,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
pr_warn("bus width %d instead %d bit\n", pr_warn("bus width %d instead %d bit\n",
(chip->options & NAND_BUSWIDTH_16) ? 16 : 8, (chip->options & NAND_BUSWIDTH_16) ? 16 : 8,
busw ? 16 : 8); busw ? 16 : 8);
return ERR_PTR(-EINVAL); return -EINVAL;
} }
nand_decode_bbm_options(mtd, chip, id_data); nand_decode_bbm_options(mtd, chip, id_data);
...@@ -4154,7 +4153,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd, ...@@ -4154,7 +4153,7 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
pr_info("%d MiB, %s, erase size: %d KiB, page size: %d, OOB size: %d\n", 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", (int)(chip->chipsize >> 20), nand_is_slc(chip) ? "SLC" : "MLC",
mtd->erasesize >> 10, mtd->writesize, mtd->oobsize); mtd->erasesize >> 10, mtd->writesize, mtd->oobsize);
return type; return 0;
} }
static const char * const nand_ecc_modes[] = { static const char * const nand_ecc_modes[] = {
...@@ -4320,7 +4319,6 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, ...@@ -4320,7 +4319,6 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips,
{ {
int i, nand_maf_id, nand_dev_id; int i, nand_maf_id, nand_dev_id;
struct nand_chip *chip = mtd_to_nand(mtd); struct nand_chip *chip = mtd_to_nand(mtd);
struct nand_flash_dev *type;
int ret; int ret;
ret = nand_dt_init(chip); ret = nand_dt_init(chip);
...@@ -4343,14 +4341,12 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips, ...@@ -4343,14 +4341,12 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips,
nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16); nand_set_defaults(chip, chip->options & NAND_BUSWIDTH_16);
/* Read the flash type */ /* Read the flash type */
type = nand_get_flash_type(mtd, chip, &nand_maf_id, ret = nand_get_flash_type(mtd, chip, &nand_maf_id, &nand_dev_id, table);
&nand_dev_id, table); if (ret) {
if (IS_ERR(type)) {
if (!(chip->options & NAND_SCAN_SILENT_NODEV)) if (!(chip->options & NAND_SCAN_SILENT_NODEV))
pr_warn("No NAND device found\n"); pr_warn("No NAND device found\n");
chip->select_chip(mtd, -1); chip->select_chip(mtd, -1);
return PTR_ERR(type); return ret;
} }
ret = nand_init_data_interface(chip); ret = nand_init_data_interface(chip);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment