summaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/quirks.c
diff options
context:
space:
mode:
authorPierre Tardy <pierre.tardy@intel.com>2011-02-06 19:03:46 +0100
committerChris Ball <cjb@laptop.org>2011-03-15 13:48:33 -0400
commit57f0adc7eaaf4315d568e72069dbe48aa7e20995 (patch)
tree233c66fd4f21b977f532702ce9427023b2e53e09 /drivers/mmc/core/quirks.c
parent66c036e0142fed2484d58a2d3c7a4d21ba32b6a6 (diff)
downloadop-kernel-dev-57f0adc7eaaf4315d568e72069dbe48aa7e20995.zip
op-kernel-dev-57f0adc7eaaf4315d568e72069dbe48aa7e20995.tar.gz
mmc: add per device quirk placeholder
Some cards have quirks valid for every platforms using current platform quirk hooks leads to a lot of code and debug duplication. So we inspire a bit from what exists in PCI subsystem and do our own per vendorid/deviceid quirk. We still drop the complexity of the pci quirk system (with special section tables, and so on). That can be added later if needed. Signed-off-by: Pierre Tardy <pierre.tardy@intel.com> Acked-by: Linus Walleij <linus.walleij@stericsson.com> Acked-by: Ohad Ben-Cohen <ohad@wizery.com> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/core/quirks.c')
-rw-r--r--drivers/mmc/core/quirks.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/drivers/mmc/core/quirks.c b/drivers/mmc/core/quirks.c
new file mode 100644
index 0000000..e18cb49
--- /dev/null
+++ b/drivers/mmc/core/quirks.c
@@ -0,0 +1,61 @@
+/*
+ * This file contains work-arounds for many known sdio hardware
+ * bugs.
+ *
+ * Copyright (c) 2011 Pierre Tardy <tardyp@gmail.com>
+ * Inspired from pci fixup code:
+ * Copyright (c) 1999 Martin Mares <mj@ucw.cz>
+ *
+ */
+
+#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 }
+};
+
+void mmc_fixup_device(struct mmc_card *card)
+{
+ 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)) {
+ dev_dbg(&card->dev, "calling %pF\n", f->vendor_fixup);
+ f->vendor_fixup(card, f->data);
+ }
+ }
+}
+EXPORT_SYMBOL(mmc_fixup_device);
OpenPOWER on IntegriCloud