add support for target 3c24xx (more known as Openmoko GTA02 "Freerunner") and merge...
[openwrt/openwrt.git] / target / linux / s3c24xx / patches / 0251-My-GTA01-2.6.26-kernel-was-crashing-within-mmc_power.patch
1 From 0733a2e1b598dec898fef5066b737764170aaf62 Mon Sep 17 00:00:00 2001
2 From: Andy Green <agreen@pads.home.warmcat.com>
3 Date: Sun, 10 Aug 2008 09:27:16 +0100
4 Subject: [PATCH] My GTA01 2.6.26 kernel was crashing within mmc_power_up(), at the first
5 call to mmc_set_ios(host), due to host->ops being NULL. mmc_power_up()
6 was being called by mmc_rescan().
7
8 The only possible call path I can imagine for that is s3cmci_irq_cd
9 getting called before host->ops is set, thus calling mmc_detect_change()
10 which will schedule host->detect which is mmc_rescan.
11
12 This patch avoids the problem by moving the enable of the gpio_detect
13 interrupt to just before calling mmc_add_host(), where everything else
14 is already set up.
15
16 Signed-off-by: Cesar Eduardo Barros <cesarb@cesarb.net>
17 ---
18 drivers/mmc/host/s3cmci.c | 34 +++++++++++++++++-----------------
19 1 files changed, 17 insertions(+), 17 deletions(-)
20
21 diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c
22 index 9ef4d5b..107847a 100644
23 --- a/drivers/mmc/host/s3cmci.c
24 +++ b/drivers/mmc/host/s3cmci.c
25 @@ -1226,17 +1226,6 @@ static int s3cmci_probe(struct platform_device *pdev, int is2440)
26
27 disable_irq(host->irq);
28
29 - s3c2410_gpio_cfgpin(host->pdata->gpio_detect, S3C2410_GPIO_IRQ);
30 - set_irq_type(host->irq_cd, IRQT_BOTHEDGE);
31 -
32 - if (request_irq(host->irq_cd, s3cmci_irq_cd, 0, DRIVER_NAME, host)) {
33 - dev_err(&pdev->dev,
34 - "failed to request card detect interrupt.\n");
35 -
36 - ret = -ENOENT;
37 - goto probe_free_irq;
38 - }
39 -
40 if (host->pdata->gpio_wprotect)
41 s3c2410_gpio_cfgpin(host->pdata->gpio_wprotect,
42 S3C2410_GPIO_INPUT);
43 @@ -1244,7 +1233,7 @@ static int s3cmci_probe(struct platform_device *pdev, int is2440)
44 if (s3c2410_dma_request(host->dma, &s3cmci_dma_client, NULL)) {
45 dev_err(&pdev->dev, "unable to get DMA channel.\n");
46 ret = -EBUSY;
47 - goto probe_free_irq_cd;
48 + goto probe_free_irq;
49 }
50
51 host->clk = clk_get(&pdev->dev, "sdi");
52 @@ -1281,10 +1270,21 @@ static int s3cmci_probe(struct platform_device *pdev, int is2440)
53 "irq_cd:%u dma:%u.\n", (host->is2440?"2440":""),
54 host->base, host->irq, host->irq_cd, host->dma);
55
56 + s3c2410_gpio_cfgpin(host->pdata->gpio_detect, S3C2410_GPIO_IRQ);
57 + set_irq_type(host->irq_cd, IRQT_BOTHEDGE);
58 +
59 + if (request_irq(host->irq_cd, s3cmci_irq_cd, 0, DRIVER_NAME, host)) {
60 + dev_err(&pdev->dev,
61 + "failed to request card detect interrupt.\n");
62 +
63 + ret = -ENOENT;
64 + goto probe_disable_clk;
65 + }
66 +
67 ret = mmc_add_host(mmc);
68 if (ret) {
69 dev_err(&pdev->dev, "failed to add mmc host.\n");
70 - goto probe_disable_clk;
71 + goto probe_free_irq_cd;
72 }
73
74 platform_set_drvdata(pdev, mmc);
75 @@ -1292,15 +1292,15 @@ static int s3cmci_probe(struct platform_device *pdev, int is2440)
76 dev_info(&pdev->dev, "initialisation done.\n");
77 return 0;
78
79 + probe_free_irq_cd:
80 + free_irq(host->irq_cd, host);
81 +
82 probe_disable_clk:
83 clk_disable(host->clk);
84
85 probe_free_clk:
86 clk_put(host->clk);
87
88 - probe_free_irq_cd:
89 - free_irq(host->irq_cd, host);
90 -
91 probe_free_dma:
92 s3c2410_dma_free(host->dma, &s3cmci_dma_client);
93
94 @@ -1325,10 +1325,10 @@ static int s3cmci_remove(struct platform_device *pdev)
95 struct s3cmci_host *host = mmc_priv(mmc);
96
97 mmc_remove_host(mmc);
98 + free_irq(host->irq_cd, host);
99 clk_disable(host->clk);
100 clk_put(host->clk);
101 s3c2410_dma_free(host->dma, &s3cmci_dma_client);
102 - free_irq(host->irq_cd, host);
103 free_irq(host->irq, host);
104 iounmap(host->base);
105 release_mem_region(host->mem->start, RESSIZE(host->mem));
106 --
107 1.5.6.3
108