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:14 +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 26/50] leds: is31fl319x: don't store shutdown gpio descriptor

Since the shutdown gpio descriptor is only accessed in device probe
method there is no need to store it in the private structure.

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 | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c
index ba1a5da5521b5..595112958617e 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -63,7 +63,6 @@
 struct is31fl319x_chip {
 	const struct is31fl319x_chipdef *cdef;
 	struct i2c_client               *client;
-	struct gpio_desc		*shutdown_gpio;
 	struct regmap                   *regmap;
 	struct mutex                    lock;
 	u32                             audio_gain_db;
@@ -227,15 +226,6 @@ static int is31fl319x_parse_dt(struct device *dev,
 	if (!np)
 		return -ENODEV;
 
-	is31->shutdown_gpio = devm_gpiod_get_optional(dev,
-						"shutdown",
-						GPIOD_OUT_HIGH);
-	if (IS_ERR(is31->shutdown_gpio)) {
-		ret = PTR_ERR(is31->shutdown_gpio);
-		dev_err(dev, "Failed to get shutdown gpio: %d\n", ret);
-		return ret;
-	}
-
 	is31->cdef = device_get_match_data(dev);
 
 	count = of_get_available_child_count(np);
@@ -355,6 +345,7 @@ static int is31fl319x_probe(struct i2c_client *client,
 {
 	struct is31fl319x_chip *is31;
 	struct device *dev = &client->dev;
+	struct gpio_desc *shutdown_gpio;
 	int err;
 	int i = 0;
 	u32 aggregated_led_microamp;
@@ -375,18 +366,26 @@ static int is31fl319x_probe(struct i2c_client *client,
 	if (!is31)
 		return -ENOMEM;
 
+	shutdown_gpio = gpiod_get_optional(dev, "shutdown", GPIOD_OUT_HIGH);
+	if (IS_ERR(shutdown_gpio)) {
+		err = PTR_ERR(shutdown_gpio);
+		dev_err(dev, "Failed to get shutdown gpio: %d\n", err);
+		return err;
+	}
+
+	if (shutdown_gpio) {
+		gpiod_direction_output(shutdown_gpio, 0);
+		mdelay(5);
+		gpiod_direction_output(shutdown_gpio, 1);
+		gpiod_put(shutdown_gpio);
+	}
+
 	mutex_init(&is31->lock);
 
 	err = is31fl319x_parse_dt(&client->dev, is31);
 	if (err)
 		goto free_mutex;
 
-	if (is31->shutdown_gpio) {
-		gpiod_direction_output(is31->shutdown_gpio, 0);
-		mdelay(5);
-		gpiod_direction_output(is31->shutdown_gpio, 1);
-	}
-
 	is31->client = client;
 	is31->regmap = devm_regmap_init_i2c(client, &regmap_config);
 	if (IS_ERR(is31->regmap)) {
-- 
2.26.2

Powered by blists - more mailing lists