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

Commit a4275153 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'mmc-fixes-for-3.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc

Pull MMC fixes from Chris Ball:
 - sdhci: fix a NULL dereference at resume-time, seen on OLPC XO-4
 - sdhci: fix against 3.7-rc1 for UHS modes without a vqmmc regulator
 - sdhci-of-esdhc: disable CMD23 on boards where it's broken
 - sdhci-s3c: fix against 3.7-rc1 for card detection with runtime PM
 - dw_mmc, omap_hsmmc: fix potential NULL derefs, compiler warnings

* tag 'mmc-fixes-for-3.7-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc:
  mmc: sdhci-s3c: fix the card detection in runtime-pm
  mmc: sdhci-s3c: use clk_prepare_enable and clk_disable_unprepare
  mmc: dw_mmc: constify dw_mci_idmac_ops in exynos back-end
  mmc: dw_mmc: fix modular build for exynos back-end
  mmc: sdhci: fix NULL dereference in sdhci_request() tuning
  mmc: sdhci: fix IS_ERR() checking of regulator_get()
  mmc: fix sdhci-dove probe/removal
  mmc: sh_mmcif: fix use after free
  mmc: sdhci-pci: fix 'Invalid iomem size' error message condition
  mmc: mxcmmc: Fix MODULE_ALIAS
  mmc: omap_hsmmc: fix NULL pointer dereference for dt boot
  mmc: omap_hsmmc: fix host reference after mmc_free_host
  mmc: dw_mmc: fix multiple drv_data NULL dereferences
  mmc: dw_mmc: enable controller interrupt before calling mmc_start_host
  mmc: sdhci-of-esdhc: disable CMD23 for some Freescale SoCs
  mmc: dw_mmc: remove _dev_info compile warning
  mmc: dw_mmc: convert the variable type of irq
parents 9ca72adc 0aa55c23
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -208,7 +208,7 @@ static unsigned long exynos5250_dwmmc_caps[4] = {
	MMC_CAP_CMD23,
	MMC_CAP_CMD23,
};
};


