diff mbox

goldfish: emulated MMC device

Message ID 87boc96k2a.fsf@laptop.org (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Ball Jan. 28, 2013, 10:04 p.m. UTC
Hi,

On Tue, Jan 22 2013, Alan Cox wrote:
>> does it support dt? i cannot see and table entry here? I think Nall ew
>> drivers added should be dt compatible.
>> there should be a of table entry here
>
> [..]
> Goldfish is an established platform used for most Android development
> work nowdays so we don't get to re-decide how it works just support it.

I agree that we should go ahead and merge this given that it's in
widespread use already.

Does anyone mind if I change the filename to
drivers/mmc/host/android-goldfish.c?  Kconfig will stay the same.

I've also made trivial style edits and converted from ISO-8859 to
UTF-8, as attached.

Queued in mmc-next for 3.9, thanks,

- Chris.
diff mbox

Patch

diff --git a/drivers/mmc/host/goldfish.c b/drivers/mmc/host/goldfish.c
index 5763f78..ef3aef0 100644
--- a/drivers/mmc/host/goldfish.c
+++ b/drivers/mmc/host/goldfish.c
@@ -4,7 +4,7 @@ 
  *
  *  based on omap.c driver, which was
  *  Copyright (C) 2004 Nokia Corporation
- *  Written by Tuukka Tikkanen and Juha Yrjölä<juha.yrjola@nokia.com>
+ *  Written by Tuukka Tikkanen and Juha Yrjölä <juha.yrjola@nokia.com>
  *  Misc hacks here and there by Tony Lindgren <tony@atomide.com>
  *  Other hacks (DMA, SD, etc) by David Brownell
  *
@@ -58,7 +58,6 @@ 
 #define GOLDFISH_MMC_READ(host, addr)   (readl(host->reg_base + addr))
 #define GOLDFISH_MMC_WRITE(host, addr, x)   (writel(x, host->reg_base + addr))
 
-
 enum {
 	/* status register */
 	MMC_INT_STATUS	        = 0x00,
@@ -140,12 +139,12 @@  goldfish_mmc_cover_is_open(struct goldfish_mmc_host *host)
 
 static ssize_t
 goldfish_mmc_show_cover_switch(struct device *dev,
-	struct device_attribute *attr, char *buf)
+			       struct device_attribute *attr, char *buf)
 {
 	struct goldfish_mmc_host *host = dev_get_drvdata(dev);
 
 	return sprintf(buf, "%s\n", goldfish_mmc_cover_is_open(host) ? "open" :
-			"closed");
+		       "closed");
 }
 
 static DEVICE_ATTR(cover_switch, S_IRUGO, goldfish_mmc_show_cover_switch, NULL);
@@ -208,7 +207,7 @@  goldfish_mmc_start_command(struct goldfish_mmc_host *host, struct mmc_command *c
 }
 
 static void goldfish_mmc_xfer_done(struct goldfish_mmc_host *host,
-							struct mmc_data *data)
+				   struct mmc_data *data)
 {
 	if (host->dma_in_use) {
 		enum dma_data_direction dma_data_dir;
@@ -228,13 +227,14 @@  static void goldfish_mmc_xfer_done(struct goldfish_mmc_host *host,
 		}
 		host->data->bytes_xfered += data->sg->length;
 		dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->sg_len,
-								dma_data_dir);
+			     dma_data_dir);
 	}
 
 	host->data = NULL;
 	host->sg_len = 0;
 
-	/* NOTE:  MMC layer will sometimes poll-wait CMD13 next, issuing
+	/*
+	 * NOTE:  MMC layer will sometimes poll-wait CMD13 next, issuing
 	 * dozens of requests until the card finishes writing data.
 	 * It'd be cheaper to just wait till an EOFB interrupt arrives...
 	 */
