diff mbox series

[1/1] media: ov5670: Fix probe on ACPI

Message ID 20230329152210.1554736-1-sakari.ailus@linux.intel.com
State New
Headers show
Series [1/1] media: ov5670: Fix probe on ACPI | expand

Commit Message

Sakari Ailus March 29, 2023, 3:22 p.m. UTC
devm_clk_get() will return either an error or NULL, which the driver
handles, continuing to use the clock of reading the value of the
clock-frequency property.

However, the value of ov5670->xvclk is left as-is and the other clock
framework functions aren't capable of handling error values.

Assign ov5670->xvclk to NULL if the clock cannot be found (apart from probe
deferral case).

Fixes: 8004c91e2095 ("media: i2c: ov5670: Use common clock framework")
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/i2c/ov5670.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Jacopo Mondi March 29, 2023, 4:35 p.m. UTC | #1
Hi Sakari

On Wed, Mar 29, 2023 at 06:22:10PM +0300, Sakari Ailus wrote:
> devm_clk_get() will return either an error or NULL, which the driver
> handles, continuing to use the clock of reading the value of the
> clock-frequency property.
>
> However, the value of ov5670->xvclk is left as-is and the other clock
> framework functions aren't capable of handling error values.
>
> Assign ov5670->xvclk to NULL if the clock cannot be found (apart from probe
> deferral case).
>
> Fixes: 8004c91e2095 ("media: i2c: ov5670: Use common clock framework")
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

Ah yes! Thanks for spotting

Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>

> ---
>  drivers/media/i2c/ov5670.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
> index f79d908f4531..50c73ad86e21 100644
> --- a/drivers/media/i2c/ov5670.c
> +++ b/drivers/media/i2c/ov5670.c
> @@ -2661,14 +2661,16 @@ static int ov5670_probe(struct i2c_client *client)
>  	}
>
>  	ov5670->xvclk = devm_clk_get(&client->dev, NULL);
> -	if (!IS_ERR_OR_NULL(ov5670->xvclk))
> +	if (!IS_ERR_OR_NULL(ov5670->xvclk)) {
>  		input_clk = clk_get_rate(ov5670->xvclk);
> -	else if (PTR_ERR(ov5670->xvclk) == -ENOENT)
> +	} else if (PTR_ERR(ov5670->xvclk) == -ENOENT) {
>  		device_property_read_u32(&client->dev, "clock-frequency",
>  					 &input_clk);
> -	else
> +		ov5670->xvclk = NULL;
> +	} else {
>  		return dev_err_probe(&client->dev, PTR_ERR(ov5670->xvclk),
>  				     "error getting clock\n");
> +	}
>
>  	if (input_clk != OV5670_XVCLK_FREQ) {
>  		dev_err(&client->dev,
> --
> 2.30.2
>
diff mbox series

Patch

diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c
index f79d908f4531..50c73ad86e21 100644
--- a/drivers/media/i2c/ov5670.c
+++ b/drivers/media/i2c/ov5670.c
@@ -2661,14 +2661,16 @@  static int ov5670_probe(struct i2c_client *client)
 	}
 
 	ov5670->xvclk = devm_clk_get(&client->dev, NULL);
-	if (!IS_ERR_OR_NULL(ov5670->xvclk))
+	if (!IS_ERR_OR_NULL(ov5670->xvclk)) {
 		input_clk = clk_get_rate(ov5670->xvclk);
-	else if (PTR_ERR(ov5670->xvclk) == -ENOENT)
+	} else if (PTR_ERR(ov5670->xvclk) == -ENOENT) {
 		device_property_read_u32(&client->dev, "clock-frequency",
 					 &input_clk);
-	else
+		ov5670->xvclk = NULL;
+	} else {
 		return dev_err_probe(&client->dev, PTR_ERR(ov5670->xvclk),
 				     "error getting clock\n");
+	}
 
 	if (input_clk != OV5670_XVCLK_FREQ) {
 		dev_err(&client->dev,