2020-06-18 12:30:39

by Philipp Zabel

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] Add PWM fan controller driver for LGM SoC

Hi Rahul,

On Thu, 2020-06-18 at 20:05 +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.
>
> Signed-off-by: Rahul Tanwar <[email protected]>
> ---
> drivers/pwm/Kconfig | 9 +
> drivers/pwm/Makefile | 1 +
> drivers/pwm/pwm-intel-lgm.c | 400 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 410 insertions(+)
> create mode 100644 drivers/pwm/pwm-intel-lgm.c
>
[...]
> diff --git a/drivers/pwm/pwm-intel-lgm.c b/drivers/pwm/pwm-intel-lgm.c
> new file mode 100644
> index 000000000000..3c7077acb161
> --- /dev/null
> +++ b/drivers/pwm/pwm-intel-lgm.c
> @@ -0,0 +1,400 @@
[...]
> +static int lgm_pwm_probe(struct platform_device *pdev)
> +{
> + struct lgm_pwm_chip *pc;
> + struct device *dev = &pdev->dev;
> + void __iomem *io_base;
> + int ret;
> +
> + pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
> + if (!pc)
> + return -ENOMEM;
> +
> + io_base = devm_platform_ioremap_resource(pdev, 0);
> + if (IS_ERR(io_base))
> + return PTR_ERR(io_base);
> +
> + pc->regmap = devm_regmap_init_mmio(dev, io_base, &pwm_regmap_config);
> + if (IS_ERR(pc->regmap)) {
> + ret = PTR_ERR(pc->regmap);
> + dev_err(dev, "failed to init register map: %pe\n", pc->regmap);
> + return ret;
> + }
> +
> + pc->clk = devm_clk_get(dev, NULL);
> + if (IS_ERR(pc->clk)) {
> + ret = PTR_ERR(pc->clk);
> + dev_err(dev, "failed to get clock: %pe\n", pc->clk);
> + return ret;
> + }
> +
> + pc->rst = devm_reset_control_get(dev, NULL);
> + if (IS_ERR(pc->rst)) {
> + ret = PTR_ERR(pc->rst);
> + dev_err(dev, "failed to get reset control: %pe\n", pc->rst);
> + return ret;
> + }

Please use devm_reset_control_get_exclusive() to make it explicit an
that exclusive reset control is requested. Given how the reset control
is used, I think this driver could also use
devm_reset_control_get_shared() to potentially allow sharing a reset
line with other devices.

regards
Philipp


2020-06-25 04:55:31

by Rahul Tanwar

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] Add PWM fan controller driver for LGM SoC


Hi Philipp,

On 18/6/2020 8:25 pm, Philipp Zabel wrote:
> Hi Rahul,
>
> On Thu, 2020-06-18 at 20:05 +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.
>>
>> Signed-off-by: Rahul Tanwar <[email protected]>
>> ---
>> drivers/pwm/Kconfig | 9 +
>> drivers/pwm/Makefile | 1 +
>> drivers/pwm/pwm-intel-lgm.c | 400 ++++++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 410 insertions(+)
>> create mode 100644 drivers/pwm/pwm-intel-lgm.c
>>
> [...]
>> diff --git a/drivers/pwm/pwm-intel-lgm.c b/drivers/pwm/pwm-intel-lgm.c
>> new file mode 100644
>> index 000000000000..3c7077acb161
>> --- /dev/null
>> +++ b/drivers/pwm/pwm-intel-lgm.c
>> @@ -0,0 +1,400 @@
> [...]
>> +static int lgm_pwm_probe(struct platform_device *pdev)
>> +{
>> + struct lgm_pwm_chip *pc;
>> + struct device *dev = &pdev->dev;
>> + void __iomem *io_base;
>> + int ret;
>> +
>> + pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
>> + if (!pc)
>> + return -ENOMEM;
>> +
>> + io_base = devm_platform_ioremap_resource(pdev, 0);
>> + if (IS_ERR(io_base))
>> + return PTR_ERR(io_base);
>> +
>> + pc->regmap = devm_regmap_init_mmio(dev, io_base, &pwm_regmap_config);
>> + if (IS_ERR(pc->regmap)) {
>> + ret = PTR_ERR(pc->regmap);
>> + dev_err(dev, "failed to init register map: %pe\n", pc->regmap);
>> + return ret;
>> + }
>> +
>> + pc->clk = devm_clk_get(dev, NULL);
>> + if (IS_ERR(pc->clk)) {
>> + ret = PTR_ERR(pc->clk);
>> + dev_err(dev, "failed to get clock: %pe\n", pc->clk);
>> + return ret;
>> + }
>> +
>> + pc->rst = devm_reset_control_get(dev, NULL);
>> + if (IS_ERR(pc->rst)) {
>> + ret = PTR_ERR(pc->rst);
>> + dev_err(dev, "failed to get reset control: %pe\n", pc->rst);
>> + return ret;
>> + }
> Please use devm_reset_control_get_exclusive() to make it explicit an
> that exclusive reset control is requested. Given how the reset control
> is used, I think this driver could also use
> devm_reset_control_get_shared() to potentially allow sharing a reset
> line with other devices.

devm_reset_control_get() is a wrapper for devm_reset_control_get_exclusive().
Code as below:
static inline struct reset_control *devm_reset_control_get(
                                struct device *dev, const char *id)
{
        return devm_reset_control_get_exclusive(dev, id);
}
Am i missing something else?

Regards,
Rahul

2020-06-25 06:32:01

by Uwe Kleine-König

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] Add PWM fan controller driver for LGM SoC

