diff mbox

[5/7] mmc: pxamci: call mmc_of_parse()

Message ID 20180629144738.446-6-daniel@zonque.org (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Mack June 29, 2018, 2:47 p.m. UTC
Call into mmc_of_parse() from pxamci_of_init(). As it needs a pointer to a
struct mmc_host, refactor the code a bit.

This allows all generic MMC properties to be set that are described in
Documentation/devicetree/bindings/mmc/mmc.txt.

Signed-off-by: Daniel Mack <daniel@zonque.org>
---
 drivers/mmc/host/pxamci.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

Comments

Robert Jarzmik June 30, 2018, 3:25 p.m. UTC | #1
Daniel Mack <daniel@zonque.org> writes:

> Call into mmc_of_parse() from pxamci_of_init(). As it needs a pointer to a
> struct mmc_host, refactor the code a bit.
>
> This allows all generic MMC properties to be set that are described in
> Documentation/devicetree/bindings/mmc/mmc.txt.
>
> Signed-off-by: Daniel Mack <daniel@zonque.org>

I'm a bit worried about this one :
 - mmc_of_init() will request the gpios from "cd-gpios" and "wp-gpios"
 - pdata->gpio_card_detect will be used to request the same gpio in
 pxa_mci_of_init()

So the gpio is acquired twice, isn't it ? Do you know this works by test proof,
and doesn't it make sense to remove the "pdata->gpio* =" statements from
pxamci_of_init() ?

Cheers.
Daniel Mack June 30, 2018, 6:07 p.m. UTC | #2
On Saturday, June 30, 2018 05:25 PM, Robert Jarzmik wrote:
> Daniel Mack <daniel@zonque.org> writes:
> 
>> Call into mmc_of_parse() from pxamci_of_init(). As it needs a pointer to a
>> struct mmc_host, refactor the code a bit.
>>
>> This allows all generic MMC properties to be set that are described in
>> Documentation/devicetree/bindings/mmc/mmc.txt.
>>
>> Signed-off-by: Daniel Mack <daniel@zonque.org>
> 
> I'm a bit worried about this one :
>   - mmc_of_init() will request the gpios from "cd-gpios" and "wp-gpios"
>   - pdata->gpio_card_detect will be used to request the same gpio in
>   pxa_mci_of_init()
> 
> So the gpio is acquired twice, isn't it ? Do you know this works by test proof,
> and doesn't it make sense to remove the "pdata->gpio* =" statements from
> pxamci_of_init() ?

Ah, yes. Thanks for spotting this, you're right! Will fix in v2!


Thanks,
Daniel
--
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 mbox

Patch

diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index 3df60c7babce..e15708aa77a2 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -591,11 +591,13 @@  static const struct of_device_id pxa_mmc_dt_ids[] = {
 
 MODULE_DEVICE_TABLE(of, pxa_mmc_dt_ids);
 
-static int pxamci_of_init(struct platform_device *pdev)
+static int pxamci_of_init(struct platform_device *pdev,
+			  struct mmc_host *mmc)
 {
 	struct device_node *np = pdev->dev.of_node;
 	struct pxamci_platform_data *pdata;
 	u32 tmp;
+	int ret;
 
 	if (!np)
 		return 0;
@@ -616,12 +618,17 @@  static int pxamci_of_init(struct platform_device *pdev)
 	if (of_property_read_u32(np, "pxa-mmc,detect-delay-ms", &tmp) == 0)
 		pdata->detect_delay_ms = tmp;
 
+	ret = mmc_of_parse(mmc);
+	if (ret < 0)
+		return ret;
+
 	pdev->dev.platform_data = pdata;
 
 	return 0;
 }
 #else
-static int pxamci_of_init(struct platform_device *pdev)
+static int pxamci_of_init(struct platform_device *pdev,
+			  struct mmc_host *mmc)
 {
         return 0;
 }
@@ -634,10 +641,6 @@  static int pxamci_probe(struct platform_device *pdev)
 	struct resource *r;
 	int ret, irq, gpio_cd = -1, gpio_ro = -1, gpio_power = -1;
 
-	ret = pxamci_of_init(pdev);
-	if (ret)
-		return ret;
-
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
@@ -672,6 +675,10 @@  static int pxamci_probe(struct platform_device *pdev)
 	 */
 	mmc->max_blk_count = 65535;
 
+	ret = pxamci_of_init(pdev, mmc);
+	if (ret)
+		return ret;
+
 	host = mmc_priv(mmc);
 	host->mmc = mmc;
 	host->pdata = pdev->dev.platform_data;