static struct dw_mci_drv_data exynos5250_drv_data = {
static const struct dw_mci_drv_data exynos5250_drv_data = {
	.caps			= exynos5250_dwmmc_caps,
	.caps			= exynos5250_dwmmc_caps,
	.init			= dw_mci_exynos_priv_init,
	.init			= dw_mci_exynos_priv_init,
	.setup_clock		= dw_mci_exynos_setup_clock,
	.setup_clock		= dw_mci_exynos_setup_clock,
@@ -220,14 +220,14 @@ static struct dw_mci_drv_data exynos5250_drv_data = {


static const struct of_device_id dw_mci_exynos_match[] = {
static const struct of_device_id dw_mci_exynos_match[] = {
	{ .compatible = "samsung,exynos5250-dw-mshc",
	{ .compatible = "samsung,exynos5250-dw-mshc",
			.data = (void *)&exynos5250_drv_data, },
			.data = &exynos5250_drv_data, },
	{},
	{},
};
};
MODULE_DEVICE_TABLE(of, dw_mci_pltfm_match);
MODULE_DEVICE_TABLE(of, dw_mci_exynos_match);


int dw_mci_exynos_probe(struct platform_device *pdev)
int dw_mci_exynos_probe(struct platform_device *pdev)
{
{
	struct dw_mci_drv_data *drv_data;
	const struct dw_mci_drv_data *drv_data;
	const struct of_device_id *match;
	const struct of_device_id *match;


	match = of_match_node(dw_mci_exynos_match, pdev->dev.of_node);
	match = of_match_node(dw_mci_exynos_match, pdev->dev.of_node);
+3 −3
Original line number Original line Diff line number Diff line
@@ -24,7 +24,7 @@
#include "dw_mmc.h"
#include "dw_mmc.h"


int dw_mci_pltfm_register(struct platform_device *pdev,
int dw_mci_pltfm_register(struct platform_device *pdev,
				struct dw_mci_drv_data *drv_data)
				const struct dw_mci_drv_data *drv_data)
{
{
	struct dw_mci *host;
	struct dw_mci *host;
	struct resource	*regs;
	struct resource	*regs;
@@ -50,8 +50,8 @@ int dw_mci_pltfm_register(struct platform_device *pdev,
	if (!host->regs)
	if (!host->regs)
		return -ENOMEM;
		return -ENOMEM;


	if (host->drv_data->init) {
	if (drv_data && drv_data->init) {
		ret = host->drv_data->init(host);
		ret = drv_data->init(host);
		if (ret)
		if (ret)
			return ret;
			return ret;
	}
	}
+1 −1
Original line number Original line Diff line number Diff line
@@ -13,7 +13,7 @@
#define _DW_MMC_PLTFM_H_
#define _DW_MMC_PLTFM_H_


extern int dw_mci_pltfm_register(struct platform_device *pdev,
extern int dw_mci_pltfm_register(struct platform_device *pdev,
				struct dw_mci_drv_data *drv_data);
				const struct dw_mci_drv_data *drv_data);
extern int __devexit dw_mci_pltfm_remove(struct platform_device *pdev);
extern int __devexit dw_mci_pltfm_remove(struct platform_device *pdev);
extern const struct dev_pm_ops dw_mci_pltfm_pmops;
extern const struct dev_pm_ops dw_mci_pltfm_pmops;


+34 −28
Original line number Original line Diff line number Diff line
@@ -232,6 +232,7 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd)
{
{
	struct mmc_data	*data;
	struct mmc_data	*data;
	struct dw_mci_slot *slot = mmc_priv(mmc);
	struct dw_mci_slot *slot = mmc_priv(mmc);
	struct dw_mci_drv_data *drv_data = slot->host->drv_data;
	u32 cmdr;
	u32 cmdr;
	cmd->error = -EINPROGRESS;
	cmd->error = -EINPROGRESS;


@@ -261,8 +262,8 @@ static u32 dw_mci_prepare_command(struct mmc_host *mmc, struct mmc_command *cmd)
			cmdr |= SDMMC_CMD_DAT_WR;
			cmdr |= SDMMC_CMD_DAT_WR;
	}
	}


	if (slot->host->drv_data->prepare_command)
	if (drv_data && drv_data->prepare_command)
		slot->host->drv_data->prepare_command(slot->host, &cmdr);
		drv_data->prepare_command(slot->host, &cmdr);


	return cmdr;
	return cmdr;
}
}
@@ -434,7 +435,7 @@ static int dw_mci_idmac_init(struct dw_mci *host)
	return 0;
	return 0;
}
}


static struct dw_mci_dma_ops dw_mci_idmac_ops = {
static const struct dw_mci_dma_ops dw_mci_idmac_ops = {
	.init = dw_mci_idmac_init,
	.init = dw_mci_idmac_init,
	.start = dw_mci_idmac_start_dma,
	.start = dw_mci_idmac_start_dma,
	.stop = dw_mci_idmac_stop_dma,
	.stop = dw_mci_idmac_stop_dma,
@@ -772,6 +773,7 @@ static void dw_mci_request(struct mmc_host *mmc, struct mmc_request *mrq)
static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{
{
	struct dw_mci_slot *slot = mmc_priv(mmc);
	struct dw_mci_slot *slot = mmc_priv(mmc);
	struct dw_mci_drv_data *drv_data = slot->host->drv_data;
	u32 regs;
	u32 regs;


	/* set default 1 bit mode */
	/* set default 1 bit mode */
@@ -807,8 +809,8 @@ static void dw_mci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
		slot->clock = ios->clock;
		slot->clock = ios->clock;
	}
	}


	if (slot->host->drv_data->set_ios)
	if (drv_data && drv_data->set_ios)
		slot->host->drv_data->set_ios(slot->host, ios);
		drv_data->set_ios(slot->host, ios);


	switch (ios->power_mode) {
	switch (ios->power_mode) {
	case MMC_POWER_UP:
	case MMC_POWER_UP:
@@ -1815,6 +1817,7 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
{
{
	struct mmc_host *mmc;
	struct mmc_host *mmc;
	struct dw_mci_slot *slot;
	struct dw_mci_slot *slot;
	struct dw_mci_drv_data *drv_data = host->drv_data;
	int ctrl_id, ret;
	int ctrl_id, ret;
	u8 bus_width;
	u8 bus_width;


@@ -1854,8 +1857,8 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
	} else {
	} else {
		ctrl_id = to_platform_device(host->dev)->id;
		ctrl_id = to_platform_device(host->dev)->id;
	}
	}
	if (host->drv_data && host->drv_data->caps)
	if (drv_data && drv_data->caps)
		mmc->caps |= host->drv_data->caps[ctrl_id];
		mmc->caps |= drv_data->caps[ctrl_id];


	if (host->pdata->caps2)
	if (host->pdata->caps2)
		mmc->caps2 = host->pdata->caps2;
		mmc->caps2 = host->pdata->caps2;
@@ -1867,10 +1870,10 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
	else
	else
		bus_width = 1;
		bus_width = 1;


	if (host->drv_data->setup_bus) {
	if (drv_data && drv_data->setup_bus) {
		struct device_node *slot_np;
		struct device_node *slot_np;
		slot_np = dw_mci_of_find_slot_node(host->dev, slot->id);
		slot_np = dw_mci_of_find_slot_node(host->dev, slot->id);
		ret = host->drv_data->setup_bus(host, slot_np, bus_width);
		ret = drv_data->setup_bus(host, slot_np, bus_width);
		if (ret)
		if (ret)
			goto err_setup_bus;
			goto err_setup_bus;
	}
	}
@@ -1968,7 +1971,7 @@ static void dw_mci_init_dma(struct dw_mci *host)
	/* Determine which DMA interface to use */
	/* Determine which DMA interface to use */
#ifdef CONFIG_MMC_DW_IDMAC
#ifdef CONFIG_MMC_DW_IDMAC
	host->dma_ops = &dw_mci_idmac_ops;
	host->dma_ops = &dw_mci_idmac_ops;
	dev_info(&host->dev, "Using internal DMA controller.\n");
	dev_info(host->dev, "Using internal DMA controller.\n");
#endif
#endif


	if (!host->dma_ops)
	if (!host->dma_ops)
@@ -2035,6 +2038,7 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)
	struct dw_mci_board *pdata;
	struct dw_mci_board *pdata;
	struct device *dev = host->dev;
	struct device *dev = host->dev;
	struct device_node *np = dev->of_node;
	struct device_node *np = dev->of_node;
	struct dw_mci_drv_data *drv_data = host->drv_data;
	int idx, ret;
	int idx, ret;


	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
	pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
@@ -2062,8 +2066,8 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)


	of_property_read_u32(np, "card-detect-delay", &pdata->detect_delay_ms);
	of_property_read_u32(np, "card-detect-delay", &pdata->detect_delay_ms);


	if (host->drv_data->parse_dt) {
	if (drv_data && drv_data->parse_dt) {
		ret = host->drv_data->parse_dt(host);
		ret = drv_data->parse_dt(host);
		if (ret)
		if (ret)
			return ERR_PTR(ret);
			return ERR_PTR(ret);
	}
	}
@@ -2080,6 +2084,7 @@ static struct dw_mci_board *dw_mci_parse_dt(struct dw_mci *host)


int dw_mci_probe(struct dw_mci *host)
int dw_mci_probe(struct dw_mci *host)
{
{
	struct dw_mci_drv_data *drv_data = host->drv_data;
	int width, i, ret = 0;
	int width, i, ret = 0;
	u32 fifo_size;
	u32 fifo_size;
	int init_slots = 0;
	int init_slots = 0;
@@ -2127,8 +2132,8 @@ int dw_mci_probe(struct dw_mci *host)
	else
	else
		host->bus_hz = clk_get_rate(host->ciu_clk);
		host->bus_hz = clk_get_rate(host->ciu_clk);


	if (host->drv_data->setup_clock) {
	if (drv_data && drv_data->setup_clock) {
		ret = host->drv_data->setup_clock(host);
		ret = drv_data->setup_clock(host);
		if (ret) {
		if (ret) {
			dev_err(host->dev,
			dev_err(host->dev,
				"implementation specific clock setup failed\n");
				"implementation specific clock setup failed\n");
@@ -2228,6 +2233,21 @@ int dw_mci_probe(struct dw_mci *host)
	else
	else
		host->num_slots = ((mci_readl(host, HCON) >> 1) & 0x1F) + 1;
		host->num_slots = ((mci_readl(host, HCON) >> 1) & 0x1F) + 1;


	/*
	 * Enable interrupts for command done, data over, data empty, card det,
	 * receive ready and error such as transmit, receive timeout, crc error
	 */
	mci_writel(host, RINTSTS, 0xFFFFFFFF);
	mci_writel(host, INTMASK, SDMMC_INT_CMD_DONE | SDMMC_INT_DATA_OVER |
		   SDMMC_INT_TXDR | SDMMC_INT_RXDR |
		   DW_MCI_ERROR_FLAGS | SDMMC_INT_CD);
	mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */

	dev_info(host->dev, "DW MMC controller at irq %d, "
		 "%d bit host data width, "
		 "%u deep fifo\n",
		 host->irq, width, fifo_size);

	/* We need at least one slot to succeed */
	/* We need at least one slot to succeed */
	for (i = 0; i < host->num_slots; i++) {
	for (i = 0; i < host->num_slots; i++) {
		ret = dw_mci_init_slot(host, i);
		ret = dw_mci_init_slot(host, i);
@@ -2257,20 +2277,6 @@ int dw_mci_probe(struct dw_mci *host)
	else
	else
		host->data_offset = DATA_240A_OFFSET;
		host->data_offset = DATA_240A_OFFSET;


	/*
	 * Enable interrupts for command done, data over, data empty, card det,
	 * receive ready and error such as transmit, receive timeout, crc error
	 */
	mci_writel(host, RINTSTS, 0xFFFFFFFF);
	mci_writel(host, INTMASK, SDMMC_INT_CMD_DONE | SDMMC_INT_DATA_OVER |
		   SDMMC_INT_TXDR | SDMMC_INT_RXDR |
		   DW_MCI_ERROR_FLAGS | SDMMC_INT_CD);
	mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */

	dev_info(host->dev, "DW MMC controller at irq %d, "
		 "%d bit host data width, "
		 "%u deep fifo\n",
		 host->irq, width, fifo_size);
	if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO)
	if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO)
		dev_info(host->dev, "Internal DMAC interrupt fix enabled.\n");
		dev_info(host->dev, "Internal DMAC interrupt fix enabled.\n");


+1 −1
Original line number Original line Diff line number Diff line
@@ -1134,4 +1134,4 @@ module_platform_driver(mxcmci_driver);
MODULE_DESCRIPTION("i.MX Multimedia Card Interface Driver");
MODULE_DESCRIPTION("i.MX Multimedia Card Interface Driver");
MODULE_AUTHOR("Sascha Hauer, Pengutronix");
MODULE_AUTHOR("Sascha Hauer, Pengutronix");
MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:imx-mmc");
MODULE_ALIAS("platform:mxc-mmc");
Loading