* [PATCH v1 1/1] i2c: synquacer: Fix clock rate retrieval code
@ 2024-09-12 14:41 Andy Shevchenko
2024-09-12 14:49 ` Andi Shyti
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2024-09-12 14:41 UTC (permalink / raw)
To: Ard Biesheuvel, Andi Shyti, Christophe JAILLET, linux-i2c,
linux-kernel
Cc: Andy Shevchenko
With the devm_clk_get_enabled() the probe will fail on the systems
that have no clock provided, such as ACPI-based ones.
synquacer_i2c SCX0003:00: error -ENOENT: failed to get and enable clock
synquacer_i2c SCX0003:00: probe with driver synquacer_i2c failed with error -2
Fix this by switching to devm_clk_get_optional_enabled() in conjunction with NULL
check, so we won't overwrite the clock rate from the property.
Fixes: 55750148e559 ("i2c: synquacer: Fix an error handling path in synquacer_i2c_probe()")
Reported-by: Ard Biesheuvel <ardb@kernel.org>
Closes: https://lore.kernel.org/r/CAMj1kXFH+zB_YuUS+vaEpguhuVGLYbQw55VNDCxnBfSPe6b-nw@mail.gmail.com
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
drivers/i2c/busses/i2c-synquacer.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-synquacer.c b/drivers/i2c/busses/i2c-synquacer.c
index 4eccbcd0fbfc..49d01fa8fb4e 100644
--- a/drivers/i2c/busses/i2c-synquacer.c
+++ b/drivers/i2c/busses/i2c-synquacer.c
@@ -550,12 +550,12 @@ static int synquacer_i2c_probe(struct platform_device *pdev)
device_property_read_u32(&pdev->dev, "socionext,pclk-rate",
&i2c->pclkrate);
- pclk = devm_clk_get_enabled(&pdev->dev, "pclk");
+ pclk = devm_clk_get_optional_enabled(&pdev->dev, "pclk");
if (IS_ERR(pclk))
return dev_err_probe(&pdev->dev, PTR_ERR(pclk),
"failed to get and enable clock\n");
-
- i2c->pclkrate = clk_get_rate(pclk);
+ if (pclk)
+ i2c->pclkrate = clk_get_rate(pclk);
if (i2c->pclkrate < SYNQUACER_I2C_MIN_CLK_RATE ||
i2c->pclkrate > SYNQUACER_I2C_MAX_CLK_RATE)
--
2.46.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v1 1/1] i2c: synquacer: Fix clock rate retrieval code
2024-09-12 14:41 [PATCH v1 1/1] i2c: synquacer: Fix clock rate retrieval code Andy Shevchenko
@ 2024-09-12 14:49 ` Andi Shyti
2024-09-12 15:38 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Andi Shyti @ 2024-09-12 14:49 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Ard Biesheuvel, Christophe JAILLET, linux-i2c, linux-kernel
Hi Andy,
On Thu, Sep 12, 2024 at 05:41:05PM GMT, Andy Shevchenko wrote:
> With the devm_clk_get_enabled() the probe will fail on the systems
> that have no clock provided, such as ACPI-based ones.
>
> synquacer_i2c SCX0003:00: error -ENOENT: failed to get and enable clock
> synquacer_i2c SCX0003:00: probe with driver synquacer_i2c failed with error -2
>
> Fix this by switching to devm_clk_get_optional_enabled() in conjunction with NULL
> check, so we won't overwrite the clock rate from the property.
>
> Fixes: 55750148e559 ("i2c: synquacer: Fix an error handling path in synquacer_i2c_probe()")
> Reported-by: Ard Biesheuvel <ardb@kernel.org>
> Closes: https://lore.kernel.org/r/CAMj1kXFH+zB_YuUS+vaEpguhuVGLYbQw55VNDCxnBfSPe6b-nw@mail.gmail.com
> Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
you are late, Ard already sent the fix :-)
Thanks,
Andi
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1 1/1] i2c: synquacer: Fix clock rate retrieval code
2024-09-12 14:49 ` Andi Shyti
@ 2024-09-12 15:38 ` Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2024-09-12 15:38 UTC (permalink / raw)
To: Andi Shyti; +Cc: Ard Biesheuvel, Christophe JAILLET, linux-i2c, linux-kernel
On Thu, Sep 12, 2024 at 5:49 PM Andi Shyti <andi.shyti@kernel.org> wrote:
> On Thu, Sep 12, 2024 at 05:41:05PM GMT, Andy Shevchenko wrote:
> > With the devm_clk_get_enabled() the probe will fail on the systems
> > that have no clock provided, such as ACPI-based ones.
> >
> > synquacer_i2c SCX0003:00: error -ENOENT: failed to get and enable clock
> > synquacer_i2c SCX0003:00: probe with driver synquacer_i2c failed with error -2
> >
> > Fix this by switching to devm_clk_get_optional_enabled() in conjunction with NULL
> > check, so we won't overwrite the clock rate from the property.
> >
> > Fixes: 55750148e559 ("i2c: synquacer: Fix an error handling path in synquacer_i2c_probe()")
> > Reported-by: Ard Biesheuvel <ardb@kernel.org>
> > Closes: https://lore.kernel.org/r/CAMj1kXFH+zB_YuUS+vaEpguhuVGLYbQw55VNDCxnBfSPe6b-nw@mail.gmail.com
> > Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
> you are late, Ard already sent the fix :-)
Ah, and it's identical! Means it's good as is :-)
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-12 15:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-12 14:41 [PATCH v1 1/1] i2c: synquacer: Fix clock rate retrieval code Andy Shevchenko
2024-09-12 14:49 ` Andi Shyti
2024-09-12 15:38 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox