From patchwork Sun Jan 9 16:26:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Tardy X-Patchwork-Id: 466721 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p09IVVWL012836 for ; Sun, 9 Jan 2011 18:31:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752471Ab1AISbl (ORCPT ); Sun, 9 Jan 2011 13:31:41 -0500 Received: from mail-ww0-f44.google.com ([74.125.82.44]:46044 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752386Ab1AISbk (ORCPT ); Sun, 9 Jan 2011 13:31:40 -0500 Received: by wwa36 with SMTP id 36so20054851wwa.1 for ; Sun, 09 Jan 2011 10:31:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:in-reply-to:references; bh=1y4++iA3/ou+5ONS8C9RQRLa3sU/j3wdnIGT891xmzM=; b=FEnvgnQQkSYLqsmaC/rh1gkvBYUHDLiou/WmyNKLcWGHnkN/tvD1i6UHfypx+vDRVK 8g/XRQdAO8J1d0NdejvRoFKOzx3PCZ8jnCOWy+EM+79jTWg+re3aARDUYWPz6PMbqlXl mKS9WQqahTRPijhHYWkIYJM5ht5+1MLFZtXEs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=HkQbN7ugy1Zk5BMNqfztA+qAitjaeirOuAOADMp6Ggjr8A6E4Cx/k9GngiK5i2IqqV fKWgnNrGRpvulMxVrfHH/X+sfwTmES4SQLaM9fm6TB2gy9g0KNrZr0kVwWDknIeJUFLI XmlmWzIsFv9fNCsJ43bVfLlncQV5gpH9WxG4M= Received: by 10.216.208.230 with SMTP id q80mr1006508weo.103.1294590483130; Sun, 09 Jan 2011 08:28:03 -0800 (PST) Received: from localhost.localdomain ([82.240.198.215]) by mx.google.com with ESMTPS id n18sm13581608wee.16.2011.01.09.08.28.01 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 09 Jan 2011 08:28:02 -0800 (PST) From: Pierre Tardy To: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Pierre Tardy Subject: [PATCH 1/3] mmc: add per device quirk placeholder Date: Sun, 9 Jan 2011 17:26:18 +0100 Message-Id: <6191610532f25d7cda435781ce9b83bfdb677b5a.1294588491.git.tardyp@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 09 Jan 2011 18:31:42 +0000 (UTC) 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 + * Inspired from pci fixup code: + * Copyright (c) 1999 Martin Mares + * + */ + +#include +#include +#include +#include + +/* + * 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 mmc_fixup_device(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); + } + } +} +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)