OSDN Git Service

media: ccs: Add a sanity check for external clock frequency
authorSakari Ailus <sakari.ailus@linux.intel.com>
Thu, 8 Oct 2020 16:43:56 +0000 (18:43 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 12 Jan 2021 16:52:31 +0000 (17:52 +0100)
The driver depends on the external clock frequency. Add a sanity check for
the frequency, by returning an error from probe if it's zero.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/i2c/ccs/ccs-core.c

index fae8ced..08fce28 100644 (file)
@@ -3275,6 +3275,11 @@ static int ccs_probe(struct i2c_client *client)
                return -EINVAL;
        }
 
+       if (!sensor->hwcfg.ext_clk) {
+               dev_err(&client->dev, "cannot work with xclk frequency 0\n");
+               return -EINVAL;
+       }
+
        sensor->reset = devm_gpiod_get_optional(&client->dev, "reset",
                                                GPIOD_OUT_HIGH);
        if (IS_ERR(sensor->reset))