aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-omap2-mcspi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-omap2-mcspi.c')
-rw-r--r--drivers/spi/spi-omap2-mcspi.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 7745f91f105d..cb2c0e390b1f 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -789,7 +789,7 @@ static int omap2_mcspi_setup(struct spi_device *spi)
789 mcspi_dma = &mcspi->dma_channels[spi->chip_select]; 789 mcspi_dma = &mcspi->dma_channels[spi->chip_select];
790 790
791 if (!cs) { 791 if (!cs) {
792 cs = kzalloc(sizeof *cs, GFP_KERNEL); 792 cs = devm_kzalloc(&spi->dev , sizeof *cs, GFP_KERNEL);
793 if (!cs) 793 if (!cs)
794 return -ENOMEM; 794 return -ENOMEM;
795 cs->base = mcspi->base + spi->chip_select * 0x14; 795 cs->base = mcspi->base + spi->chip_select * 0x14;
@@ -831,7 +831,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
831 cs = spi->controller_state; 831 cs = spi->controller_state;
832 list_del(&cs->node); 832 list_del(&cs->node);
833 833
834 kfree(spi->controller_state);
835 } 834 }
836 835
837 if (spi->chip_select < spi->master->num_chipselect) { 836 if (spi->chip_select < spi->master->num_chipselect) {
@@ -1127,17 +1126,12 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
1127 r->start += pdata->regs_offset; 1126 r->start += pdata->regs_offset;
1128 r->end += pdata->regs_offset; 1127 r->end += pdata->regs_offset;
1129 mcspi->phys = r->start; 1128 mcspi->phys = r->start;
1130 if (!request_mem_region(r->start, resource_size(r),
1131 dev_name(&pdev->dev))) {
1132 status = -EBUSY;
1133 goto free_master;
1134 }
1135 1129
1136 mcspi->base = ioremap(r->start, resource_size(r)); 1130 mcspi->base = devm_request_and_ioremap(&pdev->dev, r);
1137 if (!mcspi->base) { 1131 if (!mcspi->base) {
1138 dev_dbg(&pdev->dev, "can't ioremap MCSPI\n"); 1132 dev_dbg(&pdev->dev, "can't ioremap MCSPI\n");
1139 status = -ENOMEM; 1133 status = -ENOMEM;
1140 goto release_region; 1134 goto free_master;
1141 } 1135 }
1142 1136
1143 mcspi->dev = &pdev->dev; 1137 mcspi->dev = &pdev->dev;
@@ -1152,7 +1146,7 @@ static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
1152 GFP_KERNEL); 1146 GFP_KERNEL);
1153 1147
1154 if (mcspi->dma_channels == NULL) 1148 if (mcspi->dma_channels == NULL)
1155 goto unmap_io; 1149 goto free_master;
1156 1150
1157 for (i = 0; i < master->num_chipselect; i++) { 1151 for (i = 0; i < master->num_chipselect; i++) {
1158 char dma_ch_name[14]; 1152 char dma_ch_name[14];
@@ -1202,10 +1196,6 @@ disable_pm:
1202 pm_runtime_disable(&pdev->dev); 1196 pm_runtime_disable(&pdev->dev);
1203dma_chnl_free: 1197dma_chnl_free:
1204 kfree(mcspi->dma_channels); 1198 kfree(mcspi->dma_channels);
1205unmap_io:
1206 iounmap(mcspi->base);
1207release_region:
1208 release_mem_region(r->start, resource_size(r));
1209free_master: 1199free_master:
1210 kfree(master); 1200 kfree(master);
1211 platform_set_drvdata(pdev, NULL); 1201 platform_set_drvdata(pdev, NULL);
@@ -1217,8 +1207,6 @@ static int __devexit omap2_mcspi_remove(struct platform_device *pdev)
1217 struct spi_master *master; 1207 struct spi_master *master;
1218 struct omap2_mcspi *mcspi; 1208 struct omap2_mcspi *mcspi;
1219 struct omap2_mcspi_dma *dma_channels; 1209 struct omap2_mcspi_dma *dma_channels;
1220 struct resource *r;
1221 void __iomem *base;
1222 1210
1223 master = dev_get_drvdata(&pdev->dev); 1211 master = dev_get_drvdata(&pdev->dev);
1224 mcspi = spi_master_get_devdata(master); 1212 mcspi = spi_master_get_devdata(master);
@@ -1226,12 +1214,8 @@ static int __devexit omap2_mcspi_remove(struct platform_device *pdev)
1226 1214
1227 omap2_mcspi_disable_clocks(mcspi); 1215 omap2_mcspi_disable_clocks(mcspi);
1228 pm_runtime_disable(&pdev->dev); 1216 pm_runtime_disable(&pdev->dev);
1229 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1230 release_mem_region(r->start, resource_size(r));
1231 1217
1232 base = mcspi->base;
1233 spi_unregister_master(master); 1218 spi_unregister_master(master);
1234 iounmap(base);
1235 kfree(dma_channels); 1219 kfree(dma_channels);
1236 destroy_workqueue(mcspi->wq); 1220 destroy_workqueue(mcspi->wq);
1237 platform_set_drvdata(pdev, NULL); 1221 platform_set_drvdata(pdev, NULL);