From patchwork Mon Jan 28 22:04:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Ball X-Patchwork-Id: 2058591 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A0A783FD1A for ; Mon, 28 Jan 2013 22:05:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754767Ab3A1WFI (ORCPT ); Mon, 28 Jan 2013 17:05:08 -0500 Received: from void.printf.net ([89.145.121.20]:40898 "EHLO void.printf.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754552Ab3A1WFH convert rfc822-to-8bit (ORCPT ); Mon, 28 Jan 2013 17:05:07 -0500 Received: from 173-166-109-249-newengland.hfc.comcastbusiness.net ([173.166.109.249] helo=hydro) by void.printf.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1Tzwp6-00030s-6h; Mon, 28 Jan 2013 22:05:04 +0000 From: Chris Ball To: Alan Cox Cc: Girish K S , linux-mmc@vger.kernel.org Subject: Re: [PATCH] goldfish: emulated MMC device References: <20130121234339.19859.80987.stgit@bob.linux.org.uk> <20130122224701.5785e345@bob.linux.org.uk> Date: Mon, 28 Jan 2013 17:04:29 -0500 In-Reply-To: <20130122224701.5785e345@bob.linux.org.uk> (Alan Cox's message of "Tue, 22 Jan 2013 22:47:01 +0000") Message-ID: <87boc96k2a.fsf@laptop.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 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 --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ä + * Written by Tuukka Tikkanen and Juha Yrjölä * Misc hacks here and there by Tony Lindgren * 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: