Skip to content

Commit 25f7d74

Browse files
glneoandersson
authored andcommitted
hwspinlock: omap: Use devm_pm_runtime_enable() helper
This disables runtime PM on module exit automatically for us, currently we manually disable runtime PM which can be error-prone if not done in the right order or missed in some exit path. This also allows us to simplify the probe exit path and remove callbacks. Do that here. While here, as we can now return right after registering our hwspinlock, simply return directly and remove the extra debug message. Signed-off-by: Andrew Davis <afd@ti.com> Link: https://lore.kernel.org/r/20240208165114.63148-2-afd@ti.com Signed-off-by: Bjorn Andersson <andersson@kernel.org>
1 parent 19856a0 commit 25f7d74

1 file changed

Lines changed: 8 additions & 25 deletions

File tree

drivers/hwspinlock/omap_hwspinlock.c

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ static int omap_hwspinlock_probe(struct platform_device *pdev)
8989
* make sure the module is enabled and clocked before reading
9090
* the module SYSSTATUS register
9191
*/
92-
pm_runtime_enable(&pdev->dev);
92+
devm_pm_runtime_enable(&pdev->dev);
9393
ret = pm_runtime_resume_and_get(&pdev->dev);
9494
if (ret < 0)
95-
goto runtime_err;
95+
return ret;
9696

9797
/* Determine number of locks */
9898
i = readl(io_base + SYSSTATUS_OFFSET);
@@ -104,41 +104,26 @@ static int omap_hwspinlock_probe(struct platform_device *pdev)
104104
*/
105105
ret = pm_runtime_put(&pdev->dev);
106106
if (ret < 0)
107-
goto runtime_err;
107+
return ret;
108108

109109
/* one of the four lsb's must be set, and nothing else */
110-
if (hweight_long(i & 0xf) != 1 || i > 8) {
111-
ret = -EINVAL;
112-
goto runtime_err;
113-
}
110+
if (hweight_long(i & 0xf) != 1 || i > 8)
111+
return -EINVAL;
114112

115113
num_locks = i * 32; /* actual number of locks in this device */
116114

117115
bank = devm_kzalloc(&pdev->dev, struct_size(bank, lock, num_locks),
118116
GFP_KERNEL);
119-
if (!bank) {
120-
ret = -ENOMEM;
121-
goto runtime_err;
122-
}
117+
if (!bank)
118+
return -ENOMEM;
123119

124120
platform_set_drvdata(pdev, bank);
125121

126122
for (i = 0, hwlock = &bank->lock[0]; i < num_locks; i++, hwlock++)
127123
hwlock->priv = io_base + LOCK_BASE_OFFSET + sizeof(u32) * i;
128124

129-
ret = hwspin_lock_register(bank, &pdev->dev, &omap_hwspinlock_ops,
125+
return hwspin_lock_register(bank, &pdev->dev, &omap_hwspinlock_ops,
130126
base_id, num_locks);
131-
if (ret)
132-
goto runtime_err;
133-
134-
dev_dbg(&pdev->dev, "Registered %d locks with HwSpinlock core\n",
135-
num_locks);
136-
137-
return 0;
138-
139-
runtime_err:
140-
pm_runtime_disable(&pdev->dev);
141-
return ret;
142127
}
143128

144129
static void omap_hwspinlock_remove(struct platform_device *pdev)
@@ -151,8 +136,6 @@ static void omap_hwspinlock_remove(struct platform_device *pdev)
151136
dev_err(&pdev->dev, "%s failed: %d\n", __func__, ret);
152137
return;
153138
}
154-
155-
pm_runtime_disable(&pdev->dev);
156139
}
157140

158141
static const struct of_device_id omap_hwspinlock_of_match[] = {

0 commit comments

Comments
 (0)