@@ -249,7 +249,7 @@  static void goldfish_mmc_xfer_done(struct goldfish_mmc_host *host,
 }
 
 static void goldfish_mmc_end_of_data(struct goldfish_mmc_host *host,
-							struct mmc_data *data)
+				     struct mmc_data *data)
 {
 	if (!host->dma_in_use) {
 		goldfish_mmc_xfer_done(host, data);
@@ -260,7 +260,7 @@  static void goldfish_mmc_end_of_data(struct goldfish_mmc_host *host,
 }
 
 static void goldfish_mmc_cmd_done(struct goldfish_mmc_host *host,
-						struct mmc_command *cmd)
+				  struct mmc_command *cmd)
 {
 	host->cmd = NULL;
 	if (cmd->flags & MMC_RSP_PRESENT) {
@@ -364,7 +364,7 @@  static irqreturn_t goldfish_mmc_irq(int irq, void *dev_id)
 }
 
 static void goldfish_mmc_prepare_data(struct goldfish_mmc_host *host,
-						struct mmc_request *req)
+				      struct mmc_request *req)
 {
 	struct mmc_data *data = req->data;
 	int block_size;
@@ -384,7 +384,8 @@  static void goldfish_mmc_prepare_data(struct goldfish_mmc_host *host,
 	GOLDFISH_MMC_WRITE(host, MMC_BLOCK_COUNT, data->blocks - 1);
 	GOLDFISH_MMC_WRITE(host, MMC_BLOCK_LENGTH, block_size - 1);
 
-	/* cope with calling layer confusion; it issues "single
+	/*
+	 * Cope with calling layer confusion; it issues "single
 	 * block" writes using multi-block scatterlists.
 	 */
 	sg_len = (data->blocks == 1) ? 1 : data->sg_len;
@@ -395,13 +396,15 @@  static void goldfish_mmc_prepare_data(struct goldfish_mmc_host *host,
 		dma_data_dir = DMA_FROM_DEVICE;
 
 	host->sg_len = dma_map_sg(mmc_dev(host->mmc), data->sg,
-				sg_len, dma_data_dir);
+				  sg_len, dma_data_dir);
 	host->dma_done = 0;
 	host->dma_in_use = 1;
 
 	if (dma_data_dir == DMA_TO_DEVICE) {
-		/* we don't really have DMA, so we need to copy to our
-		   platform driver buffer */
+		/*
+		 * We don't really have DMA, so we need to copy to our
+		 * platform driver buffer
+		 */
 		const uint8_t *src = (uint8_t *)sg_virt(data->sg);
 		memcpy(host->virt_base, src, data->sg->length);
 	}
@@ -417,10 +420,12 @@  static void goldfish_mmc_request(struct mmc_host *mmc, struct mmc_request *req)
 	goldfish_mmc_prepare_data(host, req);
 	goldfish_mmc_start_command(host, req->cmd);
 
-	/* this is to avoid accidentally being detected as an SDIO card
-	   in mmc_attach_sdio() */
+	/*
+	 * This is to avoid accidentally being detected as an SDIO card
+	 * in mmc_attach_sdio().
+	 */
 	if (req->cmd->opcode == SD_IO_SEND_OP_COND &&
-		req->cmd->flags == (MMC_RSP_SPI_R4 | MMC_RSP_R4 | MMC_CMD_BCR))
+	    req->cmd->flags == (MMC_RSP_SPI_R4 | MMC_RSP_R4 | MMC_CMD_BCR))
 		req->cmd->error = -EINVAL;
 }
 
@@ -477,7 +482,7 @@  static int goldfish_mmc_probe(struct platform_device *pdev)
 		goto ioremap_failed;
 	}
 	host->virt_base = dma_alloc_coherent(&pdev->dev, BUFFER_SIZE,
-							&buf_addr, GFP_KERNEL);
+					     &buf_addr, GFP_KERNEL);
 
 	if (host->virt_base == 0) {
 		ret = -ENOMEM;
@@ -507,7 +512,6 @@  static int goldfish_mmc_probe(struct platform_device *pdev)
 	ret = request_irq(host->irq, goldfish_mmc_irq, 0, DRIVER_NAME, host);
 	if (ret) {
 		dev_err(&pdev->dev, "Failed IRQ Adding goldfish MMC\n");
-
 		goto err_request_irq_failed;
 	}
 
@@ -517,19 +521,19 @@  static int goldfish_mmc_probe(struct platform_device *pdev)
 	ret = device_create_file(&pdev->dev, &dev_attr_cover_switch);
 	if (ret)
 		dev_warn(mmc_dev(host->mmc),
-				"Unable to create sysfs attributes\n");
+			 "Unable to create sysfs attributes\n");
 
 	GOLDFISH_MMC_WRITE(host, MMC_SET_BUFFER, host->phys_base);
 	GOLDFISH_MMC_WRITE(host, MMC_INT_ENABLE,
-		MMC_STAT_END_OF_CMD | MMC_STAT_END_OF_DATA |
-		MMC_STAT_STATE_CHANGE | MMC_STAT_CMD_TIMEOUT);
+			   MMC_STAT_END_OF_CMD | MMC_STAT_END_OF_DATA |
+			   MMC_STAT_STATE_CHANGE | MMC_STAT_CMD_TIMEOUT);
 
 	mmc_add_host(mmc);
 	return 0;
 
 err_request_irq_failed:
 	dma_free_coherent(&pdev->dev, BUFFER_SIZE, host->virt_base,
-							host->phys_base);
+			  host->phys_base);
 dma_alloc_failed:
 	iounmap(host->reg_base);
 ioremap_failed: