diff options
author | Shubhrajyoti D <shubhrajyoti@ti.com> | 2011-10-28 07:44:19 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2011-10-29 08:07:18 -0400 |
commit | 39f1b56593293a3d1d3b49b97a59337a19fef053 (patch) | |
tree | 34aad11f73193e7b3104fcc8ce1b2affbb8a76da /drivers/spi/spi-omap2-mcspi.c | |
parent | 751c925cbb3a270f9771e3945494cb44bd9e732a (diff) |
spi/omap: Correct the error path
Currently McSPI driver doesnt follow correct failure fallback steps
attempting to correct the same.
Also:
- label names changed to give meaningful names.
- Setting the driver data to NULL in remove
Signed-off-by: Hebbar, Gururaja <gururaja.hebbar@ti.com>
Signed-off-by: Shubhrajyoti D <shubhrajyoti@ti.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi/spi-omap2-mcspi.c')
-rw-r--r-- | drivers/spi/spi-omap2-mcspi.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 22e17264a20e..0b0dfb71c640 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c | |||
@@ -1115,13 +1115,13 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) | |||
1115 | mcspi->wq = alloc_workqueue(wq_name, WQ_MEM_RECLAIM, 1); | 1115 | mcspi->wq = alloc_workqueue(wq_name, WQ_MEM_RECLAIM, 1); |
1116 | if (mcspi->wq == NULL) { | 1116 | if (mcspi->wq == NULL) { |
1117 | status = -ENOMEM; | 1117 | status = -ENOMEM; |
1118 | goto err1; | 1118 | goto free_master; |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1121 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
1122 | if (r == NULL) { | 1122 | if (r == NULL) { |
1123 | status = -ENODEV; | 1123 | status = -ENODEV; |
1124 | goto err1; | 1124 | goto free_master; |
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | r->start += pdata->regs_offset; | 1127 | r->start += pdata->regs_offset; |
@@ -1130,14 +1130,14 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) | |||
1130 | if (!request_mem_region(r->start, resource_size(r), | 1130 | if (!request_mem_region(r->start, resource_size(r), |
1131 | dev_name(&pdev->dev))) { | 1131 | dev_name(&pdev->dev))) { |
1132 | status = -EBUSY; | 1132 | status = -EBUSY; |
1133 | goto err1; | 1133 | goto free_master; |
1134 | } | 1134 | } |
1135 | 1135 | ||
1136 | mcspi->base = ioremap(r->start, resource_size(r)); | 1136 | mcspi->base = ioremap(r->start, resource_size(r)); |
1137 | if (!mcspi->base) { | 1137 | if (!mcspi->base) { |
1138 | dev_dbg(&pdev->dev, "can't ioremap MCSPI\n"); | 1138 | dev_dbg(&pdev->dev, "can't ioremap MCSPI\n"); |
1139 | status = -ENOMEM; | 1139 | status = -ENOMEM; |
1140 | goto err2; | 1140 | goto release_region; |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | mcspi->dev = &pdev->dev; | 1143 | mcspi->dev = &pdev->dev; |
@@ -1152,7 +1152,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) | |||
1152 | GFP_KERNEL); | 1152 | GFP_KERNEL); |
1153 | 1153 | ||
1154 | if (mcspi->dma_channels == NULL) | 1154 | if (mcspi->dma_channels == NULL) |
1155 | goto err2; | 1155 | goto unmap_io; |
1156 | 1156 | ||
1157 | for (i = 0; i < master->num_chipselect; i++) { | 1157 | for (i = 0; i < master->num_chipselect; i++) { |
1158 | char dma_ch_name[14]; | 1158 | char dma_ch_name[14]; |
@@ -1182,26 +1182,33 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) | |||
1182 | mcspi->dma_channels[i].dma_tx_sync_dev = dma_res->start; | 1182 | mcspi->dma_channels[i].dma_tx_sync_dev = dma_res->start; |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | if (status < 0) | ||
1186 | goto dma_chnl_free; | ||
1187 | |||
1185 | pm_runtime_enable(&pdev->dev); | 1188 | pm_runtime_enable(&pdev->dev); |
1186 | 1189 | ||
1187 | if (status || omap2_mcspi_master_setup(mcspi) < 0) | 1190 | if (status || omap2_mcspi_master_setup(mcspi) < 0) |
1188 | goto err3; | 1191 | goto disable_pm; |
1189 | 1192 | ||
1190 | status = spi_register_master(master); | 1193 | status = spi_register_master(master); |
1191 | if (status < 0) | 1194 | if (status < 0) |
1192 | goto err4; | 1195 | goto err_spi_register; |
1193 | 1196 | ||
1194 | return status; | 1197 | return status; |
1195 | 1198 | ||
1196 | err4: | 1199 | err_spi_register: |
1197 | spi_master_put(master); | 1200 | spi_master_put(master); |
1198 | err3: | 1201 | disable_pm: |
1199 | pm_runtime_disable(&pdev->dev); | 1202 | pm_runtime_disable(&pdev->dev); |
1203 | dma_chnl_free: | ||
1200 | kfree(mcspi->dma_channels); | 1204 | kfree(mcspi->dma_channels); |
1201 | err2: | 1205 | unmap_io: |
1202 | release_mem_region(r->start, resource_size(r)); | ||
1203 | iounmap(mcspi->base); | 1206 | iounmap(mcspi->base); |
1204 | err1: | 1207 | release_region: |
1208 | release_mem_region(r->start, resource_size(r)); | ||
1209 | free_master: | ||
1210 | kfree(master); | ||
1211 | platform_set_drvdata(pdev, NULL); | ||
1205 | return status; | 1212 | return status; |
1206 | } | 1213 | } |
1207 | 1214 | ||
@@ -1227,6 +1234,7 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev) | |||
1227 | iounmap(base); | 1234 | iounmap(base); |
1228 | kfree(dma_channels); | 1235 | kfree(dma_channels); |
1229 | destroy_workqueue(mcspi->wq); | 1236 | destroy_workqueue(mcspi->wq); |
1237 | platform_set_drvdata(pdev, NULL); | ||
1230 | 1238 | ||
1231 | return 0; | 1239 | return 0; |
1232 | } | 1240 | } |