From: "Tanwar, Rahul" <rahul.tanwar@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: u.kleine-koenig@pengutronix.de, linux-pwm@vger.kernel.org,
lee.jones@linaro.org, thierry.reding@gmail.com,
p.zabel@pengutronix.de, robh+dt@kernel.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
songjun.Wu@intel.com, cheol.yong.kim@intel.com,
qi-ming.wu@intel.com, rahul.tanwar.linux@gmail.com,
rtanwar@maxlinear.com
Subject: Re: [PATCH v10 2/2] Add PWM fan controller driver for LGM SoC
Date: Mon, 24 Aug 2020 17:36:47 +0800 [thread overview]
Message-ID: <ed7affbb-b95d-cf42-b9bc-71addf908ffc@linux.intel.com> (raw)
In-Reply-To: <20200824081715.GA1891694@smile.fi.intel.com>
Hi Andy,
On 24/8/2020 4:17 pm, Andy Shevchenko wrote:
> On Mon, Aug 24, 2020 at 11:36:37AM +0800, Rahul Tanwar wrote:
>> Intel Lightning Mountain(LGM) SoC contains a PWM fan controller.
>> This PWM controller does not have any other consumer, it is a
>> dedicated PWM controller for fan attached to the system. Add
>> driver for this PWM fan controller.
> ...
>
>> + pc->regmap = devm_regmap_init_mmio(dev, io_base, &lgm_pwm_regmap_config);
>> + if (IS_ERR(pc->regmap)) {
>> + ret = PTR_ERR(pc->regmap);
>> + if (ret != -EPROBE_DEFER)
>> + dev_err_probe(dev, ret, "failed to init register map\n");
>> + return ret;
>> + }
>> +
>> + pc->clk = devm_clk_get(dev, NULL);
>> + if (IS_ERR(pc->clk)) {
>> + ret = PTR_ERR(pc->clk);
>> + if (ret != -EPROBE_DEFER)
>> + dev_err_probe(dev, ret, "failed to get clock\n");
>> + return ret;
>> + }
>> +
>> + pc->rst = devm_reset_control_get_exclusive(dev, NULL);
>> + if (IS_ERR(pc->rst)) {
>> + ret = PTR_ERR(pc->rst);
>> + if (ret != -EPROBE_DEFER)
>> + dev_err_probe(dev, ret, "failed to get reset control\n");
>> + return ret;
>> + }
>> +
>> + ret = reset_control_deassert(pc->rst);
>> + if (ret) {
>> + if (ret != -EPROBE_DEFER)
>> + dev_err_probe(dev, ret, "cannot deassert reset control\n");
>> + return ret;
>> + }
> Please, spend a bit of time to understand the changes you are doing. There are
> already few examples how to use dev_err_probe() properly.
I guess your point is that the check of (ret !- -EPROBE_DEFER) is not needed
when using dev_err_probe() as it encapsulates it. Sorry, i missed it. Will
fix it. I am not able to find any other missing point after referring to
two driver examples which uses dev_err_probe() ?
>> + ret = clk_prepare_enable(pc->clk);
>> + if (ret) {
>> + dev_err(dev, "failed to enable clock\n");
>> + return ret;
>> + }
>> +
>> + ret = devm_add_action_or_reset(dev, lgm_pwm_action, pc);
>> + if (ret)
>> + return ret;
> You have also ordering issues here.
>
> So, what I can see about implementation is that
>
>
> static void ..._clk_disable(void *data)
> {
> clk_disable_unprepare(data);
> }
>
> static int ..._clk_enable(...)
> {
> int ret;
>
> ret = clk_preare_enable(...);
> if (ret)
> return ret;
> return devm_add_action_or_reset(..., ..._clk_disable);
> }
>
>
> Similar for reset control.
>
> Then in the ->probe() something like this:
>
> ret = devm_reset_control_get...;
> if (ret)
> return ret;
>
> ret = ..._reset_deassert(...);
> if (ret)
> return ret;
>
> followed by similar section for the clock.
>
Regarding ordering: In early rounds of review, feedback about ordering was that
it is recommended to be reverse of the sequence in probe i.e.
if in probe:
1. reset_control_deassert()
2. clk_prepare_enable()
then in remove:
1. clk_disable_uprepare()
2. reset_control_assert()
That's the reason i added a generic action() which reverses order.
I understand your suggested way as explained above but not sure if that would
ensure reverse ordering during unwind.
Thanks.
Regards,
Rahul
next prev parent reply other threads:[~2020-08-24 9:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-24 3:36 [PATCH v10 0/2] pwm: intel: Add PWM driver for a new SoC Rahul Tanwar
2020-08-24 3:36 ` [PATCH v10 1/2] Add DT bindings YAML schema for PWM fan controller of LGM SoC Rahul Tanwar
2020-08-24 3:36 ` [PATCH v10 2/2] Add PWM fan controller driver for " Rahul Tanwar
2020-08-24 8:17 ` Andy Shevchenko
2020-08-24 9:36 ` Tanwar, Rahul [this message]
2020-08-24 10:14 ` Andy Shevchenko
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=ed7affbb-b95d-cf42-b9bc-71addf908ffc@linux.intel.com \
--to=rahul.tanwar@linux.intel.com \
--cc=andriy.shevchenko@intel.com \
--cc=cheol.yong.kim@intel.com \
--cc=devicetree@vger.kernel.org \
--cc=lee.jones@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=qi-ming.wu@intel.com \
--cc=rahul.tanwar.linux@gmail.com \
--cc=robh+dt@kernel.org \
--cc=rtanwar@maxlinear.com \
--cc=songjun.Wu@intel.com \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).