OSDN Git Service

media: ccs: Stop reading arrays after the first zero
authorSakari Ailus <sakari.ailus@linux.intel.com>
Wed, 27 May 2020 08:35:01 +0000 (10:35 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 3 Dec 2020 11:27:31 +0000 (12:27 +0100)
The register arrays have a certain size but not all the entries will be
relevant. In practice reading can be stopped after encountering a zero
value in the array. Do that to avoid extra reads.

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 be27b00..dec248f 100644 (file)
@@ -199,6 +199,9 @@ static int ccs_read_all_limits(struct ccs_sensor *sensor)
                                goto out_err;
                        }
 
+                       if (!val && j)
+                               break;
+
                        ccs_assign_limit(ptr, width, val);
 
                        dev_dbg(&client->dev, "0x%8.8x \"%s\" = %u, 0x%x\n",