diff options
author | Hannu Heikkinen <hannuxx@iki.fi> | 2012-05-09 10:26:26 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2012-05-09 20:37:42 -0400 |
commit | 6d6467ee58b4cddd34b01d642d282a353dd57ce9 (patch) | |
tree | aff8db927d873c5810ef7d7ad004e53639480017 /drivers/spi | |
parent | 3aa450c063e29b4f4b622480e1779e5e256d8f8f (diff) |
spi/ep93xx: clean probe/remove routines
Use devm_* functions for managing devres resources.
Also use local variable irq and remove irq variable from
struct ep93xx_spi, as it is needed only in probe routine.
Acked-by: Mika Westerberg <mika.westerberg@iki.fi>
Acked-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Hannu Heikkinen <hannuxx@iki.fi>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-ep93xx.c | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c index e8055073e84d..f97f1d248800 100644 --- a/drivers/spi/spi-ep93xx.c +++ b/drivers/spi/spi-ep93xx.c | |||
@@ -76,7 +76,6 @@ | |||
76 | * @clk: clock for the controller | 76 | * @clk: clock for the controller |
77 | * @regs_base: pointer to ioremap()'d registers | 77 | * @regs_base: pointer to ioremap()'d registers |
78 | * @sspdr_phys: physical address of the SSPDR register | 78 | * @sspdr_phys: physical address of the SSPDR register |
79 | * @irq: IRQ number used by the driver | ||
80 | * @min_rate: minimum clock rate (in Hz) supported by the controller | 79 | * @min_rate: minimum clock rate (in Hz) supported by the controller |
81 | * @max_rate: maximum clock rate (in Hz) supported by the controller | 80 | * @max_rate: maximum clock rate (in Hz) supported by the controller |
82 | * @running: is the queue running | 81 | * @running: is the queue running |
@@ -114,7 +113,6 @@ struct ep93xx_spi { | |||
114 | struct clk *clk; | 113 | struct clk *clk; |
115 | void __iomem *regs_base; | 114 | void __iomem *regs_base; |
116 | unsigned long sspdr_phys; | 115 | unsigned long sspdr_phys; |
117 | int irq; | ||
118 | unsigned long min_rate; | 116 | unsigned long min_rate; |
119 | unsigned long max_rate; | 117 | unsigned long max_rate; |
120 | bool running; | 118 | bool running; |
@@ -1031,6 +1029,7 @@ static int __devinit ep93xx_spi_probe(struct platform_device *pdev) | |||
1031 | struct ep93xx_spi_info *info; | 1029 | struct ep93xx_spi_info *info; |
1032 | struct ep93xx_spi *espi; | 1030 | struct ep93xx_spi *espi; |
1033 | struct resource *res; | 1031 | struct resource *res; |
1032 | int irq; | ||
1034 | int error; | 1033 | int error; |
1035 | 1034 | ||
1036 | info = pdev->dev.platform_data; | 1035 | info = pdev->dev.platform_data; |
@@ -1070,8 +1069,8 @@ static int __devinit ep93xx_spi_probe(struct platform_device *pdev) | |||
1070 | espi->min_rate = clk_get_rate(espi->clk) / (254 * 256); | 1069 | espi->min_rate = clk_get_rate(espi->clk) / (254 * 256); |
1071 | espi->pdev = pdev; | 1070 | espi->pdev = pdev; |
1072 | 1071 | ||
1073 | espi->irq = platform_get_irq(pdev, 0); | 1072 | irq = platform_get_irq(pdev, 0); |
1074 | if (espi->irq < 0) { | 1073 | if (irq < 0) { |
1075 | error = -EBUSY; | 1074 | error = -EBUSY; |
1076 | dev_err(&pdev->dev, "failed to get irq resources\n"); | 1075 | dev_err(&pdev->dev, "failed to get irq resources\n"); |
1077 | goto fail_put_clock; | 1076 | goto fail_put_clock; |
@@ -1084,26 +1083,20 @@ static int __devinit ep93xx_spi_probe(struct platform_device *pdev) | |||
1084 | goto fail_put_clock; | 1083 | goto fail_put_clock; |
1085 | } | 1084 | } |
1086 | 1085 | ||
1087 | res = request_mem_region(res->start, resource_size(res), pdev->name); | ||
1088 | if (!res) { | ||
1089 | dev_err(&pdev->dev, "unable to request iomem resources\n"); | ||
1090 | error = -EBUSY; | ||
1091 | goto fail_put_clock; | ||
1092 | } | ||
1093 | |||
1094 | espi->sspdr_phys = res->start + SSPDR; | 1086 | espi->sspdr_phys = res->start + SSPDR; |
1095 | espi->regs_base = ioremap(res->start, resource_size(res)); | 1087 | |
1088 | espi->regs_base = devm_request_and_ioremap(&pdev->dev, res); | ||
1096 | if (!espi->regs_base) { | 1089 | if (!espi->regs_base) { |
1097 | dev_err(&pdev->dev, "failed to map resources\n"); | 1090 | dev_err(&pdev->dev, "failed to map resources\n"); |
1098 | error = -ENODEV; | 1091 | error = -ENODEV; |
1099 | goto fail_free_mem; | 1092 | goto fail_put_clock; |
1100 | } | 1093 | } |
1101 | 1094 | ||
1102 | error = request_irq(espi->irq, ep93xx_spi_interrupt, 0, | 1095 | error = devm_request_irq(&pdev->dev, irq, ep93xx_spi_interrupt, |
1103 | "ep93xx-spi", espi); | 1096 | 0, "ep93xx-spi", espi); |
1104 | if (error) { | 1097 | if (error) { |
1105 | dev_err(&pdev->dev, "failed to request irq\n"); | 1098 | dev_err(&pdev->dev, "failed to request irq\n"); |
1106 | goto fail_unmap_regs; | 1099 | goto fail_put_clock; |
1107 | } | 1100 | } |
1108 | 1101 | ||
1109 | if (info->use_dma && ep93xx_spi_setup_dma(espi)) | 1102 | if (info->use_dma && ep93xx_spi_setup_dma(espi)) |
@@ -1128,7 +1121,7 @@ static int __devinit ep93xx_spi_probe(struct platform_device *pdev) | |||
1128 | } | 1121 | } |
1129 | 1122 | ||
1130 | dev_info(&pdev->dev, "EP93xx SPI Controller at 0x%08lx irq %d\n", | 1123 | dev_info(&pdev->dev, "EP93xx SPI Controller at 0x%08lx irq %d\n", |
1131 | (unsigned long)res->start, espi->irq); | 1124 | (unsigned long)res->start, irq); |
1132 | 1125 | ||
1133 | return 0; | 1126 | return 0; |
1134 | 1127 | ||
@@ -1136,11 +1129,6 @@ fail_free_queue: | |||
1136 | destroy_workqueue(espi->wq); | 1129 | destroy_workqueue(espi->wq); |
1137 | fail_free_dma: | 1130 | fail_free_dma: |
1138 | ep93xx_spi_release_dma(espi); | 1131 | ep93xx_spi_release_dma(espi); |
1139 | free_irq(espi->irq, espi); | ||
1140 | fail_unmap_regs: | ||
1141 | iounmap(espi->regs_base); | ||
1142 | fail_free_mem: | ||
1143 | release_mem_region(res->start, resource_size(res)); | ||
1144 | fail_put_clock: | 1132 | fail_put_clock: |
1145 | clk_put(espi->clk); | 1133 | clk_put(espi->clk); |
1146 | fail_release_master: | 1134 | fail_release_master: |
@@ -1154,7 +1142,6 @@ static int __devexit ep93xx_spi_remove(struct platform_device *pdev) | |||
1154 | { | 1142 | { |
1155 | struct spi_master *master = platform_get_drvdata(pdev); | 1143 | struct spi_master *master = platform_get_drvdata(pdev); |
1156 | struct ep93xx_spi *espi = spi_master_get_devdata(master); | 1144 | struct ep93xx_spi *espi = spi_master_get_devdata(master); |
1157 | struct resource *res; | ||
1158 | 1145 | ||
1159 | spin_lock_irq(&espi->lock); | 1146 | spin_lock_irq(&espi->lock); |
1160 | espi->running = false; | 1147 | espi->running = false; |
@@ -1180,10 +1167,6 @@ static int __devexit ep93xx_spi_remove(struct platform_device *pdev) | |||
1180 | spin_unlock_irq(&espi->lock); | 1167 | spin_unlock_irq(&espi->lock); |
1181 | 1168 | ||
1182 | ep93xx_spi_release_dma(espi); | 1169 | ep93xx_spi_release_dma(espi); |
1183 | free_irq(espi->irq, espi); | ||
1184 | iounmap(espi->regs_base); | ||
1185 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1186 | release_mem_region(res->start, resource_size(res)); | ||
1187 | clk_put(espi->clk); | 1170 | clk_put(espi->clk); |
1188 | platform_set_drvdata(pdev, NULL); | 1171 | platform_set_drvdata(pdev, NULL); |
1189 | 1172 | ||