All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Subject: [PATCH 6/7] smiapp: Refactor reading SMIA limits
Date: Thu, 13 Feb 2020 11:49:33 +0200	[thread overview]
Message-ID: <20200213094934.18595-7-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20200213094934.18595-1-sakari.ailus@linux.intel.com>

Combine the two trivial functions reading limits into one. Also rename
smiapp_get_all_limits() as smiapp_read_all_smia_limits().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/i2c/smiapp/smiapp-core.c | 32 ++++++++------------------
 1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index a6800e5c495d..5e4f6a2ef78e 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -69,37 +69,25 @@ static u32 smiapp_get_limit(struct smiapp_sensor *sensor,
 #define SMIA_LIM(sensor, limit) \
 	smiapp_get_limit(sensor, SMIAPP_LIMIT_##limit)
 
-static int smiapp_get_limits(struct smiapp_sensor *sensor, int const *limit,
-			     unsigned int n)
+static int smiapp_read_all_smia_limits(struct smiapp_sensor *sensor)
 {
 	struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
 	unsigned int i;
-	u32 val;
 	int rval;
 
-	for (i = 0; i < n; i++) {
+	for (i = 0; i < SMIAPP_LIMIT_LAST; i++) {
+		u32 val;
+
 		rval = smiapp_read(
-			sensor, smiapp_reg_limits[limit[i]].addr, &val);
+			sensor, smiapp_reg_limits[i].addr, &val);
 		if (rval)
 			return rval;
-		sensor->limits[limit[i]] = val;
-		dev_dbg(&client->dev, "0x%8.8x \"%s\" = %u, 0x%x\n",
-			smiapp_reg_limits[limit[i]].addr,
-			smiapp_reg_limits[limit[i]].what, val, val);
-	}
 
-	return 0;
-}
+		sensor->limits[i] = val;
 
-static int smiapp_get_all_limits(struct smiapp_sensor *sensor)
-{
-	unsigned int i;
-	int rval;
-
-	for (i = 0; i < SMIAPP_LIMIT_LAST; i++) {
-		rval = smiapp_get_limits(sensor, &i, 1);
-		if (rval < 0)
-			return rval;
+		dev_dbg(&client->dev, "0x%8.8x \"%s\" = %u, 0x%x\n",
+			smiapp_reg_limits[i].addr,
+			smiapp_reg_limits[i].what, val, val);
 	}
 
 	if (SMIA_LIM(sensor, SCALER_N_MIN) == 0)
@@ -2938,7 +2926,7 @@ static int smiapp_probe(struct i2c_client *client)
 		goto out_power_off;
 	}
 
-	rval = smiapp_get_all_limits(sensor);
+	rval = smiapp_read_all_smia_limits(sensor);
 	if (rval) {
 		rval = -ENODEV;
 		goto out_power_off;
-- 
2.20.1


  parent reply	other threads:[~2020-02-13  9:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-13  9:49 [PATCH 0/7] smiapp, omap3isp: Cleanups and fixes Sakari Ailus
2020-02-13  9:49 ` [PATCH 1/7] omap3isp: Prevent enabling CCDC when stopping streaming Sakari Ailus
2020-02-13  9:49 ` [PATCH 2/7] smiapp: Simplify condition for choosing 8-bit access Sakari Ailus
2020-02-13  9:49 ` [PATCH 3/7] smiapp: Use unaligned get and put functions Sakari Ailus
2020-02-13  9:49 ` [PATCH 4/7] smiapp: Turn limit lookup into a function Sakari Ailus
2020-02-13  9:49 ` [PATCH 5/7] smiapp: Move SMIA limit reading up Sakari Ailus
2020-02-13  9:49 ` Sakari Ailus [this message]
2020-02-13  9:49 ` [PATCH 7/7] smiapp: Move definitions under driver directory Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200213094934.18595-7-sakari.ailus@linux.intel.com \
    --to=sakari.ailus@linux.intel.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.