From patchwork Mon Dec 11 17:50:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Rudenko X-Patchwork-Id: 13487745 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IqFLlH4h" Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA29AD0; Mon, 11 Dec 2023 09:50:51 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-50bf1e32571so5581961e87.2; Mon, 11 Dec 2023 09:50:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702317049; x=1702921849; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e4fte2YHRSrHHN42OBWruBtaIGZ/SFtVFuhUHEuhcX8=; b=IqFLlH4hfcQN+nVLz+K238zJs287ZHvR6ddocANW7MKwC1bTrAp5lE/ASgXEyoUvQl oqEn1zXb5ta+5RjuYRJYTslbWIF26fWJwIcL6ap/MP/12dMZ0yHjQWgvRgygRFfwRMlX AYglRkXztW9Xk/JY6ZzssxWLtktBFOMc0oGesNzaD81QSLZ6Yr1FIV9YlZJ4ZROc6PaC 5Naf2893cI63+ICan4gDM8BnyZ8e1tGTkQzOVOrC0/B/UPw8Y34mU1ow4s0Idtw0hdoO 1rQd0Lr1voyFVAixcFPoObmOuywWf0qbZBlGPd6L/T9WI18C7t0ShOyOvhAhzYTqiBWZ hKvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702317049; x=1702921849; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e4fte2YHRSrHHN42OBWruBtaIGZ/SFtVFuhUHEuhcX8=; b=NtReQpCWkpf0gtZGwIPsPKvbmE8UgIlP1rvFea3DF+R4WWiw1xFsrmOLXN7T4yJYVg QRlEZkXI/q5UZP0zLiVgWGdO6vzYxSEEgwH4r2rulSMBTtEd8qqAJj6/ecHu+Ds1/WY1 XlrUgCh+6mxSXthzasazIq/RBhsFh/+Czf8QFUN/G/33U9rroJf6SDzK8dON87ILJUle CP7M0R5c9NqwN9nRW+9LNjJ4feUAwAogal/O+UoaJnXwZmu0+gpKfOniIesJTPbxh+6C w7J3J0BmmqZSLAtD9tdbyyNRWoK13Za+qHLQEauB4LfWVN4wSbEe3fCoPm0sjhcDiTyT pxew== X-Gm-Message-State: AOJu0YxuayilUJAFgHP0X0XA3uephF625qxtVnmVo9znGjKcLHwTbxfc IDGX91YZ6XrJV/IGMnELR3iNUtgtXch1/ozV X-Google-Smtp-Source: AGHT+IF5X7lZC/m/xlcA22hSseem5KEqJ7lk6Q+Zx/IJMWZsJ4d2zmf8M/D4xSPXrwkgHBduCisf8Q== X-Received: by 2002:ac2:5328:0:b0:50d:ff76:61ee with SMTP id f8-20020ac25328000000b0050dff7661eemr767800lfh.134.1702317049431; Mon, 11 Dec 2023 09:50:49 -0800 (PST) Received: from localhost ([83.149.246.185]) by smtp.gmail.com with ESMTPSA id k4-20020a05651210c400b0050bef21a012sm1141582lfg.191.2023.12.11.09.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 09:50:48 -0800 (PST) From: Mikhail Rudenko To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sakari Ailus , Laurent Pinchart , Jacopo Mondi , Tommaso Merciai , Christophe JAILLET , Dave Stevenson , Mauro Carvalho Chehab , Mikhail Rudenko Subject: [PATCH 05/19] media: i2c: ov4689: Refactor ov4689_set_ctrl Date: Mon, 11 Dec 2023 20:50:08 +0300 Message-ID: <20231211175023.1680247-6-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231211175023.1680247-1-mike.rudenko@gmail.com> References: <20231211175023.1680247-1-mike.rudenko@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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; }