i2c: synquacer: Fix clock rate retrieval code
Subsystems (2)
PATCH 1/1 i2c: synquacer: Fix clock rate retrieval code
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.
--- drivers/i2c/busses/i2c-synquacer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-synquacer.c +3 -3
@@ -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 )
Signature · 1 line
2.46.0
Andi Shyti
maintainerHi Andy,
Quoted 6 lines · 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_i2cSCX0003:00: error-ENOENT: failed to get and enable clocksynquacer_i2cSCX0003:00: probe with driversynquacer_i2cfailed with error -2
Quoted 7 lines
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 <[email protected]>Closes https://lore.kernel.org/r/CAMj1kXFH+zB_YuUS+vaEpguhuVGLYbQw55VNDCxnBfSPe6b-nw@mail.gmail.com open hereSigned-off-by Andy Shevchenko <[email protected]>
you are late, Ard already sent the fix :-)
Thanks,
Andi
Quoted 10 lines · Andi Shyti
Quoted 9 lines · 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_i2cSCX0003:00: error-ENOENT: failed to get and enable clocksynquacer_i2cSCX0003:00: probe with driversynquacer_i2cfailed with error -2Fix 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.
Quoted 6 lines
Quoted 4 lines
Fixes 55750148e559 ("i2c: synquacer: Fix an error handling path in synquacer_i2c_probe()")Reported-by Ard Biesheuvel <[email protected]>Closes https://lore.kernel.org/r/CAMj1kXFH+zB_YuUS+vaEpguhuVGLYbQw55VNDCxnBfSPe6b-nw@mail.gmail.com open hereSigned-off-by Andy Shevchenko <[email protected]>you are late, Ard already sent the fix :-)
Ah, and it's identical! Means it's good as is :-)
Signature · 2 lines
With Best Regards, Andy Shevchenko