diff options
author | Magnus Damm <damm@opensource.se> | 2011-05-06 07:02:33 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2011-05-24 23:53:52 -0400 |
commit | 8e7bfdb37ac001c95d2c768932b57de1019409cd (patch) | |
tree | 8b91c25442de01ce415563ae60ee30eb8d7e6e3c /drivers | |
parent | df3ef2d3c92c0a562ebde3699af7d12401fddf60 (diff) |
mmc: tmio/sdhi: break out interrupt request/free
Move request_irq()/free_irq() from the shared code
in tmio_mmc.c into the SDHI/tmio specific portion
in sh_mobile_sdhi.c and tmio_mmc_pio.c.
This is ground work to allow us to adjust the SDHI
code with IRQ flags and number of interupt sources.
Signed-off-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/mmc/host/sh_mobile_sdhi.c | 18 | ||||
-rw-r--r-- | drivers/mmc/host/tmio_mmc.c | 21 | ||||
-rw-r--r-- | drivers/mmc/host/tmio_mmc.h | 2 | ||||
-rw-r--r-- | drivers/mmc/host/tmio_mmc_pio.c | 17 |
4 files changed, 37 insertions, 21 deletions
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index f60e954dec64..9ee51ace6f70 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c | |||
@@ -62,7 +62,7 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
62 | struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; | 62 | struct sh_mobile_sdhi_info *p = pdev->dev.platform_data; |
63 | struct tmio_mmc_host *host; | 63 | struct tmio_mmc_host *host; |
64 | char clk_name[8]; | 64 | char clk_name[8]; |
65 | int ret; | 65 | int irq, ret; |
66 | 66 | ||
67 | priv = kzalloc(sizeof(struct sh_mobile_sdhi), GFP_KERNEL); | 67 | priv = kzalloc(sizeof(struct sh_mobile_sdhi), GFP_KERNEL); |
68 | if (priv == NULL) { | 68 | if (priv == NULL) { |
@@ -116,11 +116,24 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
116 | if (ret < 0) | 116 | if (ret < 0) |
117 | goto eprobe; | 117 | goto eprobe; |
118 | 118 | ||
119 | irq = platform_get_irq(pdev, 0); | ||
120 | if (irq < 0) { | ||
121 | ret = irq; | ||
122 | goto eirq; | ||
123 | } | ||
124 | |||
125 | ret = request_irq(irq, tmio_mmc_irq, IRQF_DISABLED | | ||
126 | IRQF_TRIGGER_FALLING, dev_name(&pdev->dev), host); | ||
127 | if (ret) | ||
128 | goto eirq; | ||
129 | |||
119 | pr_info("%s at 0x%08lx irq %d\n", mmc_hostname(host->mmc), | 130 | pr_info("%s at 0x%08lx irq %d\n", mmc_hostname(host->mmc), |
120 | (unsigned long)host->ctl, host->irq); | 131 | (unsigned long)host->ctl, irq); |
121 | 132 | ||
122 | return ret; | 133 | return ret; |
123 | 134 | ||
135 | eirq: | ||
136 | tmio_mmc_host_remove(host); | ||
124 | eprobe: | 137 | eprobe: |
125 | clk_disable(priv->clk); | 138 | clk_disable(priv->clk); |
126 | clk_put(priv->clk); | 139 | clk_put(priv->clk); |
@@ -135,6 +148,7 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev) | |||
135 | struct tmio_mmc_host *host = mmc_priv(mmc); | 148 | struct tmio_mmc_host *host = mmc_priv(mmc); |
136 | struct sh_mobile_sdhi *priv = container_of(host->pdata, struct sh_mobile_sdhi, mmc_data); | 149 | struct sh_mobile_sdhi *priv = container_of(host->pdata, struct sh_mobile_sdhi, mmc_data); |
137 | 150 | ||
151 | free_irq(platform_get_irq(pdev, 0), host); | ||
138 | tmio_mmc_host_remove(host); | 152 | tmio_mmc_host_remove(host); |
139 | clk_disable(priv->clk); | 153 | clk_disable(priv->clk); |
140 | clk_put(priv->clk); | 154 | clk_put(priv->clk); |
diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c index be739f7ef422..14479f9ef53f 100644 --- a/drivers/mmc/host/tmio_mmc.c +++ b/drivers/mmc/host/tmio_mmc.c | |||
@@ -64,7 +64,7 @@ static int __devinit tmio_mmc_probe(struct platform_device *pdev) | |||
64 | const struct mfd_cell *cell = mfd_get_cell(pdev); | 64 | const struct mfd_cell *cell = mfd_get_cell(pdev); |
65 | struct tmio_mmc_data *pdata; | 65 | struct tmio_mmc_data *pdata; |
66 | struct tmio_mmc_host *host; | 66 | struct tmio_mmc_host *host; |
67 | int ret = -EINVAL; | 67 | int ret = -EINVAL, irq; |
68 | 68 | ||
69 | if (pdev->num_resources != 2) | 69 | if (pdev->num_resources != 2) |
70 | goto out; | 70 | goto out; |
@@ -73,6 +73,12 @@ static int __devinit tmio_mmc_probe(struct platform_device *pdev) | |||
73 | if (!pdata || !pdata->hclk) | 73 | if (!pdata || !pdata->hclk) |
74 | goto out; | 74 | goto out; |
75 | 75 | ||
76 | irq = platform_get_irq(pdev, 0); | ||
77 | if (irq < 0) { | ||
78 | ret = irq; | ||
79 | goto out; | ||
80 | } | ||
81 | |||
76 | /* Tell the MFD core we are ready to be enabled */ | 82 | /* Tell the MFD core we are ready to be enabled */ |
77 | if (cell->enable) { | 83 | if (cell->enable) { |
78 | ret = cell->enable(pdev); | 84 | ret = cell->enable(pdev); |
@@ -84,11 +90,18 @@ static int __devinit tmio_mmc_probe(struct platform_device *pdev) | |||
84 | if (ret) | 90 | if (ret) |
85 | goto cell_disable; | 91 | goto cell_disable; |
86 | 92 | ||
93 | ret = request_irq(irq, tmio_mmc_irq, IRQF_DISABLED | | ||
94 | IRQF_TRIGGER_FALLING, dev_name(&pdev->dev), host); | ||
95 | if (ret) | ||
96 | goto host_remove; | ||
97 | |||
87 | pr_info("%s at 0x%08lx irq %d\n", mmc_hostname(host->mmc), | 98 | pr_info("%s at 0x%08lx irq %d\n", mmc_hostname(host->mmc), |
88 | (unsigned long)host->ctl, host->irq); | 99 | (unsigned long)host->ctl, irq); |
89 | 100 | ||
90 | return 0; | 101 | return 0; |
91 | 102 | ||
103 | host_remove: | ||
104 | tmio_mmc_host_remove(host); | ||
92 | cell_disable: | 105 | cell_disable: |
93 | if (cell->disable) | 106 | if (cell->disable) |
94 | cell->disable(pdev); | 107 | cell->disable(pdev); |
@@ -104,7 +117,9 @@ static int __devexit tmio_mmc_remove(struct platform_device *pdev) | |||
104 | platform_set_drvdata(pdev, NULL); | 117 | platform_set_drvdata(pdev, NULL); |
105 | 118 | ||
106 | if (mmc) { | 119 | if (mmc) { |
107 | tmio_mmc_host_remove(mmc_priv(mmc)); | 120 | struct tmio_mmc_host *host = mmc_priv(mmc); |
121 | free_irq(platform_get_irq(pdev, 0), host); | ||
122 | tmio_mmc_host_remove(host); | ||
108 | if (cell->disable) | 123 | if (cell->disable) |
109 | cell->disable(pdev); | 124 | cell->disable(pdev); |
110 | } | 125 | } |
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index 58138a203877..c6bf726c8f44 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h | |||
@@ -45,7 +45,6 @@ struct tmio_mmc_host { | |||
45 | struct mmc_request *mrq; | 45 | struct mmc_request *mrq; |
46 | struct mmc_data *data; | 46 | struct mmc_data *data; |
47 | struct mmc_host *mmc; | 47 | struct mmc_host *mmc; |
48 | int irq; | ||
49 | unsigned int sdio_irq_enabled; | 48 | unsigned int sdio_irq_enabled; |
50 | 49 | ||
51 | /* Callbacks for clock / power control */ | 50 | /* Callbacks for clock / power control */ |
@@ -86,6 +85,7 @@ void tmio_mmc_do_data_irq(struct tmio_mmc_host *host); | |||
86 | 85 | ||
87 | void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i); | 86 | void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i); |
88 | void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i); | 87 | void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i); |
88 | irqreturn_t tmio_mmc_irq(int irq, void *devid); | ||
89 | 89 | ||
90 | static inline char *tmio_mmc_kmap_atomic(struct scatterlist *sg, | 90 | static inline char *tmio_mmc_kmap_atomic(struct scatterlist *sg, |
91 | unsigned long *flags) | 91 | unsigned long *flags) |
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index ea6ade31bcc7..af5d4f6d2233 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c | |||
@@ -564,7 +564,7 @@ out: | |||
564 | spin_unlock(&host->lock); | 564 | spin_unlock(&host->lock); |
565 | } | 565 | } |
566 | 566 | ||
567 | static irqreturn_t tmio_mmc_irq(int irq, void *devid) | 567 | irqreturn_t tmio_mmc_irq(int irq, void *devid) |
568 | { | 568 | { |
569 | struct tmio_mmc_host *host = devid; | 569 | struct tmio_mmc_host *host = devid; |
570 | struct tmio_mmc_data *pdata = host->pdata; | 570 | struct tmio_mmc_data *pdata = host->pdata; |
@@ -659,6 +659,7 @@ static irqreturn_t tmio_mmc_irq(int irq, void *devid) | |||
659 | out: | 659 | out: |
660 | return IRQ_HANDLED; | 660 | return IRQ_HANDLED; |
661 | } | 661 | } |
662 | EXPORT_SYMBOL(tmio_mmc_irq); | ||
662 | 663 | ||
663 | static int tmio_mmc_start_data(struct tmio_mmc_host *host, | 664 | static int tmio_mmc_start_data(struct tmio_mmc_host *host, |
664 | struct mmc_data *data) | 665 | struct mmc_data *data) |
@@ -893,21 +894,10 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, | |||
893 | tmio_mmc_clk_stop(_host); | 894 | tmio_mmc_clk_stop(_host); |
894 | tmio_mmc_reset(_host); | 895 | tmio_mmc_reset(_host); |
895 | 896 | ||
896 | ret = platform_get_irq(pdev, 0); | ||
897 | if (ret < 0) | ||
898 | goto pm_suspend; | ||
899 | |||
900 | _host->irq = ret; | ||
901 | |||
902 | tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL); | 897 | tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL); |
903 | if (pdata->flags & TMIO_MMC_SDIO_IRQ) | 898 | if (pdata->flags & TMIO_MMC_SDIO_IRQ) |
904 | tmio_mmc_enable_sdio_irq(mmc, 0); | 899 | tmio_mmc_enable_sdio_irq(mmc, 0); |
905 | 900 | ||
906 | ret = request_irq(_host->irq, tmio_mmc_irq, IRQF_DISABLED | | ||
907 | IRQF_TRIGGER_FALLING, dev_name(&pdev->dev), _host); | ||
908 | if (ret) | ||
909 | goto pm_suspend; | ||
910 | |||
911 | spin_lock_init(&_host->lock); | 901 | spin_lock_init(&_host->lock); |
912 | 902 | ||
913 | /* Init delayed work for request timeouts */ | 903 | /* Init delayed work for request timeouts */ |
@@ -933,8 +923,6 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, | |||
933 | 923 | ||
934 | return 0; | 924 | return 0; |
935 | 925 | ||
936 | pm_suspend: | ||
937 | pm_runtime_suspend(&pdev->dev); | ||
938 | pm_disable: | 926 | pm_disable: |
939 | pm_runtime_disable(&pdev->dev); | 927 | pm_runtime_disable(&pdev->dev); |
940 | iounmap(_host->ctl); | 928 | iounmap(_host->ctl); |
@@ -952,7 +940,6 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host) | |||
952 | mmc_remove_host(host->mmc); | 940 | mmc_remove_host(host->mmc); |
953 | cancel_delayed_work_sync(&host->delayed_reset_work); | 941 | cancel_delayed_work_sync(&host->delayed_reset_work); |
954 | tmio_mmc_release_dma(host); | 942 | tmio_mmc_release_dma(host); |
955 | free_irq(host->irq, host); | ||
956 | iounmap(host->ctl); | 943 | iounmap(host->ctl); |
957 | mmc_free_host(host->mmc); | 944 | mmc_free_host(host->mmc); |
958 | 945 | ||