.. | .. |
---|
9 | 9 | #include <linux/module.h> |
---|
10 | 10 | #include <linux/device.h> |
---|
11 | 11 | #include <linux/io.h> |
---|
12 | | -#include <linux/pm_runtime.h> |
---|
13 | 12 | #include <linux/slab.h> |
---|
14 | 13 | #include <linux/spinlock.h> |
---|
15 | 14 | #include <linux/hwspinlock.h> |
---|
.. | .. |
---|
56 | 55 | { |
---|
57 | 56 | struct sirf_hwspinlock *hwspin; |
---|
58 | 57 | struct hwspinlock *hwlock; |
---|
59 | | - int idx, ret; |
---|
| 58 | + int idx; |
---|
60 | 59 | |
---|
61 | 60 | if (!pdev->dev.of_node) |
---|
62 | 61 | return -ENODEV; |
---|
.. | .. |
---|
69 | 68 | return -ENOMEM; |
---|
70 | 69 | |
---|
71 | 70 | /* retrieve io base */ |
---|
72 | | - hwspin->io_base = of_iomap(pdev->dev.of_node, 0); |
---|
73 | | - if (!hwspin->io_base) |
---|
74 | | - return -ENOMEM; |
---|
| 71 | + hwspin->io_base = devm_platform_ioremap_resource(pdev, 0); |
---|
| 72 | + if (IS_ERR(hwspin->io_base)) |
---|
| 73 | + return PTR_ERR(hwspin->io_base); |
---|
75 | 74 | |
---|
76 | 75 | for (idx = 0; idx < HW_SPINLOCK_NUMBER; idx++) { |
---|
77 | 76 | hwlock = &hwspin->bank.lock[idx]; |
---|
.. | .. |
---|
80 | 79 | |
---|
81 | 80 | platform_set_drvdata(pdev, hwspin); |
---|
82 | 81 | |
---|
83 | | - pm_runtime_enable(&pdev->dev); |
---|
84 | | - |
---|
85 | | - ret = hwspin_lock_register(&hwspin->bank, &pdev->dev, |
---|
86 | | - &sirf_hwspinlock_ops, 0, |
---|
87 | | - HW_SPINLOCK_NUMBER); |
---|
88 | | - if (ret) |
---|
89 | | - goto reg_failed; |
---|
90 | | - |
---|
91 | | - return 0; |
---|
92 | | - |
---|
93 | | -reg_failed: |
---|
94 | | - pm_runtime_disable(&pdev->dev); |
---|
95 | | - iounmap(hwspin->io_base); |
---|
96 | | - |
---|
97 | | - return ret; |
---|
98 | | -} |
---|
99 | | - |
---|
100 | | -static int sirf_hwspinlock_remove(struct platform_device *pdev) |
---|
101 | | -{ |
---|
102 | | - struct sirf_hwspinlock *hwspin = platform_get_drvdata(pdev); |
---|
103 | | - int ret; |
---|
104 | | - |
---|
105 | | - ret = hwspin_lock_unregister(&hwspin->bank); |
---|
106 | | - if (ret) { |
---|
107 | | - dev_err(&pdev->dev, "%s failed: %d\n", __func__, ret); |
---|
108 | | - return ret; |
---|
109 | | - } |
---|
110 | | - |
---|
111 | | - pm_runtime_disable(&pdev->dev); |
---|
112 | | - |
---|
113 | | - iounmap(hwspin->io_base); |
---|
114 | | - |
---|
115 | | - return 0; |
---|
| 82 | + return devm_hwspin_lock_register(&pdev->dev, &hwspin->bank, |
---|
| 83 | + &sirf_hwspinlock_ops, 0, |
---|
| 84 | + HW_SPINLOCK_NUMBER); |
---|
116 | 85 | } |
---|
117 | 86 | |
---|
118 | 87 | static const struct of_device_id sirf_hwpinlock_ids[] = { |
---|
.. | .. |
---|
123 | 92 | |
---|
124 | 93 | static struct platform_driver sirf_hwspinlock_driver = { |
---|
125 | 94 | .probe = sirf_hwspinlock_probe, |
---|
126 | | - .remove = sirf_hwspinlock_remove, |
---|
127 | 95 | .driver = { |
---|
128 | 96 | .name = "atlas7_hwspinlock", |
---|
129 | 97 | .of_match_table = of_match_ptr(sirf_hwpinlock_ids), |
---|