[RFC PATCH v2 07/13] hwspinlock: sun6i: use new callback to initialize hwspinlock priv
Wolfram Sang
wsa+renesas at sang-engineering.com
Sun Feb 15 14:54:47 PST 2026
Apply the new helper to avoid using internal structures from the core.
Remove superfluous setting of drvdata while here.
Signed-off-by: Wolfram Sang <wsa+renesas at sang-engineering.com>
---
drivers/hwspinlock/sun6i_hwspinlock.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/hwspinlock/sun6i_hwspinlock.c b/drivers/hwspinlock/sun6i_hwspinlock.c
index 8ff81cb5880a..7d0c639c0e82 100644
--- a/drivers/hwspinlock/sun6i_hwspinlock.c
+++ b/drivers/hwspinlock/sun6i_hwspinlock.c
@@ -74,9 +74,17 @@ static void sun6i_hwspinlock_unlock(struct hwspinlock *lock)
writel(SPINLOCK_NOTTAKEN, lock_addr);
}
+static void *sun6i_hwspinlock_init_priv(int local_id, void *init_data)
+{
+ void __iomem *io_base_ofs = init_data;
+
+ return io_base_ofs + sizeof(u32) * local_id;
+}
+
static const struct hwspinlock_ops sun6i_hwspinlock_ops = {
.trylock = sun6i_hwspinlock_trylock,
.unlock = sun6i_hwspinlock_unlock,
+ .init_priv = sun6i_hwspinlock_init_priv,
};
static void sun6i_hwspinlock_disable(void *data)
@@ -91,10 +99,9 @@ static void sun6i_hwspinlock_disable(void *data)
static int sun6i_hwspinlock_probe(struct platform_device *pdev)
{
struct sun6i_hwspinlock_data *priv;
- struct hwspinlock *hwlock;
void __iomem *io_base;
u32 num_banks;
- int err, i;
+ int err;
io_base = devm_platform_ioremap_resource(pdev, SPINLOCK_BASE_ID);
if (IS_ERR(io_base))
@@ -161,11 +168,6 @@ static int sun6i_hwspinlock_probe(struct platform_device *pdev)
goto bank_fail;
}
- for (i = 0; i < priv->nlocks; ++i) {
- hwlock = &priv->bank->lock[i];
- hwlock->priv = io_base + SPINLOCK_LOCK_REGN + sizeof(u32) * i;
- }
-
/* failure of debugfs is considered non-fatal */
sun6i_hwspinlock_debugfs_init(priv);
if (IS_ERR(priv->debugfs))
@@ -177,10 +179,8 @@ static int sun6i_hwspinlock_probe(struct platform_device *pdev)
goto bank_fail;
}
- platform_set_drvdata(pdev, priv);
-
return devm_hwspin_lock_register(&pdev->dev, priv->bank, &sun6i_hwspinlock_ops,
- SPINLOCK_BASE_ID, priv->nlocks);
+ SPINLOCK_BASE_ID, priv->nlocks, io_base + SPINLOCK_LOCK_REGN);
bank_fail:
clk_disable_unprepare(priv->ahb_clk);
--
2.51.0
More information about the linux-arm-kernel
mailing list