From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-arm-kernel@lists.infradead.org, mripard@kernel.org
Subject: Re: [PATCH 1/3] hwspinlock: sunxi: Implement support for Allwinner's A64 SoC
Date: Mon, 10 Feb 2020 12:05:44 -0800 [thread overview]
Message-ID: <20200210200544.GA1443@yoga> (raw)
In-Reply-To: <45d491fa-716a-eb6a-f1a3-621363675a17@suse.com>
On Mon 10 Feb 11:06 PST 2020, Nikolay Borisov wrote:
>
>
> On 10.02.20 ??. 20:57 ??., Bjorn Andersson wrote:
> > On Mon 10 Feb 09:01 PST 2020, Nikolay Borisov wrote:
> > [..]
> >> diff --git a/drivers/hwspinlock/sunxi_hwspinlock.c b/drivers/hwspinlock/sunxi_hwspinlock.c
> >> new file mode 100644
> >> index 000000000000..8e5685357fbf
> >> --- /dev/null
> >> +++ b/drivers/hwspinlock/sunxi_hwspinlock.c
> >> @@ -0,0 +1,181 @@
> >> +// SPDX-License-Identifier: GPL-2.0
> >> +/* Author: Nikolay Borisov <nborisov@suse.com> */
> >> +
> >> +#include <linux/clk.h>
> >> +#include <linux/reset.h>
> >> +#include <linux/hwspinlock.h>
> >> +#include <linux/io.h>
> >> +#include <linux/kernel.h>
> >> +#include <linux/module.h>
> >> +#include <linux/of.h>
> >> +#include <linux/platform_device.h>
> >
> > Please sort these.
>
> alphabetically or reverse christmas tree?
>
Alphabetically please.
> >
> >> +
>
> <snip>
> >> + hw->clk = clk;
> >> + hw->reset = reset;
> >> +
> >> + io_base += LOCK_BASE_OFFSET;
> >> + for (i = 0; i < num_locks; i++)
> >> + hw->bank.lock[i].priv = io_base + i * sizeof(u32);
> >> +
> >> + platform_set_drvdata(pdev, hw);
> >> +
> >> + ret = hwspin_lock_register(&hw->bank, &pdev->dev, &sunxi_hwspinlock_ops,
> >> + 0, num_locks);
> >
> > People will likely send patches to replace this with
> > devm_hwspin_lock_register(), but that will create an invalid ordering
> > between the clock disable, reset assert and the hwspinlock
> > unregistration.
> >
> > You could deal with this using devm_add_action() and
> > devm_add_action_or_reset() for the clock and reset above. That will save
> > us future churn, would clean up your error handling and you could drop
> > the remove function completely.
>
> This is my first rodeo in device driver land so I'm learning. It looks
> like what you want here is similar to what there is in
> sprd_hwspinlock.c. Will rework it.
>
Exactly like that, forgot that we had an example of this in the sprd
driver. That will ensure that we rely solely on devres to unroll the
resources in a suitable order.
Regards,
Bjorn
> >
> >> +
> >> + if (!ret)
> >> + return ret;
> >> +out_reset:
> >> + reset_control_assert(reset);
> >> +out_declock:
> >> + clk_disable_unprepare(clk);
> >> + return ret;
> >> +}
> >> +
> >> +static int sunxi_hwspinlock_remove(struct platform_device *pdev)
> >> +{
> >> + struct sunxi_hwspinlock *hw = platform_get_drvdata(pdev);
> >> + int ret;
> >> +
> >> + ret = hwspin_lock_unregister(&hw->bank);
> >> + if (ret)
> >> + dev_err(&pdev->dev, "%s failed: %d\n", __func__, ret);
> >> +
> >> + reset_control_assert(hw->reset);
> >> + clk_disable_unprepare(hw->clk);
> >> +
> >> + return 0;
> >> +}
> >> +
> >
> > Regards,
> > Bjorn
> >
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2020-02-10 20:05 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-10 17:01 [PATCH 0/3] Add support for hwspinlock on A64 SoC Nikolay Borisov
2020-02-10 17:01 ` [PATCH 1/3] hwspinlock: sunxi: Implement support for Allwinner's " Nikolay Borisov
2020-02-10 18:57 ` Bjorn Andersson
2020-02-10 19:06 ` Nikolay Borisov
2020-02-10 20:05 ` Bjorn Andersson [this message]
2020-02-11 7:46 ` Maxime Ripard
2020-02-11 8:08 ` Nikolay Borisov
2020-02-11 12:34 ` Maxime Ripard
2020-02-11 13:17 ` Nikolay Borisov
2020-02-12 12:06 ` Maxime Ripard
2020-02-12 14:32 ` Nikolay Borisov
2020-02-12 19:10 ` Maxime Ripard
2020-02-10 17:01 ` [PATCH 2/3] arm64: dts: allwinner: a64: Add hwspinlock node Nikolay Borisov
2020-02-11 7:55 ` Maxime Ripard
2020-02-11 8:09 ` Nikolay Borisov
2020-02-11 12:36 ` Maxime Ripard
2020-02-10 17:01 ` [PATCH 3/3] dt-bindings: hwlock: Document A64 hwspinlock bindings Nikolay Borisov
2020-02-10 18:59 ` Bjorn Andersson
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=20200210200544.GA1443@yoga \
--to=bjorn.andersson@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mripard@kernel.org \
--cc=nborisov@suse.com \
/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