diff mbox series

[leds,v2,26/50] leds: is31fl319x: don't store shutdown gpio descriptor

Message ID 20200917223338.14164-27-marek.behun@nic.cz
State New
Headers show
Series None | expand

Commit Message

Marek BehĂșn Sept. 17, 2020, 10:33 p.m. UTC
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@nic.cz>
Cc: H. Nikolaus Schaller <hns@goldelico.com>
Cc: Grant Feng <von81@163.com>
---
 drivers/leds/leds-is31fl319x.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)
diff mbox series

Patch

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)) {