From 6356a9d955e1898eadaa8cba9a5137b1787c0c7e Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Mon, 22 Oct 2007 18:16:16 +0200 Subject: at91_mci: Fix bad reference The flags parameter got removed in a previous commit, but some references were overlooked. Signed-off-by: Pierre Ossman --- drivers/mmc/host/au1xmmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c index c77fadc0dfa3..b2104d4f87af 100644 --- a/drivers/mmc/host/au1xmmc.c +++ b/drivers/mmc/host/au1xmmc.c @@ -212,12 +212,12 @@ static int au1xmmc_send_command(struct au1xmmc_host *host, int wait, } if (data) { - if (flags & MMC_DATA_READ) { + if (data->flags & MMC_DATA_READ) { if (data->blocks > 1) mmccmd |= SD_CMD_CT_4; else mmccmd |= SD_CMD_CT_2; - } else if (flags & MMC_DATA_WRITE) { + } else if (data->flags & MMC_DATA_WRITE) { if (data->blocks > 1) mmccmd |= SD_CMD_CT_3; else -- cgit v1.2.2 From 78e480731ab89e311ecdb455d04903cafbe163ca Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sat, 27 Oct 2007 14:14:23 +0200 Subject: mmc: fix cid and csd byte order MMC over SPI sends the CID and CSD registers as data, not responses, which means that the host driver won't do the necessary byte flipping for us. Signed-off-by: Pierre Ossman --- drivers/mmc/core/mmc_ops.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index bf4bc6adcfef..7471d49909b2 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c @@ -267,15 +267,26 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host, int mmc_send_csd(struct mmc_card *card, u32 *csd) { + int ret, i; + if (!mmc_host_is_spi(card->host)) return mmc_send_cxd_native(card->host, card->rca << 16, csd, MMC_SEND_CSD); - return mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd, 16); + ret = mmc_send_cxd_data(card, card->host, MMC_SEND_CSD, csd, 16); + if (ret) + return ret; + + for (i = 0;i < 4;i++) + csd[i] = be32_to_cpu(csd[i]); + + return 0; } int mmc_send_cid(struct mmc_host *host, u32 *cid) { + int ret, i; + if (!mmc_host_is_spi(host)) { if (!host->card) return -EINVAL; @@ -283,7 +294,14 @@ int mmc_send_cid(struct mmc_host *host, u32 *cid) cid, MMC_SEND_CID); } - return mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid, 16); + ret = mmc_send_cxd_data(NULL, host, MMC_SEND_CID, cid, 16); + if (ret) + return ret; + + for (i = 0;i < 4;i++) + cid[i] = be32_to_cpu(cid[i]); + + return 0; } int mmc_send_ext_csd(struct mmc_card *card, u8 *ext_csd) -- cgit v1.2.2 From 1fa8dd146f6bf57902602522c212040f8fa6fcd3 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Sat, 27 Oct 2007 14:41:04 +0200 Subject: mmc: use common byte swap macros Use the more generic byte swapping macros instead of the socket variants. Signed-off-by: Pierre Ossman --- drivers/mmc/core/sd_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/sd_ops.c b/drivers/mmc/core/sd_ops.c index ee4029a24efd..a6dafe62b992 100644 --- a/drivers/mmc/core/sd_ops.c +++ b/drivers/mmc/core/sd_ops.c @@ -294,8 +294,8 @@ int mmc_app_send_scr(struct mmc_card *card, u32 *scr) if (data.error) return data.error; - scr[0] = ntohl(scr[0]); - scr[1] = ntohl(scr[1]); + scr[0] = be32_to_cpu(scr[0]); + scr[1] = be32_to_cpu(scr[1]); return 0; } -- cgit v1.2.2 From 460cd0589df8aa9b89599905b13c2010db627012 Mon Sep 17 00:00:00 2001 From: David Brownell Date: Sat, 27 Oct 2007 14:47:20 +0200 Subject: mmc_spi: Fix mmc-over-spi regression Patch 49dce689ad4ef0fd1f970ef762168e4bd46f69a3 changed the sysfs data structures for SPI in a way which broke the MMC-over-SPI host driver. This patch fixes that regression by changing the scheme used to keep from knowingly trying to use a shared bus segment, and updates the adjacent comments slightly to better explain the issue. Signed-off-by: David Brownell Signed-off-by: Pierre Ossman --- drivers/mmc/host/mmc_spi.c | 52 +++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index 12c2d807c145..a6469218f194 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c @@ -1165,6 +1165,23 @@ mmc_spi_detect_irq(int irq, void *mmc) return IRQ_HANDLED; } +struct count_children { + unsigned n; + struct bus_type *bus; +}; + +static int maybe_count_child(struct device *dev, void *c) +{ + struct count_children *ccp = c; + + if (dev->bus == ccp->bus) { + if (ccp->n) + return -EBUSY; + ccp->n++; + } + return 0; +} + static int mmc_spi_probe(struct spi_device *spi) { void *ones; @@ -1188,33 +1205,30 @@ static int mmc_spi_probe(struct spi_device *spi) return status; } - /* We can use the bus safely iff nobody else will interfere with - * us. That is, either we have the experimental exclusive access - * primitives ... or else there's nobody to share it with. + /* We can use the bus safely iff nobody else will interfere with us. + * Most commands consist of one SPI message to issue a command, then + * several more to collect its response, then possibly more for data + * transfer. Clocking access to other devices during that period will + * corrupt the command execution. + * + * Until we have software primitives which guarantee non-interference, + * we'll aim for a hardware-level guarantee. + * + * REVISIT we can't guarantee another device won't be added later... */ if (spi->master->num_chipselect > 1) { - struct device *parent = spi->dev.parent; + struct count_children cc; - /* If there are multiple devices on this bus, we - * can't proceed. - */ - spin_lock(&parent->klist_children.k_lock); - if (parent->klist_children.k_list.next - != parent->klist_children.k_list.prev) - status = -EMLINK; - else - status = 0; - spin_unlock(&parent->klist_children.k_lock); + cc.n = 0; + cc.bus = spi->dev.bus; + status = device_for_each_child(spi->dev.parent, &cc, + maybe_count_child); if (status < 0) { dev_err(&spi->dev, "can't share SPI bus\n"); return status; } - /* REVISIT we can't guarantee another device won't - * be added later. It's uncommon though ... for now, - * work as if this is safe. - */ - dev_warn(&spi->dev, "ASSUMING unshared SPI bus!\n"); + dev_warn(&spi->dev, "ASSUMING SPI bus stays unshared!\n"); } /* We need a supply of ones to transmit. This is the only time -- cgit v1.2.2