From patchwork Mon Mar 25 09:42:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Liu X-Patchwork-Id: 2329631 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 8C8913FD8C for ; Mon, 25 Mar 2013 09:45:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755635Ab3CYJpD (ORCPT ); Mon, 25 Mar 2013 05:45:03 -0400 Received: from na3sys009aog120.obsmtp.com ([74.125.149.140]:47841 "EHLO na3sys009aog120.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755616Ab3CYJpB (ORCPT ); Mon, 25 Mar 2013 05:45:01 -0400 X-Greylist: delayed 878 seconds by postgrey-1.27 at vger.kernel.org; Mon, 25 Mar 2013 05:44:47 EDT Received: from sc-owa02.marvell.com ([199.233.58.137]) (using TLSv1) by na3sys009aob120.postini.com ([74.125.148.12]) with SMTP ID DSNKUVAciy0tJChcb/zsy5uvGkRTkgCjz5Sp@postini.com; Mon, 25 Mar 2013 02:45:01 PDT Received: from maili.marvell.com (10.93.76.43) by sc-owa02.marvell.com (10.93.76.22) with Microsoft SMTP Server id 8.3.213.0; Mon, 25 Mar 2013 02:40:53 -0700 Received: from kliu5-desktop.marvell.com (unknown [10.38.36.240]) by maili.marvell.com (Postfix) with ESMTP id CD76E4E517; Mon, 25 Mar 2013 02:40:37 -0700 (PDT) From: Kevin Liu To: , Chris Ball , Jerry Huang , Chunhe Lan , Guennadi Liakhovetski , Sujit Reddy Thumma , Jaehoon Chung , Aaron Lu , Ulf Hansson , Wei WANG , Fabio Estevam CC: Stephen Warren , Adrian Hunter , Philip Rakity , Shawn Guo , Johan Rudholm , Girish K S , Haijun Zhang , Zhangfei Gao , Haojian Zhuang , Chao Xie , Kevin Liu , Kevin Liu Subject: [PATCH RESEND 3/4] mmc: sdhci-pxav3: enhance device tree parser code Date: Mon, 25 Mar 2013 17:42:58 +0800 Message-ID: <1364204579-13307-4-git-send-email-kliu5@marvell.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1364204579-13307-1-git-send-email-kliu5@marvell.com> References: <1364204579-13307-1-git-send-email-kliu5@marvell.com> MIME-Version: 1.0 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org 1. seperate device tree parsing from platform data handling which can make further work easy when platform data can be removed. 2. add calling mmc_of_parse which can parse more of property and pxav3_get_mmc_pdata can be shrinked a lot. Signed-off-by: Kevin Liu --- drivers/mmc/host/sdhci-pxav3.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c index 56d6a2e..fb0d23c 100644 --- a/drivers/mmc/host/sdhci-pxav3.c +++ b/drivers/mmc/host/sdhci-pxav3.c @@ -195,29 +195,16 @@ static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev) { struct sdhci_pxa_platdata *pdata; struct device_node *np = dev->of_node; - u32 bus_width; u32 clk_delay_cycles; - enum of_gpio_flags gpio_flags; pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return NULL; - if (of_find_property(np, "non-removable", NULL)) - pdata->flags |= PXA_FLAG_CARD_PERMANENT; - - of_property_read_u32(np, "bus-width", &bus_width); - if (bus_width == 8) - pdata->flags |= PXA_FLAG_SD_8_BIT_CAPABLE_SLOT; - of_property_read_u32(np, "mrvl,clk-delay-cycles", &clk_delay_cycles); if (clk_delay_cycles > 0) pdata->clk_delay_cycles = clk_delay_cycles; - pdata->ext_cd_gpio = of_get_named_gpio_flags(np, "cd-gpios", 0, &gpio_flags); - if (gpio_flags != OF_GPIO_ACTIVE_LOW) - pdata->host_caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; - return pdata; } #else @@ -264,10 +251,11 @@ static int sdhci_pxav3_probe(struct platform_device *pdev) host->mmc->caps |= MMC_CAP_1_8V_DDR; match = of_match_device(of_match_ptr(sdhci_pxav3_of_match), &pdev->dev); - if (match) + if (match) { + mmc_of_parse(host->mmc); + sdhci_get_of_property(pdev); pdata = pxav3_get_mmc_pdata(dev); - - if (pdata) { + } else if (pdata) { /* on-chip device */ if (pdata->flags & PXA_FLAG_CARD_PERMANENT) host->mmc->caps |= MMC_CAP_NONREMOVABLE; @@ -297,8 +285,6 @@ static int sdhci_pxav3_probe(struct platform_device *pdev) } } - sdhci_get_of_property(pdev); - pm_runtime_set_active(&pdev->dev); pm_runtime_enable(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, PXAV3_RPM_DELAY_MS); @@ -316,7 +302,7 @@ static int sdhci_pxav3_probe(struct platform_device *pdev) platform_set_drvdata(pdev, host); - if (pdata->pm_caps & MMC_PM_KEEP_POWER) { + if (host->mmc->pm_caps & MMC_PM_KEEP_POWER) { device_init_wakeup(&pdev->dev, 1); host->mmc->pm_flags |= MMC_PM_WAKE_SDIO_IRQ; } else {