hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwspinlock/omap_hwspinlock.c
....@@ -76,7 +76,6 @@
7676 struct device_node *node = pdev->dev.of_node;
7777 struct hwspinlock_device *bank;
7878 struct hwspinlock *hwlock;
79
- struct resource *res;
8079 void __iomem *io_base;
8180 int num_locks, i, ret;
8281 /* Only a single hwspinlock block device is supported */
....@@ -85,13 +84,9 @@
8584 if (!node)
8685 return -ENODEV;
8786
88
- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
89
- if (!res)
90
- return -ENODEV;
91
-
92
- io_base = ioremap(res->start, resource_size(res));
93
- if (!io_base)
94
- return -ENOMEM;
87
+ io_base = devm_platform_ioremap_resource(pdev, 0);
88
+ if (IS_ERR(io_base))
89
+ return PTR_ERR(io_base);
9590
9691 /*
9792 * make sure the module is enabled and clocked before reading
....@@ -101,7 +96,7 @@
10196 ret = pm_runtime_get_sync(&pdev->dev);
10297 if (ret < 0) {
10398 pm_runtime_put_noidle(&pdev->dev);
104
- goto iounmap_base;
99
+ goto runtime_err;
105100 }
106101
107102 /* Determine number of locks */
....@@ -114,20 +109,21 @@
114109 */
115110 ret = pm_runtime_put(&pdev->dev);
116111 if (ret < 0)
117
- goto iounmap_base;
112
+ goto runtime_err;
118113
119114 /* one of the four lsb's must be set, and nothing else */
120115 if (hweight_long(i & 0xf) != 1 || i > 8) {
121116 ret = -EINVAL;
122
- goto iounmap_base;
117
+ goto runtime_err;
123118 }
124119
125120 num_locks = i * 32; /* actual number of locks in this device */
126121
127
- bank = kzalloc(struct_size(bank, lock, num_locks), GFP_KERNEL);
122
+ bank = devm_kzalloc(&pdev->dev, struct_size(bank, lock, num_locks),
123
+ GFP_KERNEL);
128124 if (!bank) {
129125 ret = -ENOMEM;
130
- goto iounmap_base;
126
+ goto runtime_err;
131127 }
132128
133129 platform_set_drvdata(pdev, bank);
....@@ -138,22 +134,21 @@
138134 ret = hwspin_lock_register(bank, &pdev->dev, &omap_hwspinlock_ops,
139135 base_id, num_locks);
140136 if (ret)
141
- goto reg_fail;
137
+ goto runtime_err;
138
+
139
+ dev_dbg(&pdev->dev, "Registered %d locks with HwSpinlock core\n",
140
+ num_locks);
142141
143142 return 0;
144143
145
-reg_fail:
146
- kfree(bank);
147
-iounmap_base:
144
+runtime_err:
148145 pm_runtime_disable(&pdev->dev);
149
- iounmap(io_base);
150146 return ret;
151147 }
152148
153149 static int omap_hwspinlock_remove(struct platform_device *pdev)
154150 {
155151 struct hwspinlock_device *bank = platform_get_drvdata(pdev);
156
- void __iomem *io_base = bank->lock[0].priv - LOCK_BASE_OFFSET;
157152 int ret;
158153
159154 ret = hwspin_lock_unregister(bank);
....@@ -163,14 +158,13 @@
163158 }
164159
165160 pm_runtime_disable(&pdev->dev);
166
- iounmap(io_base);
167
- kfree(bank);
168161
169162 return 0;
170163 }
171164
172165 static const struct of_device_id omap_hwspinlock_of_match[] = {
173166 { .compatible = "ti,omap4-hwspinlock", },
167
+ { .compatible = "ti,am654-hwspinlock", },
174168 { /* end */ },
175169 };
176170 MODULE_DEVICE_TABLE(of, omap_hwspinlock_of_match);