diff options
author | Thomas Abraham <thomas.abraham@linaro.org> | 2012-09-17 14:16:35 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2012-10-03 10:05:13 -0400 |
commit | 4a90920c6b39a3af26470cfc26b8e5ec9c4e7f3c (patch) | |
tree | 1813a9972f2ec1c8129c68eb969ea7066ddfaec3 | |
parent | 950d56acce5d401f477b91d0177605b543d63d07 (diff) |
mmc: dw_mmc: convert copy of struct device in struct dw_mci to a reference
The 'struct dw_mci' maintains a copy of the pdev->dev instance instead of
maintaining a reference to that 'struct device' instance. Any resource
allocated using the device resource management kernel API with the instance
of 'struct device' in 'struct dw_mci' is then incorrect. Fix this by
converting the copy of 'struct device' in 'struct dw_mci' to a reference.
Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
Acked-by: Will Newton <will.newton@imgtec.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r-- | drivers/mmc/host/dw_mmc-pci.c | 2 | ||||
-rw-r--r-- | drivers/mmc/host/dw_mmc-pltfm.c | 2 | ||||
-rw-r--r-- | drivers/mmc/host/dw_mmc.c | 56 | ||||
-rw-r--r-- | include/linux/mmc/dw_mmc.h | 2 |
4 files changed, 31 insertions, 31 deletions
diff --git a/drivers/mmc/host/dw_mmc-pci.c b/drivers/mmc/host/dw_mmc-pci.c index f5ab03d32fb9..edb37e9135ae 100644 --- a/drivers/mmc/host/dw_mmc-pci.c +++ b/drivers/mmc/host/dw_mmc-pci.c | |||
@@ -59,7 +59,7 @@ static int __devinit dw_mci_pci_probe(struct pci_dev *pdev, | |||
59 | 59 | ||
60 | host->irq = pdev->irq; | 60 | host->irq = pdev->irq; |
61 | host->irq_flags = IRQF_SHARED; | 61 | host->irq_flags = IRQF_SHARED; |
62 | host->dev = pdev->dev; | 62 | host->dev = &pdev->dev; |
63 | host->pdata = &pci_board_data; | 63 | host->pdata = &pci_board_data; |
64 | 64 | ||
65 | host->regs = pci_iomap(pdev, PCI_BAR_NO, COMPLETE_BAR); | 65 | host->regs = pci_iomap(pdev, PCI_BAR_NO, COMPLETE_BAR); |
diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c index a54d3a359ccd..528d37b93651 100644 --- a/drivers/mmc/host/dw_mmc-pltfm.c +++ b/drivers/mmc/host/dw_mmc-pltfm.c | |||
@@ -43,7 +43,7 @@ static int __devinit dw_mci_pltfm_probe(struct platform_device *pdev) | |||
43 | goto err_free; | 43 | goto err_free; |
44 | } | 44 | } |
45 | 45 | ||
46 | host->dev = pdev->dev; | 46 | host->dev = &pdev->dev; |
47 | host->irq_flags = 0; | 47 | host->irq_flags = 0; |
48 | host->pdata = pdev->dev.platform_data; | 48 | host->pdata = pdev->dev.platform_data; |
49 | ret = -ENOMEM; | 49 | ret = -ENOMEM; |
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 36f98c09715e..a18e73c7305e 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c | |||
@@ -266,7 +266,7 @@ static void dw_mci_start_command(struct dw_mci *host, | |||
266 | struct mmc_command *cmd, u32 cmd_flags) | 266 | struct mmc_command *cmd, u32 cmd_flags) |
267 | { | 267 | { |
268 | host->cmd = cmd; | 268 | host->cmd = cmd; |
269 | dev_vdbg(&host->dev, | 269 | dev_vdbg(host->dev, |
270 | "start command: ARGR=0x%08x CMDR=0x%08x\n", | 270 | "start command: ARGR=0x%08x CMDR=0x%08x\n", |
271 | cmd->arg, cmd_flags); | 271 | cmd->arg, cmd_flags); |
272 | 272 | ||
@@ -308,7 +308,7 @@ static void dw_mci_dma_cleanup(struct dw_mci *host) | |||
308 | 308 | ||
309 | if (data) | 309 | if (data) |
310 | if (!data->host_cookie) | 310 | if (!data->host_cookie) |
311 | dma_unmap_sg(&host->dev, | 311 | dma_unmap_sg(host->dev, |
312 | data->sg, | 312 | data->sg, |
313 | data->sg_len, | 313 | data->sg_len, |
314 | dw_mci_get_dma_dir(data)); | 314 | dw_mci_get_dma_dir(data)); |
@@ -334,7 +334,7 @@ static void dw_mci_idmac_complete_dma(struct dw_mci *host) | |||
334 | { | 334 | { |
335 | struct mmc_data *data = host->data; | 335 | struct mmc_data *data = host->data; |
336 | 336 | ||
337 | dev_vdbg(&host->dev, "DMA complete\n"); | 337 | dev_vdbg(host->dev, "DMA complete\n"); |
338 | 338 | ||
339 | host->dma_ops->cleanup(host); | 339 | host->dma_ops->cleanup(host); |
340 | 340 | ||
@@ -414,13 +414,13 @@ static int dw_mci_idmac_init(struct dw_mci *host) | |||
414 | dma_support = (mci_readl(host, HCON) >> 16) & 0x3; | 414 | dma_support = (mci_readl(host, HCON) >> 16) & 0x3; |
415 | 415 | ||
416 | if (!dma_support || dma_support > 2) { | 416 | if (!dma_support || dma_support > 2) { |
417 | dev_err(&host->dev, | 417 | dev_err(host->dev, |
418 | "Host Controller does not support IDMA Tx.\n"); | 418 | "Host Controller does not support IDMA Tx.\n"); |
419 | host->dma_ops = NULL; | 419 | host->dma_ops = NULL; |
420 | return -ENODEV; | 420 | return -ENODEV; |
421 | } | 421 | } |
422 | 422 | ||
423 | dev_info(&host->dev, "Using internal DMA controller.\n"); | 423 | dev_info(host->dev, "Using internal DMA controller.\n"); |
424 | 424 | ||
425 | /* Forward link the descriptor list */ | 425 | /* Forward link the descriptor list */ |
426 | for (i = 0, p = host->sg_cpu; i < host->ring_size - 1; i++, p++) | 426 | for (i = 0, p = host->sg_cpu; i < host->ring_size - 1; i++, p++) |
@@ -476,7 +476,7 @@ static int dw_mci_pre_dma_transfer(struct dw_mci *host, | |||
476 | return -EINVAL; | 476 | return -EINVAL; |
477 | } | 477 | } |
478 | 478 | ||
479 | sg_len = dma_map_sg(&host->dev, | 479 | sg_len = dma_map_sg(host->dev, |
480 | data->sg, | 480 | data->sg, |
481 | data->sg_len, | 481 | data->sg_len, |
482 | dw_mci_get_dma_dir(data)); | 482 | dw_mci_get_dma_dir(data)); |
@@ -519,7 +519,7 @@ static void dw_mci_post_req(struct mmc_host *mmc, | |||
519 | return; | 519 | return; |
520 | 520 | ||
521 | if (data->host_cookie) | 521 | if (data->host_cookie) |
522 | dma_unmap_sg(&slot->host->dev, | 522 | dma_unmap_sg(slot->host->dev, |
523 | data->sg, | 523 | data->sg, |
524 | data->sg_len, | 524 | data->sg_len, |
525 | dw_mci_get_dma_dir(data)); | 525 | dw_mci_get_dma_dir(data)); |
@@ -545,7 +545,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) | |||
545 | 545 | ||
546 | host->using_dma = 1; | 546 | host->using_dma = 1; |
547 | 547 | ||
548 | dev_vdbg(&host->dev, | 548 | dev_vdbg(host->dev, |
549 | "sd sg_cpu: %#lx sg_dma: %#lx sg_len: %d\n", | 549 | "sd sg_cpu: %#lx sg_dma: %#lx sg_len: %d\n", |
550 | (unsigned long)host->sg_cpu, (unsigned long)host->sg_dma, | 550 | (unsigned long)host->sg_cpu, (unsigned long)host->sg_dma, |
551 | sg_len); | 551 | sg_len); |
@@ -939,12 +939,12 @@ static void dw_mci_request_end(struct dw_mci *host, struct mmc_request *mrq) | |||
939 | slot = list_entry(host->queue.next, | 939 | slot = list_entry(host->queue.next, |
940 | struct dw_mci_slot, queue_node); | 940 | struct dw_mci_slot, queue_node); |
941 | list_del(&slot->queue_node); | 941 | list_del(&slot->queue_node); |
942 | dev_vdbg(&host->dev, "list not empty: %s is next\n", | 942 | dev_vdbg(host->dev, "list not empty: %s is next\n", |
943 | mmc_hostname(slot->mmc)); | 943 | mmc_hostname(slot->mmc)); |
944 | host->state = STATE_SENDING_CMD; | 944 | host->state = STATE_SENDING_CMD; |
945 | dw_mci_start_request(host, slot); | 945 | dw_mci_start_request(host, slot); |
946 | } else { | 946 | } else { |
947 | dev_vdbg(&host->dev, "list empty\n"); | 947 | dev_vdbg(host->dev, "list empty\n"); |
948 | host->state = STATE_IDLE; | 948 | host->state = STATE_IDLE; |
949 | } | 949 | } |
950 | 950 | ||
@@ -1083,7 +1083,7 @@ static void dw_mci_tasklet_func(unsigned long priv) | |||
1083 | data->bytes_xfered = 0; | 1083 | data->bytes_xfered = 0; |
1084 | data->error = -ETIMEDOUT; | 1084 | data->error = -ETIMEDOUT; |
1085 | } else { | 1085 | } else { |
1086 | dev_err(&host->dev, | 1086 | dev_err(host->dev, |
1087 | "data FIFO error " | 1087 | "data FIFO error " |
1088 | "(status=%08x)\n", | 1088 | "(status=%08x)\n", |
1089 | status); | 1089 | status); |
@@ -1772,7 +1772,7 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1772 | struct mmc_host *mmc; | 1772 | struct mmc_host *mmc; |
1773 | struct dw_mci_slot *slot; | 1773 | struct dw_mci_slot *slot; |
1774 | 1774 | ||
1775 | mmc = mmc_alloc_host(sizeof(struct dw_mci_slot), &host->dev); | 1775 | mmc = mmc_alloc_host(sizeof(struct dw_mci_slot), host->dev); |
1776 | if (!mmc) | 1776 | if (!mmc) |
1777 | return -ENOMEM; | 1777 | return -ENOMEM; |
1778 | 1778 | ||
@@ -1884,10 +1884,10 @@ static void dw_mci_cleanup_slot(struct dw_mci_slot *slot, unsigned int id) | |||
1884 | static void dw_mci_init_dma(struct dw_mci *host) | 1884 | static void dw_mci_init_dma(struct dw_mci *host) |
1885 | { | 1885 | { |
1886 | /* Alloc memory for sg translation */ | 1886 | /* Alloc memory for sg translation */ |
1887 | host->sg_cpu = dma_alloc_coherent(&host->dev, PAGE_SIZE, | 1887 | host->sg_cpu = dma_alloc_coherent(host->dev, PAGE_SIZE, |
1888 | &host->sg_dma, GFP_KERNEL); | 1888 | &host->sg_dma, GFP_KERNEL); |
1889 | if (!host->sg_cpu) { | 1889 | if (!host->sg_cpu) { |
1890 | dev_err(&host->dev, "%s: could not alloc DMA memory\n", | 1890 | dev_err(host->dev, "%s: could not alloc DMA memory\n", |
1891 | __func__); | 1891 | __func__); |
1892 | goto no_dma; | 1892 | goto no_dma; |
1893 | } | 1893 | } |
@@ -1903,12 +1903,12 @@ static void dw_mci_init_dma(struct dw_mci *host) | |||
1903 | if (host->dma_ops->init && host->dma_ops->start && | 1903 | if (host->dma_ops->init && host->dma_ops->start && |
1904 | host->dma_ops->stop && host->dma_ops->cleanup) { | 1904 | host->dma_ops->stop && host->dma_ops->cleanup) { |
1905 | if (host->dma_ops->init(host)) { | 1905 | if (host->dma_ops->init(host)) { |
1906 | dev_err(&host->dev, "%s: Unable to initialize " | 1906 | dev_err(host->dev, "%s: Unable to initialize " |
1907 | "DMA Controller.\n", __func__); | 1907 | "DMA Controller.\n", __func__); |
1908 | goto no_dma; | 1908 | goto no_dma; |
1909 | } | 1909 | } |
1910 | } else { | 1910 | } else { |
1911 | dev_err(&host->dev, "DMA initialization not found.\n"); | 1911 | dev_err(host->dev, "DMA initialization not found.\n"); |
1912 | goto no_dma; | 1912 | goto no_dma; |
1913 | } | 1913 | } |
1914 | 1914 | ||
@@ -1916,7 +1916,7 @@ static void dw_mci_init_dma(struct dw_mci *host) | |||
1916 | return; | 1916 | return; |
1917 | 1917 | ||
1918 | no_dma: | 1918 | no_dma: |
1919 | dev_info(&host->dev, "Using PIO mode.\n"); | 1919 | dev_info(host->dev, "Using PIO mode.\n"); |
1920 | host->use_dma = 0; | 1920 | host->use_dma = 0; |
1921 | return; | 1921 | return; |
1922 | } | 1922 | } |
@@ -1948,19 +1948,19 @@ int dw_mci_probe(struct dw_mci *host) | |||
1948 | u32 fifo_size; | 1948 | u32 fifo_size; |
1949 | 1949 | ||
1950 | if (!host->pdata || !host->pdata->init) { | 1950 | if (!host->pdata || !host->pdata->init) { |
1951 | dev_err(&host->dev, | 1951 | dev_err(host->dev, |
1952 | "Platform data must supply init function\n"); | 1952 | "Platform data must supply init function\n"); |
1953 | return -ENODEV; | 1953 | return -ENODEV; |
1954 | } | 1954 | } |
1955 | 1955 | ||
1956 | if (!host->pdata->select_slot && host->pdata->num_slots > 1) { | 1956 | if (!host->pdata->select_slot && host->pdata->num_slots > 1) { |
1957 | dev_err(&host->dev, | 1957 | dev_err(host->dev, |
1958 | "Platform data must supply select_slot function\n"); | 1958 | "Platform data must supply select_slot function\n"); |
1959 | return -ENODEV; | 1959 | return -ENODEV; |
1960 | } | 1960 | } |
1961 | 1961 | ||
1962 | if (!host->pdata->bus_hz) { | 1962 | if (!host->pdata->bus_hz) { |
1963 | dev_err(&host->dev, | 1963 | dev_err(host->dev, |
1964 | "Platform data must supply bus speed\n"); | 1964 | "Platform data must supply bus speed\n"); |
1965 | return -ENODEV; | 1965 | return -ENODEV; |
1966 | } | 1966 | } |
@@ -1998,7 +1998,7 @@ int dw_mci_probe(struct dw_mci *host) | |||
1998 | } | 1998 | } |
1999 | 1999 | ||
2000 | /* Reset all blocks */ | 2000 | /* Reset all blocks */ |
2001 | if (!mci_wait_reset(&host->dev, host)) | 2001 | if (!mci_wait_reset(host->dev, host)) |
2002 | return -ENODEV; | 2002 | return -ENODEV; |
2003 | 2003 | ||
2004 | host->dma_ops = host->pdata->dma_ops; | 2004 | host->dma_ops = host->pdata->dma_ops; |
@@ -2065,7 +2065,7 @@ int dw_mci_probe(struct dw_mci *host) | |||
2065 | * Need to check the version-id and set data-offset for DATA register. | 2065 | * Need to check the version-id and set data-offset for DATA register. |
2066 | */ | 2066 | */ |
2067 | host->verid = SDMMC_GET_VERID(mci_readl(host, VERID)); | 2067 | host->verid = SDMMC_GET_VERID(mci_readl(host, VERID)); |
2068 | dev_info(&host->dev, "Version ID is %04x\n", host->verid); | 2068 | dev_info(host->dev, "Version ID is %04x\n", host->verid); |
2069 | 2069 | ||
2070 | if (host->verid < DW_MMC_240A) | 2070 | if (host->verid < DW_MMC_240A) |
2071 | host->data_offset = DATA_OFFSET; | 2071 | host->data_offset = DATA_OFFSET; |
@@ -2082,12 +2082,12 @@ int dw_mci_probe(struct dw_mci *host) | |||
2082 | DW_MCI_ERROR_FLAGS | SDMMC_INT_CD); | 2082 | DW_MCI_ERROR_FLAGS | SDMMC_INT_CD); |
2083 | mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */ | 2083 | mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */ |
2084 | 2084 | ||
2085 | dev_info(&host->dev, "DW MMC controller at irq %d, " | 2085 | dev_info(host->dev, "DW MMC controller at irq %d, " |
2086 | "%d bit host data width, " | 2086 | "%d bit host data width, " |
2087 | "%u deep fifo\n", | 2087 | "%u deep fifo\n", |
2088 | host->irq, width, fifo_size); | 2088 | host->irq, width, fifo_size); |
2089 | if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) | 2089 | if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) |
2090 | dev_info(&host->dev, "Internal DMAC interrupt fix enabled.\n"); | 2090 | dev_info(host->dev, "Internal DMAC interrupt fix enabled.\n"); |
2091 | 2091 | ||
2092 | return 0; | 2092 | return 0; |
2093 | 2093 | ||
@@ -2106,7 +2106,7 @@ err_workqueue: | |||
2106 | err_dmaunmap: | 2106 | err_dmaunmap: |
2107 | if (host->use_dma && host->dma_ops->exit) | 2107 | if (host->use_dma && host->dma_ops->exit) |
2108 | host->dma_ops->exit(host); | 2108 | host->dma_ops->exit(host); |
2109 | dma_free_coherent(&host->dev, PAGE_SIZE, | 2109 | dma_free_coherent(host->dev, PAGE_SIZE, |
2110 | host->sg_cpu, host->sg_dma); | 2110 | host->sg_cpu, host->sg_dma); |
2111 | 2111 | ||
2112 | if (host->vmmc) { | 2112 | if (host->vmmc) { |
@@ -2125,7 +2125,7 @@ void dw_mci_remove(struct dw_mci *host) | |||
2125 | mci_writel(host, INTMASK, 0); /* disable all mmc interrupt first */ | 2125 | mci_writel(host, INTMASK, 0); /* disable all mmc interrupt first */ |
2126 | 2126 | ||
2127 | for (i = 0; i < host->num_slots; i++) { | 2127 | for (i = 0; i < host->num_slots; i++) { |
2128 | dev_dbg(&host->dev, "remove slot %d\n", i); | 2128 | dev_dbg(host->dev, "remove slot %d\n", i); |
2129 | if (host->slot[i]) | 2129 | if (host->slot[i]) |
2130 | dw_mci_cleanup_slot(host->slot[i], i); | 2130 | dw_mci_cleanup_slot(host->slot[i], i); |
2131 | } | 2131 | } |
@@ -2136,7 +2136,7 @@ void dw_mci_remove(struct dw_mci *host) | |||
2136 | 2136 | ||
2137 | free_irq(host->irq, host); | 2137 | free_irq(host->irq, host); |
2138 | destroy_workqueue(host->card_workqueue); | 2138 | destroy_workqueue(host->card_workqueue); |
2139 | dma_free_coherent(&host->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); | 2139 | dma_free_coherent(host->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); |
2140 | 2140 | ||
2141 | if (host->use_dma && host->dma_ops->exit) | 2141 | if (host->use_dma && host->dma_ops->exit) |
2142 | host->dma_ops->exit(host); | 2142 | host->dma_ops->exit(host); |
@@ -2188,7 +2188,7 @@ int dw_mci_resume(struct dw_mci *host) | |||
2188 | if (host->vmmc) | 2188 | if (host->vmmc) |
2189 | regulator_enable(host->vmmc); | 2189 | regulator_enable(host->vmmc); |
2190 | 2190 | ||
2191 | if (!mci_wait_reset(&host->dev, host)) { | 2191 | if (!mci_wait_reset(host->dev, host)) { |
2192 | ret = -ENODEV; | 2192 | ret = -ENODEV; |
2193 | return ret; | 2193 | return ret; |
2194 | } | 2194 | } |
diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h index 7a7ebd367cfd..a37a573fa13c 100644 --- a/include/linux/mmc/dw_mmc.h +++ b/include/linux/mmc/dw_mmc.h | |||
@@ -156,7 +156,7 @@ struct dw_mci { | |||
156 | u32 fifoth_val; | 156 | u32 fifoth_val; |
157 | u16 verid; | 157 | u16 verid; |
158 | u16 data_offset; | 158 | u16 data_offset; |
159 | struct device dev; | 159 | struct device *dev; |
160 | struct dw_mci_board *pdata; | 160 | struct dw_mci_board *pdata; |
161 | struct dw_mci_slot *slot[MAX_MCI_SLOTS]; | 161 | struct dw_mci_slot *slot[MAX_MCI_SLOTS]; |
162 | 162 | ||