From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-renesas-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
Bjorn Andersson <andersson@kernel.org>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org
Subject: [PATCH v5 06/15] hwspinlock: qcom: use new callback to initialize hwspinlock priv
Date: Thu, 19 Mar 2026 11:59:28 +0100 [thread overview]
Message-ID: <20260319105947.6237-7-wsa+renesas@sang-engineering.com> (raw)
In-Reply-To: <20260319105947.6237-1-wsa+renesas@sang-engineering.com>
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@sang-engineering.com>
Acked-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
---
drivers/hwspinlock/qcom_hwspinlock.c | 45 ++++++++++++++++------------
1 file changed, 26 insertions(+), 19 deletions(-)
diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c
index 7960a4972eab..73b280988109 100644
--- a/drivers/hwspinlock/qcom_hwspinlock.c
+++ b/drivers/hwspinlock/qcom_hwspinlock.c
@@ -25,6 +25,13 @@ struct qcom_hwspinlock_of_data {
const struct regmap_config *regmap_config;
};
+struct qcom_hwspinlock_priv_init_data {
+ struct device *dev;
+ struct regmap *regmap;
+ u32 base;
+ u32 stride;
+};
+
static int qcom_hwspinlock_trylock(struct hwspinlock *lock)
{
struct regmap_field *field = hwspin_lock_get_priv(lock);
@@ -89,10 +96,23 @@ static int qcom_hwspinlock_bust(struct hwspinlock *lock, unsigned int id)
return 0;
}
+static void *qcom_hwspinlock_init_priv(int local_id, void *init_data)
+{
+ struct qcom_hwspinlock_priv_init_data *init = init_data;
+ struct reg_field field;
+
+ field.reg = init->base + local_id * init->stride;
+ field.lsb = 0;
+ field.msb = 31;
+
+ return devm_regmap_field_alloc(init->dev, init->regmap, field);
+}
+
static const struct hwspinlock_ops qcom_hwspinlock_ops = {
.trylock = qcom_hwspinlock_trylock,
.unlock = qcom_hwspinlock_unlock,
.bust = qcom_hwspinlock_bust,
+ .init_priv = qcom_hwspinlock_init_priv,
};
static const struct regmap_config sfpb_mutex_config = {
@@ -202,17 +222,14 @@ static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev,
static int qcom_hwspinlock_probe(struct platform_device *pdev)
{
+ struct qcom_hwspinlock_priv_init_data init;
struct hwspinlock_device *bank;
- struct reg_field field;
struct regmap *regmap;
size_t array_size;
- u32 stride;
- u32 base;
- int i;
- regmap = qcom_hwspinlock_probe_syscon(pdev, &base, &stride);
+ regmap = qcom_hwspinlock_probe_syscon(pdev, &init.base, &init.stride);
if (IS_ERR(regmap) && PTR_ERR(regmap) == -ENODEV)
- regmap = qcom_hwspinlock_probe_mmio(pdev, &base, &stride);
+ regmap = qcom_hwspinlock_probe_mmio(pdev, &init.base, &init.stride);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
@@ -222,21 +239,11 @@ static int qcom_hwspinlock_probe(struct platform_device *pdev)
if (!bank)
return -ENOMEM;
- platform_set_drvdata(pdev, bank);
-
- for (i = 0; i < QCOM_MUTEX_NUM_LOCKS; i++) {
- field.reg = base + i * stride;
- field.lsb = 0;
- field.msb = 31;
-
- bank->lock[i].priv = devm_regmap_field_alloc(&pdev->dev,
- regmap, field);
- if (IS_ERR(bank->lock[i].priv))
- return PTR_ERR(bank->lock[i].priv);
- }
+ init.dev = &pdev->dev;
+ init.regmap = regmap;
return devm_hwspin_lock_register(&pdev->dev, bank, &qcom_hwspinlock_ops,
- 0, QCOM_MUTEX_NUM_LOCKS, NULL);
+ 0, QCOM_MUTEX_NUM_LOCKS, &init);
}
static struct platform_driver qcom_hwspinlock_driver = {
--
2.51.0
next prev parent reply other threads:[~2026-03-19 11:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 10:59 [PATCH v5 00/15] hwspinlock: move device alloc into core and refactor includes Wolfram Sang
2026-03-19 10:59 ` [PATCH v5 03/15] hwspinlock: add helpers to retrieve core data Wolfram Sang
2026-03-19 10:59 ` [PATCH v5 04/15] hwspinlock: add callback to fill private data of a hwspinlock Wolfram Sang
2026-03-19 13:07 ` Chen-Yu Tsai
2026-03-19 10:59 ` Wolfram Sang [this message]
2026-03-19 10:59 ` [PATCH v5 10/15] hwspinlock: handle hwspinlock device allocation in the core Wolfram Sang
2026-03-19 13:09 ` Chen-Yu Tsai
2026-03-19 10:59 ` [PATCH v5 11/15] hwspinlock: move entries from internal to public header Wolfram Sang
2026-03-19 13:09 ` Chen-Yu Tsai
2026-03-19 10:59 ` [PATCH v5 14/15] hwspinlock: refactor provider.h from " Wolfram Sang
2026-03-19 13:10 ` Chen-Yu Tsai
2026-03-19 10:59 ` [PATCH v5 15/15] hwspinlock/treewide: refactor consumer.h " Wolfram Sang
2026-03-27 11:43 ` [PATCH v5 00/15] hwspinlock: move device alloc into core and refactor includes Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260319105947.6237-7-wsa+renesas@sang-engineering.com \
--to=wsa+renesas@sang-engineering.com \
--cc=andersson@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=konrad.dybcio@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox