All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Marangi <ansuelsmth@gmail.com>
To: Baolin Wang <baolin.wang7@gmail.com>
Cc: Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Konrad Dybcio <konrad.dybcio@somainline.org>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Ohad Ben-Cohen <ohad@wizery.com>,
	linux-arm-msm@vger.kernel.org,
	Devicetree List <devicetree@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-remoteproc@vger.kernel.org
Subject: Re: [PATCH 1/3] hwspinlock: qcom: Add support for mmio usage to sfpb-mutex
Date: Thu, 7 Jul 2022 13:07:09 +0200	[thread overview]
Message-ID: <62c6be5e.1c69fb81.d194f.1258@mx.google.com> (raw)
In-Reply-To: <CADBw62o8HfH_MfbLP-=5qra9yjO34bUC__mZU1NDxqFALQZOmw@mail.gmail.com>

On Thu, Jul 07, 2022 at 07:00:15PM +0800, Baolin Wang wrote:
> On Thu, Jul 7, 2022 at 9:30 AM Christian Marangi <ansuelsmth@gmail.com> wrote:
> >
> > Allow sfpb-mutex to use mmio in addition to syscon.
> >
> > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> > ---
> >  drivers/hwspinlock/qcom_hwspinlock.c | 32 ++++++++++++++++++++++------
> >  1 file changed, 25 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/hwspinlock/qcom_hwspinlock.c b/drivers/hwspinlock/qcom_hwspinlock.c
> > index 364710966665..23c913095bd0 100644
> > --- a/drivers/hwspinlock/qcom_hwspinlock.c
> > +++ b/drivers/hwspinlock/qcom_hwspinlock.c
> > @@ -19,6 +19,11 @@
> >  #define QCOM_MUTEX_APPS_PROC_ID        1
> >  #define QCOM_MUTEX_NUM_LOCKS   32
> >
> > +struct qcom_hwspinlock_of_data {
> > +       u32 offset;
> > +       u32 stride;
> > +};
> > +
> >  static int qcom_hwspinlock_trylock(struct hwspinlock *lock)
> >  {
> >         struct regmap_field *field = lock->priv;
> > @@ -63,9 +68,20 @@ static const struct hwspinlock_ops qcom_hwspinlock_ops = {
> >         .unlock         = qcom_hwspinlock_unlock,
> >  };
> >
> > +static const struct qcom_hwspinlock_of_data of_sfpb_mutex = {
> > +       .offset = 0x4,
> > +       .stride = 0x4,
> > +};
> > +
> > +/* All modern platform has offset 0 and stride of 4k */
> > +static const struct qcom_hwspinlock_of_data of_tcsr_mutex = {
> > +       .offset = 0,
> > +       .stride = 0x1000,
> > +};
> > +
> >  static const struct of_device_id qcom_hwspinlock_of_match[] = {
> > -       { .compatible = "qcom,sfpb-mutex" },
> > -       { .compatible = "qcom,tcsr-mutex" },
> > +       { .compatible = "qcom,sfpb-mutex", .data = &of_sfpb_mutex },
> > +       { .compatible = "qcom,tcsr-mutex", .data = &of_tcsr_mutex },
> >         { }
> >  };
> >  MODULE_DEVICE_TABLE(of, qcom_hwspinlock_of_match);
> > @@ -101,7 +117,7 @@ static struct regmap *qcom_hwspinlock_probe_syscon(struct platform_device *pdev,
> >         return regmap;
> >  }
> >
> > -static const struct regmap_config tcsr_mutex_config = {
> > +static const struct regmap_config qcom_hwspinlock_mmio_config = {
> >         .reg_bits               = 32,
> >         .reg_stride             = 4,
> >         .val_bits               = 32,
> > @@ -112,18 +128,20 @@ static const struct regmap_config tcsr_mutex_config = {
> >  static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev,
> >                                                  u32 *offset, u32 *stride)
> >  {
> > +       const struct qcom_hwspinlock_of_data *data;
> >         struct device *dev = &pdev->dev;
> >         void __iomem *base;
> >
> > -       /* All modern platform has offset 0 and stride of 4k */
> > -       *offset = 0;
> > -       *stride = 0x1000;
> > +       data = of_device_get_match_data(dev);
> 
> Nit: better to validate the return value though this is a rare case.
> 
> if (!data)
>          return -ENODEV;
> 

Wonder if that can actually happen?

Looking at of_device_get_match_data() it can only return the data or
NULL if the match data is not defined but considering it should ALWAYS
be defined (or the driver can't work). But yhea should be a value to
check.

-- 
	Ansuel

      reply	other threads:[~2022-07-07 11:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-07  1:30 [PATCH 1/3] hwspinlock: qcom: Add support for mmio usage to sfpb-mutex Christian Marangi
2022-07-07  1:30 ` [PATCH 2/3] ARM: dts: qcom: add missing hwlock for ipq8064 dtsi Christian Marangi
2022-07-07  6:58   ` Krzysztof Kozlowski
2022-07-07  1:30 ` [PATCH 3/3] ARM: dts: qcom: add missing smem compatible " Christian Marangi
2022-07-07  6:59   ` Krzysztof Kozlowski
2022-07-07  6:59   ` Krzysztof Kozlowski
2022-07-07  1:30 ` [PATCH 3/3] ARM: dts: qcom: add missing smem node " Christian Marangi
2022-07-07  1:32   ` Christian Marangi
2022-07-07  2:53 ` [PATCH 1/3] hwspinlock: qcom: Add support for mmio usage to sfpb-mutex Bjorn Andersson
2022-07-07 10:14   ` Christian Marangi
2022-07-07 11:00 ` Baolin Wang
2022-07-07 11:07   ` Christian Marangi [this message]

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=62c6be5e.1c69fb81.d194f.1258@mx.google.com \
    --to=ansuelsmth@gmail.com \
    --cc=agross@kernel.org \
    --cc=baolin.wang7@gmail.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konrad.dybcio@somainline.org \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=ohad@wizery.com \
    --cc=robh+dt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.