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:   Fri, 18 Sep 2020 00:33:15 +0200
From:   Marek Behún <marek.behun@....cz>
To:     linux-leds@...r.kernel.org
Cc:     Pavel Machek <pavel@....cz>, Dan Murphy <dmurphy@...com>,
        Ondřej Jirman <megous@...ous.com>,
        linux-kernel@...r.kernel.org, Rob Herring <robh+dt@...nel.org>,
        devicetree@...r.kernel.org,
        Marek Behún <marek.behun@....cz>,
        "H . Nikolaus Schaller" <hns@...delico.com>,
        Grant Feng <von81@....com>
Subject: [PATCH leds v2 27/50] leds: is31fl319x: don't store audio gain value, simply set it

Since this value is only used in device probe, don't store it in private
structure. Simply parse the value and set it.

Signed-off-by: Marek Behún <marek.behun@....cz>
Cc: H. Nikolaus Schaller <hns@...delico.com>
Cc: Grant Feng <von81@....com>
---
 drivers/leds/leds-is31fl319x.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c
index 595112958617e..8e3e02d959989 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -65,7 +65,6 @@ struct is31fl319x_chip {
 	struct i2c_client               *client;
 	struct regmap                   *regmap;
 	struct mutex                    lock;
-	u32                             audio_gain_db;
 
 	struct is31fl319x_led {
 		struct is31fl319x_chip  *chip;
@@ -198,6 +197,18 @@ static int is31fl319x_parse_max_current(struct device *dev, u32 *aggregated)
 	return 0;
 }
 
+static u32 is31fl319x_parse_audio_gain(struct device *dev)
+{
+	u32 result;
+
+	if (!of_property_read_u32(dev_of_node(dev), "audio-gain-db", &result))
+		result = min(result, IS31FL319X_AUDIO_GAIN_DB_MAX);
+	else
+		result = 0;
+
+	return result;;
+}
+
 static int is31fl319x_parse_child_dt(const struct device *dev,
 				     const struct device_node *child,
 				     struct is31fl319x_led *led)
@@ -271,12 +282,6 @@ static int is31fl319x_parse_dt(struct device *dev,
 		led->configured = true;
 	}
 
-	is31->audio_gain_db = 0;
-	ret = of_property_read_u32(np, "audio-gain-db", &is31->audio_gain_db);
-	if (!ret)
-		is31->audio_gain_db = min(is31->audio_gain_db,
-					  IS31FL319X_AUDIO_GAIN_DB_MAX);
-
 	return 0;
 
 put_child_node:
@@ -346,6 +351,7 @@ static int is31fl319x_probe(struct i2c_client *client,
 	struct is31fl319x_chip *is31;
 	struct device *dev = &client->dev;
 	struct gpio_desc *shutdown_gpio;
+	u32 audio_gain_db;
 	int err;
 	int i = 0;
 	u32 aggregated_led_microamp;
@@ -405,9 +411,11 @@ static int is31fl319x_probe(struct i2c_client *client,
 		goto free_mutex;
 	}
 
+	audio_gain_db = is31fl319x_parse_audio_gain(dev);
+
 	regmap_write(is31->regmap, IS31FL319X_CONFIG2,
 		     is31fl319x_microamp_to_cs(dev, aggregated_led_microamp) |
-		     is31fl319x_db_to_gain(is31->audio_gain_db));
+		     is31fl319x_db_to_gain(audio_gain_db));
 
 	for (i = 0; i < is31->cdef->num_leds; i++) {
 		struct is31fl319x_led *led = &is31->leds[i];
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