Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ea28ecb authored by Balaji T K's avatar Balaji T K Committed by Chris Ball
Browse files

mmc: omap_hsmmc: fix NULL pointer dereference for dt boot



dev->platform_data is NULL in case of device tree boot,
instead use the saved version in struct omap_hsmmc_host.

Signed-off-by: default avatarBalaji T K <balajitk@ti.com>
Signed-off-by: default avatarVenkatraman S <svenkatr@ti.com>
Signed-off-by: default avatarChris Ball <cjb@laptop.org>
parent 9d1f0286
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -178,7 +178,8 @@ struct omap_hsmmc_host {

static int omap_hsmmc_card_detect(struct device *dev, int slot)
{
	struct omap_mmc_platform_data *mmc = dev->platform_data;
	struct omap_hsmmc_host *host = dev_get_drvdata(dev);
	struct omap_mmc_platform_data *mmc = host->pdata;

	/* NOTE: assumes card detect signal is active-low */
	return !gpio_get_value_cansleep(mmc->slots[0].switch_pin);
@@ -186,7 +187,8 @@ static int omap_hsmmc_card_detect(struct device *dev, int slot)

static int omap_hsmmc_get_wp(struct device *dev, int slot)
{
	struct omap_mmc_platform_data *mmc = dev->platform_data;
	struct omap_hsmmc_host *host = dev_get_drvdata(dev);
	struct omap_mmc_platform_data *mmc = host->pdata;

	/* NOTE: assumes write protect signal is active-high */
	return gpio_get_value_cansleep(mmc->slots[0].gpio_wp);
@@ -194,7 +196,8 @@ static int omap_hsmmc_get_wp(struct device *dev, int slot)

static int omap_hsmmc_get_cover_state(struct device *dev, int slot)
{
	struct omap_mmc_platform_data *mmc = dev->platform_data;
	struct omap_hsmmc_host *host = dev_get_drvdata(dev);
	struct omap_mmc_platform_data *mmc = host->pdata;

	/* NOTE: assumes card detect signal is active-low */
	return !gpio_get_value_cansleep(mmc->slots[0].switch_pin);
@@ -204,7 +207,8 @@ static int omap_hsmmc_get_cover_state(struct device *dev, int slot)

static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot)
{
	struct omap_mmc_platform_data *mmc = dev->platform_data;
	struct omap_hsmmc_host *host = dev_get_drvdata(dev);
	struct omap_mmc_platform_data *mmc = host->pdata;

	disable_irq(mmc->slots[0].card_detect_irq);
	return 0;
@@ -212,7 +216,8 @@ static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot)

static int omap_hsmmc_resume_cdirq(struct device *dev, int slot)
{
	struct omap_mmc_platform_data *mmc = dev->platform_data;
	struct omap_hsmmc_host *host = dev_get_drvdata(dev);
	struct omap_mmc_platform_data *mmc = host->pdata;

	enable_irq(mmc->slots[0].card_detect_irq);
	return 0;
@@ -2009,9 +2014,9 @@ static int __devexit omap_hsmmc_remove(struct platform_device *pdev)
		clk_put(host->dbclk);
	}

	omap_hsmmc_gpio_free(host->pdata);
	iounmap(host->base);
	mmc_free_host(host->mmc);
	omap_hsmmc_gpio_free(pdev->dev.platform_data);

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (res)