mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rong Qianfeng <11065417@vivo.com>
To: Biju Das <biju.das.jz@bp.renesas.com>,
	Rong Qianfeng <rongqianfeng@vivo.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Andi Shyti <andi.shyti@kernel.org>,
	Paul Cercueil <paul@crapouillou.net>,
	"linux-renesas-soc@vger.kernel.org"
	<linux-renesas-soc@vger.kernel.org>,
	"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mips@vger.kernel.org" <linux-mips@vger.kernel.org>
Cc: "opensource.kernel@vivo.com" <opensource.kernel@vivo.com>
Subject: Re: [PATCH v2 3/3] i2c: jz4780: Use devm_clk_get_enabled() helpers
Date: Fri, 23 Aug 2024 10:36:54 +0800	[thread overview]
Message-ID: <271d9f3d-8f18-48bf-80da-2d049783e13f@vivo.com> (raw)
In-Reply-To: <TY3PR01MB1134676C8A4FE7BBC89E13701868F2@TY3PR01MB11346.jpnprd01.prod.outlook.com>


在 2024/8/22 22:21, Biju Das 写道:
> [Some people who received this message don't often get email from biju.das.jz@bp.renesas.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> Hi Rong Qianfeng,
>
> Thanks for the patch
>
>> -----Original Message-----
>> From: Rong Qianfeng <rongqianfeng@vivo.com>
>> Sent: Thursday, August 22, 2024 3:04 PM
>> Subject: [PATCH v2 3/3] i2c: jz4780: Use devm_clk_get_enabled() helpers
>>
>> The devm_clk_get_enabled() helpers:
>>      - call devm_clk_get()
>>      - call clk_prepare_enable() and register what is needed in order to
>>       call clk_disable_unprepare() when needed, as a managed resource.
>>
>> This simplifies the code and avoids the calls to clk_disable_unprepare().
>>
>> While at it, no more special handling needed here, remove the goto label "err:".
>>
>> Signed-off-by: Rong Qianfeng <rongqianfeng@vivo.com>
>> Acked-by: Paul Cercueil <paul@crapouillou.net>
>> ---
>>   drivers/i2c/busses/i2c-jz4780.c | 21 ++++++---------------
>>   1 file changed, 6 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-jz4780.c b/drivers/i2c/busses/i2c-jz4780.c index
>> 4aafdfab6305..f5362c5dfb50 100644
>> --- a/drivers/i2c/busses/i2c-jz4780.c
>> +++ b/drivers/i2c/busses/i2c-jz4780.c
>> @@ -792,26 +792,22 @@ static int jz4780_i2c_probe(struct platform_device *pdev)
>>
>>        platform_set_drvdata(pdev, i2c);
>>
>> -     i2c->clk = devm_clk_get(&pdev->dev, NULL);
>> +     i2c->clk = devm_clk_get_enabled(&pdev->dev, NULL);
>>        if (IS_ERR(i2c->clk))
>>                return PTR_ERR(i2c->clk);
>>
>> -     ret = clk_prepare_enable(i2c->clk);
>> -     if (ret)
>> -             return ret;
>> -
>>        ret = of_property_read_u32(pdev->dev.of_node, "clock-frequency",
>>                                   &clk_freq);
>>        if (ret) {
>>                dev_err(&pdev->dev, "clock-frequency not specified in DT\n");
>> -             goto err;
>> +             return ret;
> Nitpick:
> Leaving it to you.
> If needed, you could send another patch to use dev_err_probe
>
> if (ret)
>          return dev_err_probe(&pdev->dev, ret, "clock-frequency not specified in DT\n");

Thanks for taking the time to review my patch! I will send another patch 
later.

>
>>        }
>>
>>        i2c->speed = clk_freq / 1000;
>>        if (i2c->speed == 0) {
>>                ret = -EINVAL;
>>                dev_err(&pdev->dev, "clock-frequency minimum is 1000\n");
>                  return dev_err_probe(&pdev->dev, -EINVAL, "clock-frequency minimum is 1000\n ");
>
> Cheers,
> Biju
>
>> -             goto err;
>> +             return ret;
>>        }
>>        jz4780_i2c_set_speed(i2c);
>>
>> @@ -827,29 +823,24 @@ static int jz4780_i2c_probe(struct platform_device *pdev)
>>
>>        ret = platform_get_irq(pdev, 0);
>>        if (ret < 0)
>> -             goto err;
>> +             return ret;
>>        i2c->irq = ret;
>>        ret = devm_request_irq(&pdev->dev, i2c->irq, jz4780_i2c_irq, 0,
>>                               dev_name(&pdev->dev), i2c);
>>        if (ret)
>> -             goto err;
>> +             return ret;
>>
>>        ret = i2c_add_adapter(&i2c->adap);
>>        if (ret < 0)
>> -             goto err;
>> +             return ret;
>>
>>        return 0;
>> -
>> -err:
>> -     clk_disable_unprepare(i2c->clk);
>> -     return ret;
>>   }
>>
>>   static void jz4780_i2c_remove(struct platform_device *pdev)  {
>>        struct jz4780_i2c *i2c = platform_get_drvdata(pdev);
>>
>> -     clk_disable_unprepare(i2c->clk);
>>        i2c_del_adapter(&i2c->adap);
>>   }
>>
>> --
>> 2.39.0

      reply	other threads:[~2024-08-23  2:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-22 14:04 [PATCH v2 0/3] " Rong Qianfeng
2024-08-22 14:04 ` [PATCH v2 1/3] i2c: emev2: " Rong Qianfeng
2024-08-22 14:04 ` [PATCH v2 2/3] i2c: emev2: Drop sclk from struct em_i2c_device Rong Qianfeng
2024-08-22 14:22   ` Biju Das
2024-08-22 14:04 ` [PATCH v2 3/3] i2c: jz4780: Use devm_clk_get_enabled() helpers Rong Qianfeng
2024-08-22 14:21   ` Biju Das
2024-08-23  2:36     ` Rong Qianfeng [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=271d9f3d-8f18-48bf-80da-2d049783e13f@vivo.com \
    --to=11065417@vivo.com \
    --cc=andi.shyti@kernel.org \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=opensource.kernel@vivo.com \
    --cc=paul@crapouillou.net \
    --cc=rongqianfeng@vivo.com \
    --cc=wsa+renesas@sang-engineering.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

all inboxes | Powered by JetHome®