[RFC PATCH v2 06/13] hwspinlock: stm32: use new callback to initialize hwspinlock priv
Wolfram Sang
wsa+renesas at sang-engineering.com
Sun Feb 15 14:54:46 PST 2026
Apply the new helper to avoid using internal structures from the core.
Signed-off-by: Wolfram Sang <wsa+renesas at sang-engineering.com>
---
drivers/hwspinlock/stm32_hwspinlock.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/hwspinlock/stm32_hwspinlock.c b/drivers/hwspinlock/stm32_hwspinlock.c
index 1d75dc03f4ad..02db950c9450 100644
--- a/drivers/hwspinlock/stm32_hwspinlock.c
+++ b/drivers/hwspinlock/stm32_hwspinlock.c
@@ -48,10 +48,18 @@ static void stm32_hwspinlock_relax(struct hwspinlock *lock)
ndelay(50);
}
+static void *stm32_hwspinlock_init_priv(int local_id, void *init_data)
+{
+ void __iomem *io_base = init_data;
+
+ return io_base + local_id * sizeof(u32);
+}
+
static const struct hwspinlock_ops stm32_hwspinlock_ops = {
.trylock = stm32_hwspinlock_trylock,
.unlock = stm32_hwspinlock_unlock,
.relax = stm32_hwspinlock_relax,
+ .init_priv = stm32_hwspinlock_init_priv,
};
static void stm32_hwspinlock_disable_clk(void *data)
@@ -73,7 +81,7 @@ static int stm32_hwspinlock_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct stm32_hwspinlock *hw;
void __iomem *io_base;
- int i, ret;
+ int ret;
io_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(io_base))
@@ -106,11 +114,8 @@ static int stm32_hwspinlock_probe(struct platform_device *pdev)
return ret;
}
- for (i = 0; i < STM32_MUTEX_NUM_LOCKS; i++)
- hw->bank.lock[i].priv = io_base + i * sizeof(u32);
-
ret = devm_hwspin_lock_register(dev, &hw->bank, &stm32_hwspinlock_ops,
- 0, STM32_MUTEX_NUM_LOCKS);
+ 0, STM32_MUTEX_NUM_LOCKS, io_base);
if (ret)
dev_err(dev, "Failed to register hwspinlock\n");
--
2.51.0
More information about the linux-arm-kernel
mailing list