From patchwork Fri May 23 12:33:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sascha Hauer X-Patchwork-Id: 4232001 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D18DD9F1CD for ; Fri, 23 May 2014 12:33:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 54FED203A9 for ; Fri, 23 May 2014 12:33:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2E85720386 for ; Fri, 23 May 2014 12:33:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751633AbaEWMdR (ORCPT ); Fri, 23 May 2014 08:33:17 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:43512 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751406AbaEWMdQ (ORCPT ); Fri, 23 May 2014 08:33:16 -0400 Received: from dude.hi.pengutronix.de ([2001:6f8:1178:2:a236:9fff:fe00:814]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Wnoeg-0006lu-Jb; Fri, 23 May 2014 14:32:58 +0200 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.82) (envelope-from ) id 1Wnoen-0001YM-I7; Fri, 23 May 2014 14:33:05 +0200 From: Sascha Hauer To: linux-mmc@vger.kernel.org Cc: Shawn Guo , , kernel@pengutronix.de, Sascha Hauer Subject: [PATCH 2/5] mmc: sdhci-esdhc-imx: introduce function for parsing platform_data Date: Fri, 23 May 2014 14:33:01 +0200 Message-Id: <1400848384-3226-3-git-send-email-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.0.0.rc0 In-Reply-To: <1400848384-3226-1-git-send-email-s.hauer@pengutronix.de> References: <1400848384-3226-1-git-send-email-s.hauer@pengutronix.de> X-SA-Exim-Connect-IP: 2001:6f8:1178:2:a236:9fff:fe00:814 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-mmc@vger.kernel.org Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As a first step to separate the platform_data code from the devicetree code add a function to parse the boarddata. Also change the argument of the dt probe function from struct esdhc_platform_data * to struct pltfm_imx_data *imx_data which makes it possible to get struct esdhc_platform_data out of the devicetree probing path. Signed-off-by: Sascha Hauer --- drivers/mmc/host/sdhci-esdhc-imx.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c index d530820..f6f7a45 100644 --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -901,8 +901,9 @@ static const struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = { #ifdef CONFIG_OF static int sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, - struct esdhc_platform_data *boarddata) + struct pltfm_imx_data *imx_data) { + struct esdhc_platform_data *boarddata = &imx_data->boarddata; struct device_node *np = pdev->dev.of_node; if (!np) @@ -942,12 +943,28 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, #else static inline int sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, - struct esdhc_platform_data *boarddata) + struct pltfm_imx_data *imx_data) { return -ENODEV; } #endif +static int +sdhci_esdhc_imx_probe_boarddata(struct platform_device *pdev, + struct pltfm_imx_data *imx_data) +{ + struct esdhc_platform_data *pdata = pdev->dev.platform_data; + + if (!pdata) { + dev_err(&pdev->dev, "no boarddata\n"); + return -EINVAL; + } + + imx_data->boarddata = *pdata; + + return 0; +} + static int sdhci_esdhc_imx_probe(struct platform_device *pdev) { const struct of_device_id *of_id = @@ -1037,14 +1054,10 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev) host->ioaddr + ESDHC_TUNING_CTRL); boarddata = &imx_data->boarddata; - if (sdhci_esdhc_imx_probe_dt(pdev, boarddata) < 0) { - if (!host->mmc->parent->platform_data) { - dev_err(mmc_dev(host->mmc), "no board data!\n"); - err = -EINVAL; + if (sdhci_esdhc_imx_probe_dt(pdev, imx_data) < 0) { + err = sdhci_esdhc_imx_probe_boarddata(pdev, imx_data); + if (err) goto disable_clk; - } - imx_data->boarddata = *((struct esdhc_platform_data *) - host->mmc->parent->platform_data); } imx_data->f_max = clk_get_rate(imx_data->clk_per);