lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 11 Dec 2023 20:50:08 +0300
From:   Mikhail Rudenko <mike.rudenko@...il.com>
To:     linux-media@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:     Sakari Ailus <sakari.ailus@...ux.intel.com>,
        Laurent Pinchart <laurent.pinchart@...asonboard.com>,
        Jacopo Mondi <jacopo@...ndi.org>,
        Tommaso Merciai <tommaso.merciai@...rulasolutions.com>,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        Dave Stevenson <dave.stevenson@...pberrypi.com>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Mikhail Rudenko <mike.rudenko@...il.com>
Subject: [PATCH 05/19] media: i2c: ov4689: Refactor ov4689_set_ctrl

Introduces local variables for regmap and the control value within the
ov4689_set_ctrl function. This adjustment eliminates repetition within
the function.

Signed-off-by: Mikhail Rudenko <mike.rudenko@...il.com>
---
 drivers/media/i2c/ov4689.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c
index 8c120d7f7830..42700ecfbe0e 100644
--- a/drivers/media/i2c/ov4689.c
+++ b/drivers/media/i2c/ov4689.c
@@ -584,7 +584,9 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl)
 {
 	struct ov4689 *ov4689 =
 		container_of(ctrl->handler, struct ov4689, ctrl_handler);
+	struct regmap *regmap = ov4689->regmap;
 	struct device *dev = ov4689->dev;
+	s32 val = ctrl->val;
 	int sensor_gain;
 	s64 max_expo;
 	int ret;
@@ -593,7 +595,7 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl)
 	switch (ctrl->id) {
 	case V4L2_CID_VBLANK:
 		/* Update max exposure while meeting expected vblanking */
-		max_expo = ov4689->cur_mode->height + ctrl->val - 4;
+		max_expo = ov4689->cur_mode->height + val - 4;
 		__v4l2_ctrl_modify_range(ov4689->exposure,
 					 ov4689->exposure->minimum, max_expo,
 					 ov4689->exposure->step,
@@ -607,36 +609,34 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl)
 	switch (ctrl->id) {
 	case V4L2_CID_EXPOSURE:
 		/* 4 least significant bits of exposure are fractional part */
-		ret = cci_write(ov4689->regmap, OV4689_REG_EXPOSURE,
-				ctrl->val << 4, NULL);
+		cci_write(regmap, OV4689_REG_EXPOSURE, val << 4, &ret);
 		break;
 	case V4L2_CID_ANALOGUE_GAIN:
-		ret = ov4689_map_gain(ov4689, ctrl->val, &sensor_gain);
+		ret = ov4689_map_gain(ov4689, val, &sensor_gain);
 
-		cci_write(ov4689->regmap, OV4689_REG_GAIN_H,
+		cci_write(regmap, OV4689_REG_GAIN_H,
 			  (sensor_gain >> OV4689_GAIN_H_SHIFT) &
 			  OV4689_GAIN_H_MASK, &ret);
 
-		cci_write(ov4689->regmap, OV4689_REG_GAIN_L,
+		cci_write(regmap, OV4689_REG_GAIN_L,
 			  sensor_gain & OV4689_GAIN_L_MASK,
 			  &ret);
 		break;
 	case V4L2_CID_VBLANK:
-		ret = cci_write(ov4689->regmap, OV4689_REG_VTS,
-				ctrl->val + ov4689->cur_mode->height, NULL);
+		cci_write(regmap, OV4689_REG_VTS,
+			  val + ov4689->cur_mode->height, &ret);
 		break;
 	case V4L2_CID_TEST_PATTERN:
-		ret = ov4689_enable_test_pattern(ov4689, ctrl->val);
+		ret = ov4689_enable_test_pattern(ov4689, val);
 		break;
 	default:
 		dev_warn(dev, "%s Unhandled id:0x%x, val:0x%x\n",
-			 __func__, ctrl->id, ctrl->val);
+			 __func__, ctrl->id, val);
 		ret = -EINVAL;
 		break;
 	}
 
 	pm_runtime_put(dev);
-
 	return ret;
 }
 
-- 
2.43.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