[PATCH (1/5)] mmc: sdhci-pltfm calls the sdhci_alloc_host with pdev->dev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ST targets use the sdhci-pltfm driver but there are some
problems when re-insert the driver on our platforms.
Within sdhci-pltfm d.d. the pdata->init invokes own
platform function to claim some resource (based on devres):
see the example code below:

static int mmc_pad_resources(struct sdhci_host *sdhci)
{
    if (!devm_stm_pad_claim(sdhci->mmc->parent, &stx7105_mmc_pad_config,
                            dev_name(sdhci->mmc->parent)))
              return -ENODEV;
     return 0;
}

static struct sdhci_pltfm_data stx7105_mmc_platform_data = {
                .init = mmc_pad_resources,
                .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC,
};

static struct platform_device stx7105_mmc_device = {
                .name = "sdhci",
                .id = 0,
[snip]
                .dev = {
                      .platform_data = &stx7105_mmc_platform_data,
                }
};

void __init stx7105_configure_mmc(void)
{
 ...
        platform_device_register(&stx7105_mmc_device);
}

As soon as the sdhci-pltfm is removed from the system
the sdhci resources previously allocate are not released
and the probe fails when re-insert the module.

The platform driver calls the sdhci_alloc_host passing as device pointer
the parent.
Note: parent name is "platform" and dev name is "sdhci.0".
IMO it makes sense to pass the pdev->dev pointer instead of the parent.

In the end, this also fixes the problem described above and I can insert/remove
the sdhci-pltfm driver several times without failures.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@xxxxxx>
Reviewed-by: Francesco Virlinzi <francesco.virlinzi@xxxxxx>
---
 drivers/mmc/host/sdhci-pltfm.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index 78a8f7a..4e881a5 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -65,11 +65,7 @@ static int __devinit sdhci_pltfm_probe(struct platform_device *pdev)
 		dev_err(&pdev->dev, "Invalid iomem size. You may "
 			"experience problems.\n");
 
-	if (pdev->dev.parent)
-		host = sdhci_alloc_host(pdev->dev.parent, 0);
-	else
-		host = sdhci_alloc_host(&pdev->dev, 0);
-
+	host = sdhci_alloc_host(&pdev->dev, 0);
 	if (IS_ERR(host)) {
 		ret = PTR_ERR(host);
 		goto err;
-- 
1.5.5.6

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux