From patchwork Mon Jan 8 09:18:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Hunter X-Patchwork-Id: 10149181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 14171601BE for ; Mon, 8 Jan 2018 09:18:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B52128908 for ; Mon, 8 Jan 2018 09:18:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F264628914; Mon, 8 Jan 2018 09:18:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 721052890C for ; Mon, 8 Jan 2018 09:18:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755931AbeAHJSz (ORCPT ); Mon, 8 Jan 2018 04:18:55 -0500 Received: from mga04.intel.com ([192.55.52.120]:10044 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756030AbeAHJSh (ORCPT ); Mon, 8 Jan 2018 04:18:37 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2018 01:18:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,330,1511856000"; d="scan'208";a="18331248" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.168]) ([10.237.72.168]) by orsmga003.jf.intel.com with ESMTP; 08 Jan 2018 01:18:35 -0800 Subject: Re: [PATCH] mmc: sdhci_f_sdh30: add ACPI support To: Ard Biesheuvel , linux-mmc@vger.kernel.org, ulf.hansson@linaro.org References: <20171227181420.6230-1-ard.biesheuvel@linaro.org> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <7bf350dc-4e2a-52f0-408f-36c5c7ca689d@intel.com> Date: Mon, 8 Jan 2018 11:18:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <20171227181420.6230-1-ard.biesheuvel@linaro.org> Content-Language: en-US Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 27/12/17 20:14, Ard Biesheuvel wrote: > The Fujitsu SDH30 SDHCI controller may be described as a SCX0002 ACPI > device on ACPI platforms incorporating the Socionext SynQuacer SoC. > > Given that mmc_of_parse() has already been made ACPI/DT agnostic, > making the SDH30 driver ACPI capable is actually rather simple: > all we need to do is make the call to sdhci_get_of_property() [which > does not set any properties we care about] and the clock handling > dependent on whether we are dealing with a DT device, and exposing > the ACPI id via the platform_driver struct and the module metadata. > > Signed-off-by: Ard Biesheuvel > --- > drivers/mmc/host/sdhci_f_sdh30.c | 53 +++++++++++++------- > 1 file changed, 34 insertions(+), 19 deletions(-) > > diff --git a/drivers/mmc/host/sdhci_f_sdh30.c b/drivers/mmc/host/sdhci_f_sdh30.c > index 04ca0d33a521..102321a9ea34 100644 > --- a/drivers/mmc/host/sdhci_f_sdh30.c > +++ b/drivers/mmc/host/sdhci_f_sdh30.c > @@ -10,6 +10,7 @@ > * the Free Software Foundation, version 2 of the License. > */ > > +#include > #include > #include > #include > @@ -146,7 +147,6 @@ static int sdhci_f_sdh30_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, host); > > - sdhci_get_of_property(pdev); > host->hw_name = "f_sdh30"; > host->ops = &sdhci_f_sdh30_ops; > host->irq = irq; > @@ -158,25 +158,29 @@ static int sdhci_f_sdh30_probe(struct platform_device *pdev) > goto err; > } > > - priv->clk_iface = devm_clk_get(&pdev->dev, "iface"); > - if (IS_ERR(priv->clk_iface)) { > - ret = PTR_ERR(priv->clk_iface); > - goto err; > - } > + if (dev_of_node(dev)) { > + sdhci_get_of_property(pdev); > > - ret = clk_prepare_enable(priv->clk_iface); > - if (ret) > - goto err; > + priv->clk_iface = devm_clk_get(&pdev->dev, "iface"); > + if (IS_ERR(priv->clk_iface)) { > + ret = PTR_ERR(priv->clk_iface); > + goto err; > + } > > - priv->clk = devm_clk_get(&pdev->dev, "core"); > - if (IS_ERR(priv->clk)) { > - ret = PTR_ERR(priv->clk); > - goto err_clk; > - } > + ret = clk_prepare_enable(priv->clk_iface); > + if (ret) > + goto err; > > - ret = clk_prepare_enable(priv->clk); > - if (ret) > - goto err_clk; > + priv->clk = devm_clk_get(&pdev->dev, "core"); > + if (IS_ERR(priv->clk)) { > + ret = PTR_ERR(priv->clk); > + goto err_clk; > + } > + > + ret = clk_prepare_enable(priv->clk); > + if (ret) > + goto err_clk; > + } > > /* init vendor specific regs */ > ctrl = sdhci_readw(host, F_SDH30_AHB_CONFIG); > @@ -217,8 +221,10 @@ static int sdhci_f_sdh30_remove(struct platform_device *pdev) > sdhci_remove_host(host, readl(host->ioaddr + SDHCI_INT_STATUS) == > 0xffffffff); > > - clk_disable_unprepare(priv->clk_iface); > - clk_disable_unprepare(priv->clk); > + if (dev_of_node(priv->dev)) { You check dev_of_node(priv->dev) here but not in the error path of sdhci_f_sdh30_probe(). I guess passing NULL to clk_disable_unprepare() is OK anyway, so is the check needed at all? > + clk_disable_unprepare(priv->clk_iface); > + clk_disable_unprepare(priv->clk); > + } > > sdhci_free_host(host); > platform_set_drvdata(pdev, NULL); > @@ -232,10 +238,19 @@ static const struct of_device_id f_sdh30_dt_ids[] = { > }; > MODULE_DEVICE_TABLE(of, f_sdh30_dt_ids); > > +#ifdef CONFIG_ACPI > +static const struct acpi_device_id f_sdh30_acpi_ids[] = { > + { "SCX0002" }, > + { /* sentinel */ } > +}; > +MODULE_DEVICE_TABLE(acpi, f_sdh30_acpi_ids); > +#endif > + > static struct platform_driver sdhci_f_sdh30_driver = { > .driver = { > .name = "f_sdh30", > .of_match_table = f_sdh30_dt_ids, Perhaps you should tidy up the Kconfig too e.g. Then consider using of_match_ptr() and #ifdef CONFIG_OF around f_sdh30_acpi_ids so it all looks nice and symmetrical. > + .acpi_match_table = ACPI_PTR(f_sdh30_acpi_ids), > .pm = &sdhci_pltfm_pmops, > }, > .probe = sdhci_f_sdh30_probe, > --- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index cc4fd07735a7..55aee47df96c 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig @@ -320,8 +320,7 @@ config MMC_SDHCI_BCM_KONA config MMC_SDHCI_F_SDH30 tristate "SDHCI support for Fujitsu Semiconductor F_SDH30" depends on MMC_SDHCI_PLTFM - depends on OF + depends on OF || ACPI help This selects the Secure Digital Host Controller Interface (SDHCI) Needed by some Fujitsu SoC for MMC / SD / SDIO support.