diff options
author | Andrei Warkentin <andreiw@motorola.com> | 2011-03-13 08:48:37 -0500 |
---|---|---|
committer | Ken Sumrall <ksumrall@android.com> | 2011-04-07 17:53:27 -0700 |
commit | 6345772d1ba598eb9cabf4e7cb700209e4ec6869 (patch) | |
tree | e6eb156aa28bf0012d53256226aa72796f88c56e /drivers/mmc | |
parent | 2c6f5267b56114e33fd61040bbbdc827e59458c4 (diff) |
MMC: Extends card quicks with MMC/SD quirks matching the CID.
The current mechanism is SDIO-only. This allows us to create
function-specific quirks, without creating messy Kconfig dependencies,
or polluting core/ with function-specific code.
Change-Id: If31a151c20a8a1fddb0774674821e9fdc4aa61a0
Signed-off-by: Andrei Warkentin <andreiw@motorola.com>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/core/core.h | 2 | ||||
-rw-r--r-- | drivers/mmc/core/quirks.c | 58 | ||||
-rw-r--r-- | drivers/mmc/core/sdio.c | 2 |
3 files changed, 23 insertions, 39 deletions
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h index cb686b976a34..9d9eef50e5d1 100644 --- a/drivers/mmc/core/core.h +++ b/drivers/mmc/core/core.h @@ -56,8 +56,6 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr); int mmc_attach_sd(struct mmc_host *host, u32 ocr); int mmc_attach_sdio(struct mmc_host *host, u32 ocr); -void mmc_fixup_device(struct mmc_card *card); - /* Module parameters */ extern int use_spi_crc; extern int mmc_assume_removable; diff --git a/drivers/mmc/core/quirks.c b/drivers/mmc/core/quirks.c index aa811fc5db10..981c11343f45 100644 --- a/drivers/mmc/core/quirks.c +++ b/drivers/mmc/core/quirks.c @@ -11,48 +11,34 @@ #include <linux/types.h> #include <linux/kernel.h> #include <linux/mmc/card.h> -#include <linux/mod_devicetable.h> - -/* - * The world is not perfect and supplies us with broken mmc/sdio devices. - * For at least a part of these bugs we need a work-around - */ - -struct mmc_fixup { - u16 vendor, device; /* You can use SDIO_ANY_ID here of course */ - void (*vendor_fixup)(struct mmc_card *card, int data); - int data; -}; - -/* - * This hook just adds a quirk unconditionnally - */ -static void __maybe_unused add_quirk(struct mmc_card *card, int data) -{ - card->quirks |= data; -} - -/* - * This hook just removes a quirk unconditionnally - */ -static void __maybe_unused remove_quirk(struct mmc_card *card, int data) -{ - card->quirks &= ~data; -} static const struct mmc_fixup mmc_fixup_methods[] = { - { 0 } + END_FIXUP }; -void mmc_fixup_device(struct mmc_card *card) +void mmc_fixup_device(struct mmc_card *card, + const struct mmc_fixup *table) { const struct mmc_fixup *f; - - for (f = mmc_fixup_methods; f->vendor_fixup; f++) { - if ((f->vendor == card->cis.vendor - || f->vendor == (u16) SDIO_ANY_ID) && - (f->device == card->cis.device - || f->device == (u16) SDIO_ANY_ID)) { + u64 rev = cid_rev_card(card); + + /* Non-core specific workarounds. */ + if (!table) + table = mmc_fixup_methods; + + for (f = table; f->vendor_fixup; f++) { + if ((f->manfid == CID_MANFID_ANY + || f->manfid == card->cid.manfid) && + (f->oemid == CID_OEMID_ANY + || f->oemid == card->cid.oemid) && + (f->name == CID_NAME_ANY + || !strcmp(f->name, card->cid.prod_name)) && + (f->cis_vendor == card->cis.vendor + || f->cis_vendor == (u16) SDIO_ANY_ID) && + (f->cis_device == card->cis.device + || f->cis_device == (u16) SDIO_ANY_ID) && + rev >= f->rev_start && + rev <= f->rev_end) { dev_dbg(&card->dev, "calling %pF\n", f->vendor_fixup); f->vendor_fixup(card, f->data); } diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index a99a33dd6f86..8cf313fd12c6 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -478,7 +478,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, card = oldcard; return 0; } - mmc_fixup_device(card); + mmc_fixup_device(card, NULL); if (card->type == MMC_TYPE_SD_COMBO) { err = mmc_sd_setup_card(host, card, oldcard != NULL); |