media: i2c: ov5670: Fix conditions for clock access
Sakari Ailus
maintainerPATCH 1/1 media: i2c: ov5670: Fix conditions for clock access
Leftovers from the earlier fix. Fix also the conditions for reading the clock-frequency property as well as accessing the clock.
--- drivers/media/i2c/ov5670.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/i2c/ov5670.c +2 -2
@@ -2661,9 +2661,9 @@ static int ov5670_probe(struct i2c_client *client) } ov5670->xvclk =devm_clk_get_optional (&client->dev,NULL ); -if (!IS_ERR_OR_NULL (ov5670->xvclk)) +if (!IS_ERR (ov5670->xvclk)) input_clk =clk_get_rate (ov5670->xvclk); -else if (PTR_ERR (ov5670->xvclk) == -ENOENT ) +else if (!ov5670->xvclk)device_property_read_u32 (&client->dev,"clock-frequency" , &input_clk);else
Signature · 1 line
2.30.2
Hi Sakari
Quoted 14 lines · Sakari Ailus
Leftovers from the earlier fix. Fix also the conditions for reading the clock-frequency property as well as accessing the clock.
Fixes 8df08ba4a331 ("media: ov5670: Fix probe on ACPI")Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ov5670.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/media/i2c/ov5670.c +0
-0
drivers/media/i2c/ov5670.c static int ov5670_probe(struct i2c_client *client) · line 2664
Quoted 5 lines
drivers/media/i2c/ov5670.c +1
-1@@ -2661,9 +2661,9 @@ static int ov5670_probe(struct i2c_client *client) } ov5670->xvclk =devm_clk_get_optional (&client->dev,NULL ); -if (!IS_ERR_OR_NULL (ov5670->xvclk)) +if (!IS_ERR (ov5670->xvclk))
Can't clk_get_optional() return NULL in the case the clock source is not available ?
Also, if !CONFIG_HAVE_CLK devm_clk_get_optional() returns 0.
I would then keep the _OR_NULL() part
drivers/media/i2c/ov5670.c static int ov5670_probe(struct i2c_client *client) · line 2666
Quoted 3 lines
drivers/media/i2c/ov5670.c +1
-1input_clk =clk_get_rate (ov5670->xvclk); - else if (PTR_ERR(ov5670->xvclk) == -ENOENT) + else if (!ov5670->xvclk)
While here it's probably correct, we only want to read "clock-frequency" if xvclk == NULL (when either the clock providere is not there, or !CONFIG_HAVE_CLK)
drivers/media/i2c/ov5670.c static int ov5670_probe(struct i2c_client *client) · line 2669
Quoted 3 lines
drivers/media/i2c/ov5670.c +0
-0device_property_read_u32 (&client->dev,"clock-frequency" , &input_clk); else
Everything else is an error (in example, -EPROBE_DEFER)
Quoted 3 lines
--
2.30.2
Sakari Ailus
maintainerHi Jacopo,
Quoted 19 lines · Jacopo Mondi
Hi Sakari
Quoted 16 lines · Sakari Ailus
Leftovers from the earlier fix. Fix also the conditions for reading the clock-frequency property as well as accessing the clock.
Fixes 8df08ba4a331 ("media: ov5670: Fix probe on ACPI")Signed-off-by Sakari Ailus <[email protected]>--- drivers/media/i2c/ov5670.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/media/i2c/ov5670.c +0
-0@@ -2661,9 +2661,9 @@ static int ov5670_probe(struct i2c_client *client) }
Quoted 8 lines
drivers/media/i2c/ov5670.c static int ov5670_probe(struct i2c_client *client) · line 2664
Quoted 3 lines
drivers/media/i2c/ov5670.c +1
-1ov5670->xvclk =devm_clk_get_optional (&client->dev,NULL ); -if (!IS_ERR_OR_NULL (ov5670->xvclk)) +if (!IS_ERR (ov5670->xvclk))Can't
clk_get_optional()return NULL in the case the clock source is not available ?Also, if !CONFIG_HAVE_CLK
devm_clk_get_optional()returns 0.
Correct. And in that case the clock-frequency property should be read instead.
Quoted 17 lines
I would then keep the
_OR_NULL()partdrivers/media/i2c/ov5670.c static int ov5670_probe(struct i2c_client *client) · line 2666
Quoted 3 lines
drivers/media/i2c/ov5670.c +1
-1input_clk =clk_get_rate (ov5670->xvclk); - else if (PTR_ERR(ov5670->xvclk) == -ENOENT) + else if (!ov5670->xvclk)While here it's probably correct, we only want to read "clock-frequency" if xvclk == NULL (when either the clock providere is not there, or !CONFIG_HAVE_CLK)
drivers/media/i2c/ov5670.c static int ov5670_probe(struct i2c_client *client) · line 2669
Quoted 3 lines
drivers/media/i2c/ov5670.c +0
-0device_property_read_u32 (&client->dev,"clock-frequency" , &input_clk); elseEverything else is an error (in example, -EPROBE_DEFER)
Signature · 3 lines
Regards, Sakari Ailus