On Thu, Jun 25, 2020 at 12:23:54PM +0800, Tanwar, Rahul wrote:
>
> Hi Philipp,
>
> On 18/6/2020 8:25 pm, Philipp Zabel wrote:
> > Hi Rahul,
> >
> > On Thu, 2020-06-18 at 20:05 +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.
> >>
> >> Signed-off-by: Rahul Tanwar <[email protected]>
> >> ---
> >> drivers/pwm/Kconfig | 9 +
> >> drivers/pwm/Makefile | 1 +
> >> drivers/pwm/pwm-intel-lgm.c | 400 ++++++++++++++++++++++++++++++++++++++++++++
> >> 3 files changed, 410 insertions(+)
> >> create mode 100644 drivers/pwm/pwm-intel-lgm.c
> >>
> > [...]
> >> diff --git a/drivers/pwm/pwm-intel-lgm.c b/drivers/pwm/pwm-intel-lgm.c
> >> new file mode 100644
> >> index 000000000000..3c7077acb161
> >> --- /dev/null
> >> +++ b/drivers/pwm/pwm-intel-lgm.c
> >> @@ -0,0 +1,400 @@
> > [...]
> >> +static int lgm_pwm_probe(struct platform_device *pdev)
> >> +{
> >> + struct lgm_pwm_chip *pc;
> >> + struct device *dev = &pdev->dev;
> >> + void __iomem *io_base;
> >> + int ret;
> >> +
> >> + pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
> >> + if (!pc)
> >> + return -ENOMEM;
> >> +
> >> + io_base = devm_platform_ioremap_resource(pdev, 0);
> >> + if (IS_ERR(io_base))
> >> + return PTR_ERR(io_base);
> >> +
> >> + pc->regmap = devm_regmap_init_mmio(dev, io_base, &pwm_regmap_config);
> >> + if (IS_ERR(pc->regmap)) {
> >> + ret = PTR_ERR(pc->regmap);
> >> + dev_err(dev, "failed to init register map: %pe\n", pc->regmap);
> >> + return ret;
> >> + }
> >> +
> >> + pc->clk = devm_clk_get(dev, NULL);
> >> + if (IS_ERR(pc->clk)) {
> >> + ret = PTR_ERR(pc->clk);
> >> + dev_err(dev, "failed to get clock: %pe\n", pc->clk);
> >> + return ret;
> >> + }
> >> +
> >> + pc->rst = devm_reset_control_get(dev, NULL);
> >> + if (IS_ERR(pc->rst)) {
> >> + ret = PTR_ERR(pc->rst);
> >> + dev_err(dev, "failed to get reset control: %pe\n", pc->rst);
> >> + return ret;
> >> + }
> > Please use devm_reset_control_get_exclusive() to make it explicit an
> > that exclusive reset control is requested. Given how the reset control
> > is used, I think this driver could also use
> > devm_reset_control_get_shared() to potentially allow sharing a reset
> > line with other devices.
>
> devm_reset_control_get() is a wrapper for devm_reset_control_get_exclusive().
> Code as below:
> static inline struct reset_control *devm_reset_control_get(
> ??????????????????????????????? struct device *dev, const char *id)
> {
> ??????? return devm_reset_control_get_exclusive(dev, id);
> }
> Am i missing something else?

Obviously you're missing the comment above of_reset_control_get about
some functions being compatibility wrappers.

Best regards
Uwe

--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | https://www.pengutronix.de/ |


Attachments:
(No filename) (3.06 kB)
signature.asc (499.00 B)
Download all attachments

2020-06-25 09:50:24

by Rahul Tanwar

[permalink] [raw]
Subject: Re: [PATCH v2 2/2] Add PWM fan controller driver for LGM SoC



On 25/6/2020 1:58 pm, Uwe Kleine-K?nig wrote:
> On Thu, Jun 25, 2020 at 12:23:54PM +0800, Tanwar, Rahul wrote:
>> Hi Philipp,
>>
>> On 18/6/2020 8:25 pm, Philipp Zabel wrote:
>>> Hi Rahul,
>>>
>>> On Thu, 2020-06-18 at 20:05 +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.
>>>>
>>>> Signed-off-by: Rahul Tanwar <[email protected]>
>>>> ---
>>>> drivers/pwm/Kconfig | 9 +
>>>> drivers/pwm/Makefile | 1 +
>>>> drivers/pwm/pwm-intel-lgm.c | 400 ++++++++++++++++++++++++++++++++++++++++++++
>>>> 3 files changed, 410 insertions(+)
>>>> create mode 100644 drivers/pwm/pwm-intel-lgm.c
>>>>
>>> [...]
>>>> diff --git a/drivers/pwm/pwm-intel-lgm.c b/drivers/pwm/pwm-intel-lgm.c
>>>> new file mode 100644
>>>> index 000000000000..3c7077acb161
>>>> --- /dev/null
>>>> +++ b/drivers/pwm/pwm-intel-lgm.c
>>>> @@ -0,0 +1,400 @@
>>> [...]
>>>> +static int lgm_pwm_probe(struct platform_device *pdev)
>>>> +{
>>>> + struct lgm_pwm_chip *pc;
>>>> + struct device *dev = &pdev->dev;
>>>> + void __iomem *io_base;
>>>> + int ret;
>>>> +
>>>> + pc = devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL);
>>>> + if (!pc)
>>>> + return -ENOMEM;
>>>> +
>>>> + io_base = devm_platform_ioremap_resource(pdev, 0);
>>>> + if (IS_ERR(io_base))
>>>> + return PTR_ERR(io_base);
>>>> +
>>>> + pc->regmap = devm_regmap_init_mmio(dev, io_base, &pwm_regmap_config);
>>>> + if (IS_ERR(pc->regmap)) {
>>>> + ret = PTR_ERR(pc->regmap);
>>>> + dev_err(dev, "failed to init register map: %pe\n", pc->regmap);
>>>> + return ret;
>>>> + }
>>>> +
>>>> + pc->clk = devm_clk_get(dev, NULL);
>>>> + if (IS_ERR(pc->clk)) {
>>>> + ret = PTR_ERR(pc->clk);
>>>> + dev_err(dev, "failed to get clock: %pe\n", pc->clk);
>>>> + return ret;
>>>> + }
>>>> +
>>>> + pc->rst = devm_reset_control_get(dev, NULL);
>>>> + if (IS_ERR(pc->rst)) {
>>>> + ret = PTR_ERR(pc->rst);
>>>> + dev_err(dev, "failed to get reset control: %pe\n", pc->rst);
>>>> + return ret;
>>>> + }
>>> Please use devm_reset_control_get_exclusive() to make it explicit an
>>> that exclusive reset control is requested. Given how the reset control
>>> is used, I think this driver could also use
>>> devm_reset_control_get_shared() to potentially allow sharing a reset
>>> line with other devices.
>> devm_reset_control_get() is a wrapper for devm_reset_control_get_exclusive().
>> Code as below:
>> static inline struct reset_control *devm_reset_control_get(
>> ??????????????????????????????? struct device *dev, const char *id)
>> {
>> ??????? return devm_reset_control_get_exclusive(dev, id);
>> }
>> Am i missing something else?
> Obviously you're missing the comment above of_reset_control_get about
> some functions being compatibility wrappers.

Oops, so sorry totally missed/overlooked that. Will update in v3. Thanks.

Regards,
Rahul