121-mtd-print-full-chipid.patch 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. From fb177d5b534f263735dc6955703e3c711b950f35 Mon Sep 17 00:00:00 2001
  2. From: Michal Suchanek <hramrach@gmail.com>
  3. Date: Thu, 1 Jan 2015 00:57:46 +0100
  4. Subject: [PATCH] mtd: nand: print full chip ID
  5. Full chip ID is printed so user has data to paste from syslog in case
  6. of chip misidentification.
  7. Signed-off-by: Michal Suchanek <hramrach@gmail.com>
  8. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  9. ---
  10. drivers/mtd/nand/nand_base.c | 23 ++++++++++++++++++-----
  11. 1 file changed, 18 insertions(+), 5 deletions(-)
  12. --- a/drivers/mtd/nand/nand_base.c
  13. +++ b/drivers/mtd/nand/nand_base.c
  14. @@ -4247,7 +4247,7 @@ static inline bool is_full_id_nand(struc
  15. }
  16. static bool find_full_id_nand(struct mtd_info *mtd, struct nand_chip *chip,
  17. - struct nand_flash_dev *type, u8 *id_data, int *busw)
  18. + struct nand_flash_dev *type, const u8 *id_data, int *busw)
  19. {
  20. if (!strncmp(type->id, id_data, type->id_len)) {
  21. mtd->writesize = type->pagesize;
  22. @@ -4273,6 +4273,21 @@ static bool find_full_id_nand(struct mtd
  23. }
  24. /*
  25. + * Print full detail of chip ID read from chip.
  26. + */
  27. +static void print_nand_chip_info(int maf_id, int dev_id, u8 id_data[8])
  28. +{
  29. + u8 delim[8] = { [0 ... 7] = ',' };
  30. + pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n", maf_id, dev_id);
  31. + delim[7] = ' ';
  32. + delim[nand_id_len(id_data, 8) - 1] = ';';
  33. + /* This sucks. Kernel seems to insert newline after every other printk so format in one go. */
  34. + pr_info("chip id data: 0x%02x%c 0x%02x%c 0x%02x%c 0x%02x%c 0x%02x%c 0x%02x%c 0x%02x%c 0x%02x%c\n",
  35. + id_data[0], delim[0], id_data[1], delim[1], id_data[2], delim[2], id_data[3], delim[3],
  36. + id_data[4], delim[4], id_data[5], delim[5], id_data[6], delim[6], id_data[7], delim[7]);
  37. +}
  38. +
  39. +/*
  40. * Get the flash and manufacturer id and lookup if the type is supported.
  41. */
  42. static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
  43. @@ -4385,8 +4400,7 @@ ident_done:
  44. * Check, if buswidth is correct. Hardware drivers should set
  45. * chip correct!
  46. */
  47. - pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n",
  48. - *maf_id, *dev_id);
  49. + print_nand_chip_info(*maf_id, *dev_id, id_data);
  50. pr_info("%s %s\n", nand_manuf_ids[maf_idx].name, mtd->name);
  51. pr_warn("bus width %d instead %d bit\n",
  52. (chip->options & NAND_BUSWIDTH_16) ? 16 : 8,
  53. @@ -4424,8 +4438,7 @@ ident_done:
  54. return ERR_PTR(err);
  55. }
  56. - pr_info("device found, Manufacturer ID: 0x%02x, Chip ID: 0x%02x\n",
  57. - *maf_id, *dev_id);
  58. + print_nand_chip_info(*maf_id, *dev_id, id_data);
  59. if (chip->onfi_version)
  60. pr_info("%s %s\n", nand_manuf_ids[maf_idx].name,