0356-mmc-Add-card_quirks-module-parameter-log-quirks.patch 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. From 07d3cfeff2b06f834132d3593740485c673fbe7d Mon Sep 17 00:00:00 2001
  2. From: Phil Elwell <phil@raspberrypi.org>
  3. Date: Fri, 20 May 2016 10:11:43 +0100
  4. Subject: [PATCH 356/381] mmc: Add card_quirks module parameter, log quirks
  5. Use mmc_block.card_quirks to override the quirks for all SD or MMC
  6. cards. The value is a bitfield using the bit positions defined in
  7. include/linux/mmc/card.h. If the module parameter is placed in the
  8. kernel command line (or bootargs) stored on the card then, assuming the
  9. device only has one SD card interface, the override effectively becomes
  10. card-specific.
  11. Signed-off-by: Phil Elwell <phil@raspberrypi.org>
  12. ---
  13. drivers/mmc/card/block.c | 28 +++++++++++++++++++++++++---
  14. 1 file changed, 25 insertions(+), 3 deletions(-)
  15. --- a/drivers/mmc/card/block.c
  16. +++ b/drivers/mmc/card/block.c
  17. @@ -137,6 +137,13 @@ enum {
  18. module_param(perdev_minors, int, 0444);
  19. MODULE_PARM_DESC(perdev_minors, "Minors numbers to allocate per device");
  20. +/*
  21. + * Allow quirks to be overridden for the current card
  22. + */
  23. +static char *card_quirks;
  24. +module_param(card_quirks, charp, 0644);
  25. +MODULE_PARM_DESC(card_quirks, "Force the use of the indicated quirks (a bitfield)");
  26. +
  27. static inline int mmc_blk_part_switch(struct mmc_card *card,
  28. struct mmc_blk_data *md);
  29. static int get_card_status(struct mmc_card *card, u32 *status, int retries);
  30. @@ -2570,6 +2577,7 @@ static int mmc_blk_probe(struct mmc_card
  31. {
  32. struct mmc_blk_data *md, *part_md;
  33. char cap_str[10];
  34. + char quirk_str[24];
  35. /*
  36. * Check that the card supports the command class(es) we need.
  37. @@ -2577,7 +2585,16 @@ static int mmc_blk_probe(struct mmc_card
  38. if (!(card->csd.cmdclass & CCC_BLOCK_READ))
  39. return -ENODEV;
  40. - mmc_fixup_device(card, blk_fixups);
  41. + if (card_quirks) {
  42. + unsigned long quirks;
  43. + if (kstrtoul(card_quirks, 0, &quirks) == 0)
  44. + card->quirks = (unsigned int)quirks;
  45. + else
  46. + pr_err("mmc_block: Invalid card_quirks parameter '%s'\n",
  47. + card_quirks);
  48. + }
  49. + else
  50. + mmc_fixup_device(card, blk_fixups);
  51. md = mmc_blk_alloc(card);
  52. if (IS_ERR(md))
  53. @@ -2585,9 +2602,14 @@ static int mmc_blk_probe(struct mmc_card
  54. string_get_size((u64)get_capacity(md->disk), 512, STRING_UNITS_2,
  55. cap_str, sizeof(cap_str));
  56. - pr_info("%s: %s %s %s %s\n",
  57. + if (card->quirks)
  58. + snprintf(quirk_str, sizeof(quirk_str),
  59. + " (quirks 0x%08x)", card->quirks);
  60. + else
  61. + quirk_str[0] = '\0';
  62. + pr_info("%s: %s %s %s%s%s\n",
  63. md->disk->disk_name, mmc_card_id(card), mmc_card_name(card),
  64. - cap_str, md->read_only ? "(ro)" : "");
  65. + cap_str, md->read_only ? " (ro)" : "", quirk_str);
  66. if (mmc_blk_alloc_parts(card, md))
  67. goto out;