LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Philip Rakity <prakity@marvell.com>
To: Pierre Tardy <tardyp@gmail.com>
Cc: "linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Pierre Tardy <pierre.tardy@intel.com>
Subject: Re: [PATCH 1/3] mmc: add per device quirk placeholder
Date: Mon, 10 Jan 2011 08:04:57 -0800	[thread overview]
Message-ID: <77BC89B5-DFC2-4908-8875-59BCD00DC10F@marvell.com> (raw)
In-Reply-To: <6191610532f25d7cda435781ce9b83bfdb677b5a.1294588491.git.tardyp@gmail.com>


On Jan 9, 2011, at 8:26 AM, Pierre Tardy wrote:

> From: Pierre Tardy <pierre.tardy@intel.com>
> 
> 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>
> ---
> drivers/mmc/core/Makefile |    3 +-
> drivers/mmc/core/core.h   |    2 +
> drivers/mmc/core/quirks.c |   54 +++++++++++++++++++++++++++++++++++++++++++++
> drivers/mmc/core/sdio.c   |    1 +
> include/linux/mmc/card.h  |    2 +
> 5 files changed, 61 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mmc/core/Makefile b/drivers/mmc/core/Makefile
> index 86b4791..6395019 100644
> --- a/drivers/mmc/core/Makefile
> +++ b/drivers/mmc/core/Makefile
> @@ -6,6 +6,7 @@ obj-$(CONFIG_MMC)		+= mmc_core.o
> mmc_core-y			:= core.o bus.o host.o \
> 				   mmc.o mmc_ops.o sd.o sd_ops.o \
> 				   sdio.o sdio_ops.o sdio_bus.o \
> -				   sdio_cis.o sdio_io.o sdio_irq.o
> +				   sdio_cis.o sdio_io.o sdio_irq.o \
> +				   quirks.o
> 
> mmc_core-$(CONFIG_DEBUG_FS)	+= debugfs.o
> diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
> index ca1fdde..20b1c08 100644
> --- a/drivers/mmc/core/core.h
> +++ b/drivers/mmc/core/core.h
> @@ -61,6 +61,8 @@ int mmc_attach_mmc(struct mmc_host *host);
> int mmc_attach_sd(struct mmc_host *host);
> int mmc_attach_sdio(struct mmc_host *host);
> 
> +void mmc_fixup_device(struct mmc_card *card);
> +
> /* Module parameters */
> extern int use_spi_crc;
> 
> diff --git a/drivers/mmc/core/quirks.c b/drivers/mmc/core/quirks.c
> new file mode 100644
> index 0000000..d8a5fec
> --- /dev/null
> +++ b/drivers/mmc/core/quirks.c
> @@ -0,0 +1,54 @@
> +/*
> + *  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 (*hook)(struct mmc_card *card, int data);
> +	int data;
> +};
> +
> +/*
> + * This hook just adds a quirk unconditionnally
> + */
> +static void add_quirk(struct mmc_card *card, int data)
> +{
> +	card->quirks |= data;
> +}
> +
> +static const struct mmc_fixup mmc_fixup_methods[] = {
> +	{ 0 }
> +};
> +
> +void  (struct mmc_card *card)
> +{
> +	const struct mmc_fixup *f;
> +
> +	for (f = mmc_fixup_methods; f->hook; 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->hook);
> +			f->hook(card, f->data);


hook is not a very nice name ---  something more meaningful:  vendor_fixup  ?

> +		}
> +	}
> +}
> +EXPORT_SYMBOL(mmc_fixup_device);
> +
> diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c
> index 5c4a54d..617e9ad 100644
> --- a/drivers/mmc/core/sdio.c
> +++ b/drivers/mmc/core/sdio.c
> @@ -458,6 +458,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr,
> 
> 		card = oldcard;
> 	}
> +	mmc_fixup_device(card);
> 
> 	if (card->type == MMC_TYPE_SD_COMBO) {
> 		err = mmc_sd_setup_card(host, card, oldcard != NULL);
> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
> index 8ce0827..a498d53 100644
> --- a/include/linux/mmc/card.h
> +++ b/include/linux/mmc/card.h
> @@ -148,6 +148,8 @@ struct mmc_card {
> 	struct dentry		*debugfs_root;
> };
> 
> +void mmc_fixup_device(struct mmc_card *dev);
> +
> #define mmc_card_mmc(c)		((c)->type == MMC_TYPE_MMC)
> #define mmc_card_sd(c)		((c)->type == MMC_TYPE_SD)
> #define mmc_card_sdio(c)	((c)->type == MMC_TYPE_SDIO)
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


  reply	other threads:[~2011-01-10 16:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-09 16:26 [PATCH 0/3] mmc: add quirks.c file and CLK_GATING users Pierre Tardy
2011-01-09 16:26 ` [PATCH 1/3] mmc: add per device quirk placeholder Pierre Tardy
2011-01-10 16:04   ` Philip Rakity [this message]
2011-01-10 17:02     ` Pierre Tardy
2011-01-22 22:55   ` Ohad Ben-Cohen
2011-01-09 16:26 ` [PATCH 2/3] mmc: add MMC_QUIRK_BROKEN_CLK_GATING Pierre Tardy
2011-01-10 15:58   ` Philip Rakity
2011-01-10 16:57     ` Pierre Tardy
2011-01-10 17:18       ` Philip Rakity
2011-01-09 16:26 ` [PATCH 3/3] mmc: remove anti clock gating quirk for wl1271 Pierre Tardy
2011-01-20  4:14   ` Chris Ball
2011-01-20  7:17     ` Pierre Tardy
2011-01-22 14:47       ` Chris Ball
2011-01-10 22:01 ` [PATCH 0/3] mmc: add quirks.c file and CLK_GATING users Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=77BC89B5-DFC2-4908-8875-59BCD00DC10F@marvell.com \
    --to=prakity@marvell.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=pierre.tardy@intel.com \
    --cc=tardyp@gmail.com \
    --subject='Re: [PATCH 1/3] mmc: add per device quirk placeholder' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).