From patchwork Wed Jan 5 12:28:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Tardy X-Patchwork-Id: 453431 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 p05CS5s2030544 for ; Wed, 5 Jan 2011 12:28:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751926Ab1AEM2E (ORCPT ); Wed, 5 Jan 2011 07:28:04 -0500 Received: from mail-qw0-f46.google.com ([209.85.216.46]:44141 "EHLO mail-qw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751569Ab1AEM2E (ORCPT ); Wed, 5 Jan 2011 07:28:04 -0500 Received: by qwa26 with SMTP id 26so15590355qwa.19 for ; Wed, 05 Jan 2011 04:28:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=+N0AFBoBpO1jG0RLNKMJDX4P8bpknK2Msk457rUv/Kw=; b=oZYZPjtl7KuTRJgSrgvzhAI2WDSXG34QNqsAyj4gTFwXd5w0bbAQKhNhYCNzB4aJlP IQSRBqWa5bXcGTKyMQJ/cxO0RLuiUWDgNwrM3jzaKTMHOoZcPxgZih2Ni4GWDgSnUara luVXOnnYSF+lpIgS8ipGYxKWRYNcVjRK24YIQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=tWjR15hf6KMUz0S9yJ1mF4uKM75zqzUGhmUZwWmxaJ1lnBaoEmAgUvQwYsxGF9uRu/ hQyXAWWceqw8U7KsbcpSAaWbf/1R0HKWFDqgmKTrbVt3eyyxSeUltpG/ViQjw2lz/vNK 5JMTLGExN7vL8hmIgjAWOX4sAG2eNE9Rkck7Y= MIME-Version: 1.0 Received: by 10.229.251.209 with SMTP id mt17mr6725317qcb.66.1294230482468; Wed, 05 Jan 2011 04:28:02 -0800 (PST) Received: by 10.229.44.198 with HTTP; Wed, 5 Jan 2011 04:28:02 -0800 (PST) In-Reply-To: References: <1294175416-12358-1-git-send-email-ohad@wizery.com> <1294175416-12358-4-git-send-email-ohad@wizery.com> Date: Wed, 5 Jan 2011 13:28:02 +0100 Message-ID: Subject: Re: [PATCH 4/4] mmc: add MMC_QUIRK_NONSTD_FUNC_IF From: Pierre Tardy To: Ohad Ben-Cohen Cc: linux-mmc@vger.kernel.org, Chris Ball , "DE CESCO, Jonathan" 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.3 (demeter1.kernel.org [140.211.167.41]); Wed, 05 Jan 2011 12:28:05 +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 026c975..36d9a25 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, 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; diff --git a/drivers/mmc/core/quirks.c b/drivers/mmc/core/quirks.c new file mode 100644 index 0000000..d75e68c --- /dev/null +++ b/drivers/mmc/core/quirks.c @@ -0,0 +1,43 @@ +/* + * 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); +}; + +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); + } + } +} +EXPORT_SYMBOL(mmc_fixup_device); + diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index db18ef5..d290a1c 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -386,6 +386,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, */ if (host->ops->init_card) host->ops->init_card(host, card); + mmc_fixup_device(card); /* * For native busses: set card RCA and quit open drain mode. diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 5071eb1..3fe9db0 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -149,6 +149,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)