hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwspinlock/u8500_hsem.c
....@@ -16,7 +16,6 @@
1616 #include <linux/module.h>
1717 #include <linux/delay.h>
1818 #include <linux/io.h>
19
-#include <linux/pm_runtime.h>
2019 #include <linux/slab.h>
2120 #include <linux/spinlock.h>
2221 #include <linux/hwspinlock.h>
....@@ -88,21 +87,16 @@
8887 struct hwspinlock_pdata *pdata = pdev->dev.platform_data;
8988 struct hwspinlock_device *bank;
9089 struct hwspinlock *hwlock;
91
- struct resource *res;
9290 void __iomem *io_base;
93
- int i, ret, num_locks = U8500_MAX_SEMAPHORE;
91
+ int i, num_locks = U8500_MAX_SEMAPHORE;
9492 ulong val;
9593
9694 if (!pdata)
9795 return -ENODEV;
9896
99
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
100
- if (!res)
101
- return -ENODEV;
102
-
103
- io_base = ioremap(res->start, resource_size(res));
104
- if (!io_base)
105
- return -ENOMEM;
97
+ io_base = devm_platform_ioremap_resource(pdev, 0);
98
+ if (IS_ERR(io_base))
99
+ return PTR_ERR(io_base);
106100
107101 /* make sure protocol 1 is selected */
108102 val = readl(io_base + HSEM_CTRL_REG);
....@@ -111,53 +105,28 @@
111105 /* clear all interrupts */
112106 writel(0xFFFF, io_base + HSEM_ICRALL);
113107
114
- bank = kzalloc(struct_size(bank, lock, num_locks), GFP_KERNEL);
115
- if (!bank) {
116
- ret = -ENOMEM;
117
- goto iounmap_base;
118
- }
108
+ bank = devm_kzalloc(&pdev->dev, struct_size(bank, lock, num_locks),
109
+ GFP_KERNEL);
110
+ if (!bank)
111
+ return -ENOMEM;
119112
120113 platform_set_drvdata(pdev, bank);
121114
122115 for (i = 0, hwlock = &bank->lock[0]; i < num_locks; i++, hwlock++)
123116 hwlock->priv = io_base + HSEM_REGISTER_OFFSET + sizeof(u32) * i;
124117
125
- /* no pm needed for HSem but required to comply with hwspilock core */
126
- pm_runtime_enable(&pdev->dev);
127
-
128
- ret = hwspin_lock_register(bank, &pdev->dev, &u8500_hwspinlock_ops,
129
- pdata->base_id, num_locks);
130
- if (ret)
131
- goto reg_fail;
132
-
133
- return 0;
134
-
135
-reg_fail:
136
- pm_runtime_disable(&pdev->dev);
137
- kfree(bank);
138
-iounmap_base:
139
- iounmap(io_base);
140
- return ret;
118
+ return devm_hwspin_lock_register(&pdev->dev, bank,
119
+ &u8500_hwspinlock_ops,
120
+ pdata->base_id, num_locks);
141121 }
142122
143123 static int u8500_hsem_remove(struct platform_device *pdev)
144124 {
145125 struct hwspinlock_device *bank = platform_get_drvdata(pdev);
146126 void __iomem *io_base = bank->lock[0].priv - HSEM_REGISTER_OFFSET;
147
- int ret;
148127
149128 /* clear all interrupts */
150129 writel(0xFFFF, io_base + HSEM_ICRALL);
151
-
152
- ret = hwspin_lock_unregister(bank);
153
- if (ret) {
154
- dev_err(&pdev->dev, "%s failed: %d\n", __func__, ret);
155
- return ret;
156
- }
157
-
158
- pm_runtime_disable(&pdev->dev);
159
- iounmap(io_base);
160
- kfree(bank);
161130
162131 return 0;
163132 }