[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200824081715.GA1891694@smile.fi.intel.com>
Date: Mon, 24 Aug 2020 11:17:15 +0300
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Rahul Tanwar <rahul.tanwar@...ux.intel.com>
Cc: u.kleine-koenig@...gutronix.de, linux-pwm@...r.kernel.org,
lee.jones@...aro.org, thierry.reding@...il.com,
p.zabel@...gutronix.de, robh+dt@...nel.org,
linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
songjun.Wu@...el.com, cheol.yong.kim@...el.com,
qi-ming.wu@...el.com, rahul.tanwar.linux@...il.com,
rtanwar@...linear.com
Subject: Re: [PATCH v10 2/2] Add PWM fan controller driver for LGM SoC
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.
> + 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.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists