diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2012-04-10 16:09:52 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@secretlab.ca> | 2012-04-10 16:09:56 -0400 |
commit | aae730dfe239f1a5122ba873b54dffc20a516775 (patch) | |
tree | 83ac8a15b6e25569c34f53fd1d246968a2d536ca /drivers/spi | |
parent | 0034102808e0dbbf3a2394b82b1bb40b5778de9e (diff) | |
parent | 1a77b127ae147f5827043a9896d7f4cb248b402e (diff) |
Merge branch 'spi' of git://gitorious.org/linus-tree/linus-tree into spi/next
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi-omap2-mcspi.c | 46 |
1 files changed, 9 insertions, 37 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index bb9274c2526d..33f54cd07fe0 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c | |||
@@ -791,7 +791,7 @@ static int omap2_mcspi_setup(struct spi_device *spi) | |||
791 | mcspi_dma = &mcspi->dma_channels[spi->chip_select]; | 791 | mcspi_dma = &mcspi->dma_channels[spi->chip_select]; |
792 | 792 | ||
793 | if (!cs) { | 793 | if (!cs) { |
794 | cs = kzalloc(sizeof *cs, GFP_KERNEL); | 794 | cs = devm_kzalloc(&spi->dev , sizeof *cs, GFP_KERNEL); |
795 | if (!cs) | 795 | if (!cs) |
796 | return -ENOMEM; | 796 | return -ENOMEM; |
797 | cs->base = mcspi->base + spi->chip_select * 0x14; | 797 | cs->base = mcspi->base + spi->chip_select * 0x14; |
@@ -833,7 +833,6 @@ static void omap2_mcspi_cleanup(struct spi_device *spi) | |||
833 | cs = spi->controller_state; | 833 | cs = spi->controller_state; |
834 | list_del(&cs->node); | 834 | list_del(&cs->node); |
835 | 835 | ||
836 | kfree(spi->controller_state); | ||
837 | } | 836 | } |
838 | 837 | ||
839 | if (spi->chip_select < spi->master->num_chipselect) { | 838 | if (spi->chip_select < spi->master->num_chipselect) { |
@@ -1102,7 +1101,7 @@ static const struct of_device_id omap_mcspi_of_match[] = { | |||
1102 | }; | 1101 | }; |
1103 | MODULE_DEVICE_TABLE(of, omap_mcspi_of_match); | 1102 | MODULE_DEVICE_TABLE(of, omap_mcspi_of_match); |
1104 | 1103 | ||
1105 | static int __init omap2_mcspi_probe(struct platform_device *pdev) | 1104 | static int __devinit omap2_mcspi_probe(struct platform_device *pdev) |
1106 | { | 1105 | { |
1107 | struct spi_master *master; | 1106 | struct spi_master *master; |
1108 | struct omap2_mcspi_platform_config *pdata; | 1107 | struct omap2_mcspi_platform_config *pdata; |
@@ -1166,17 +1165,12 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) | |||
1166 | r->start += regs_offset; | 1165 | r->start += regs_offset; |
1167 | r->end += regs_offset; | 1166 | r->end += regs_offset; |
1168 | mcspi->phys = r->start; | 1167 | mcspi->phys = r->start; |
1169 | if (!request_mem_region(r->start, resource_size(r), | ||
1170 | dev_name(&pdev->dev))) { | ||
1171 | status = -EBUSY; | ||
1172 | goto free_master; | ||
1173 | } | ||
1174 | 1168 | ||
1175 | mcspi->base = ioremap(r->start, resource_size(r)); | 1169 | mcspi->base = devm_request_and_ioremap(&pdev->dev, r); |
1176 | if (!mcspi->base) { | 1170 | if (!mcspi->base) { |
1177 | dev_dbg(&pdev->dev, "can't ioremap MCSPI\n"); | 1171 | dev_dbg(&pdev->dev, "can't ioremap MCSPI\n"); |
1178 | status = -ENOMEM; | 1172 | status = -ENOMEM; |
1179 | goto release_region; | 1173 | goto free_master; |
1180 | } | 1174 | } |
1181 | 1175 | ||
1182 | mcspi->dev = &pdev->dev; | 1176 | mcspi->dev = &pdev->dev; |
@@ -1191,7 +1185,7 @@ static int __init omap2_mcspi_probe(struct platform_device *pdev) | |||
1191 | GFP_KERNEL); | 1185 | GFP_KERNEL); |
1192 | 1186 | ||
1193 | if (mcspi->dma_channels == NULL) | 1187 | if (mcspi->dma_channels == NULL) |
1194 | goto unmap_io; | 1188 | goto free_master; |
1195 | 1189 | ||
1196 | for (i = 0; i < master->num_chipselect; i++) { | 1190 | for (i = 0; i < master->num_chipselect; i++) { |
1197 | char dma_ch_name[14]; | 1191 | char dma_ch_name[14]; |
@@ -1241,23 +1235,17 @@ disable_pm: | |||
1241 | pm_runtime_disable(&pdev->dev); | 1235 | pm_runtime_disable(&pdev->dev); |
1242 | dma_chnl_free: | 1236 | dma_chnl_free: |
1243 | kfree(mcspi->dma_channels); | 1237 | kfree(mcspi->dma_channels); |
1244 | unmap_io: | ||
1245 | iounmap(mcspi->base); | ||
1246 | release_region: | ||
1247 | release_mem_region(r->start, resource_size(r)); | ||
1248 | free_master: | 1238 | free_master: |
1249 | kfree(master); | 1239 | kfree(master); |
1250 | platform_set_drvdata(pdev, NULL); | 1240 | platform_set_drvdata(pdev, NULL); |
1251 | return status; | 1241 | return status; |
1252 | } | 1242 | } |
1253 | 1243 | ||
1254 | static int __exit omap2_mcspi_remove(struct platform_device *pdev) | 1244 | static int __devexit omap2_mcspi_remove(struct platform_device *pdev) |
1255 | { | 1245 | { |
1256 | struct spi_master *master; | 1246 | struct spi_master *master; |
1257 | struct omap2_mcspi *mcspi; | 1247 | struct omap2_mcspi *mcspi; |
1258 | struct omap2_mcspi_dma *dma_channels; | 1248 | struct omap2_mcspi_dma *dma_channels; |
1259 | struct resource *r; | ||
1260 | void __iomem *base; | ||
1261 | 1249 | ||
1262 | master = dev_get_drvdata(&pdev->dev); | 1250 | master = dev_get_drvdata(&pdev->dev); |
1263 | mcspi = spi_master_get_devdata(master); | 1251 | mcspi = spi_master_get_devdata(master); |
@@ -1265,12 +1253,8 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev) | |||
1265 | 1253 | ||
1266 | omap2_mcspi_disable_clocks(mcspi); | 1254 | omap2_mcspi_disable_clocks(mcspi); |
1267 | pm_runtime_disable(&pdev->dev); | 1255 | pm_runtime_disable(&pdev->dev); |
1268 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1269 | release_mem_region(r->start, resource_size(r)); | ||
1270 | 1256 | ||
1271 | base = mcspi->base; | ||
1272 | spi_unregister_master(master); | 1257 | spi_unregister_master(master); |
1273 | iounmap(base); | ||
1274 | kfree(dma_channels); | 1258 | kfree(dma_channels); |
1275 | destroy_workqueue(mcspi->wq); | 1259 | destroy_workqueue(mcspi->wq); |
1276 | platform_set_drvdata(pdev, NULL); | 1260 | platform_set_drvdata(pdev, NULL); |
@@ -1327,21 +1311,9 @@ static struct platform_driver omap2_mcspi_driver = { | |||
1327 | .pm = &omap2_mcspi_pm_ops, | 1311 | .pm = &omap2_mcspi_pm_ops, |
1328 | .of_match_table = omap_mcspi_of_match, | 1312 | .of_match_table = omap_mcspi_of_match, |
1329 | }, | 1313 | }, |
1330 | .remove = __exit_p(omap2_mcspi_remove), | 1314 | .probe = omap2_mcspi_probe, |
1315 | .remove = __devexit_p(omap2_mcspi_remove), | ||
1331 | }; | 1316 | }; |
1332 | 1317 | ||
1333 | 1318 | module_platform_driver(omap2_mcspi_driver); | |
1334 | static int __init omap2_mcspi_init(void) | ||
1335 | { | ||
1336 | return platform_driver_probe(&omap2_mcspi_driver, omap2_mcspi_probe); | ||
1337 | } | ||
1338 | subsys_initcall(omap2_mcspi_init); | ||
1339 | |||
1340 | static void __exit omap2_mcspi_exit(void) | ||
1341 | { | ||
1342 | platform_driver_unregister(&omap2_mcspi_driver); | ||
1343 | |||
1344 | } | ||
1345 | module_exit(omap2_mcspi_exit); | ||
1346 | |||
1347 | MODULE_LICENSE("GPL"); | 1319 | MODULE_LICENSE("GPL"); |