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