From patchwork Wed Oct 26 08:45:27 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Nilsson XK X-Patchwork-Id: 4823 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E29C423E0C for ; Wed, 26 Oct 2011 08:56:35 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id C77C9A18B8E for ; Wed, 26 Oct 2011 08:56:35 +0000 (UTC) Received: by faan26 with SMTP id n26so1879894faa.11 for ; Wed, 26 Oct 2011 01:56:35 -0700 (PDT) Received: by 10.223.17.3 with SMTP id q3mr57673999faa.28.1319619395525; Wed, 26 Oct 2011 01:56:35 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.1.71 with SMTP id 7cs5501lak; Wed, 26 Oct 2011 01:56:35 -0700 (PDT) Received: by 10.213.108.73 with SMTP id e9mr1397591ebp.102.1319619395006; Wed, 26 Oct 2011 01:56:35 -0700 (PDT) Received: from eu1sys200aog114.obsmtp.com (eu1sys200aog114.obsmtp.com. [207.126.144.137]) by mx.google.com with SMTP id u8si218110eeb.169.2011.10.26.01.56.31 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Oct 2011 01:56:34 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.137 is neither permitted nor denied by best guess record for domain of stefan.xk.nilsson@stericsson.com) client-ip=207.126.144.137; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.137 is neither permitted nor denied by best guess record for domain of stefan.xk.nilsson@stericsson.com) smtp.mail=stefan.xk.nilsson@stericsson.com Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob114.postini.com ([207.126.147.11]) with SMTP; Wed, 26 Oct 2011 08:56:34 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 945D9162; Wed, 26 Oct 2011 08:56:18 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id 583F16B; Wed, 26 Oct 2011 08:48:16 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 2ADD2A8065; Wed, 26 Oct 2011 10:48:12 +0200 (CEST) Received: from localhost.localdomain (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 26 Oct 2011 10:48:15 +0200 From: Stefan Nilsson XK To: , Cc: Russell King , Ulf Hansson , Stefan Nilsson XK Subject: [PATCH] mmc: mmci: Fix PIO read for small SDIO packets Date: Wed, 26 Oct 2011 10:45:27 +0200 Message-ID: <1319618727-16969-1-git-send-email-stefan.xk.nilsson@stericsson.com> X-Mailer: git-send-email 1.7.7 MIME-Version: 1.0 Corrects a bug in MMCI host driver which silently causes small reads (< 4 bytes as only used in SDIO) from PL-18X to fail. Signed-off-by: Stefan Nilsson XK Signed-off-by: Ulf Hansson Acked-by: Linus Walleij --- drivers/mmc/host/mmci.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 56e9a41..5c3a517 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c @@ -776,7 +776,18 @@ static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int rema if (count <= 0) break; - readsl(base + MMCIFIFO, ptr, count >> 2); + /* + * SDIO especially may want to send something that is + * not divisible by 4 (as opposed to card sectors + * etc). Therefore make sure to to always read the last bytes + * while only doing full 32-bit reads towards the FIFO. + */ + if (count < 4) { + unsigned char buf[4]; + readsl(base + MMCIFIFO, buf, 1); + memcpy(ptr, buf, count); + } else + readsl(base + MMCIFIFO, ptr, count >> 2); ptr += count; remain -= count;