diff mbox series

[RESEND,2/2] ASoC: cs4265: Move reset_gpio to local scope

Message ID 20211222141920.1482451-2-festevam@gmail.com (mailing list archive)
State Superseded
Headers show
Series [RESEND,1/2] ASoC: cs4265: Fix part number ID error message | expand

Commit Message

Fabio Estevam Dec. 22, 2021, 2:19 p.m. UTC
From: Fabio Estevam <festevam@denx.de>

There is no need to keep 'struct gpio_desc *reset_gpio' inside
the private structure becase reset_gpio is only used inside the
probe() function.

Move it to a local scope.

Signed-off-by: Fabio Estevam <festevam@denx.de>
---
 sound/soc/codecs/cs4265.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Charles Keepax Dec. 29, 2021, 10 a.m. UTC | #1
On Wed, Dec 22, 2021 at 11:19:20AM -0300, Fabio Estevam wrote:
> From: Fabio Estevam <festevam@denx.de>
> 
> There is no need to keep 'struct gpio_desc *reset_gpio' inside
> the private structure becase reset_gpio is only used inside the
> probe() function.
> 
> Move it to a local scope.
> 
> Signed-off-by: Fabio Estevam <festevam@denx.de>
> ---

Patch looks fine, but I do have a slight doubt would it perhaps
be better to add a remove function that puts the device back into
reset, thus keeping the private member? Feels like it might be a
nicer state to leave the chip in if the driver unbinds.

Thanks,
Charles
diff mbox series

Patch

diff --git a/sound/soc/codecs/cs4265.c b/sound/soc/codecs/cs4265.c
index b89002189a2b..88d89366f816 100644
--- a/sound/soc/codecs/cs4265.c
+++ b/sound/soc/codecs/cs4265.c
@@ -29,7 +29,6 @@ 
 
 struct cs4265_private {
 	struct regmap *regmap;
-	struct gpio_desc *reset_gpio;
 	u8 format;
 	u32 sysclk;
 };
@@ -573,6 +572,7 @@  static int cs4265_i2c_probe(struct i2c_client *i2c_client,
 			     const struct i2c_device_id *id)
 {
 	struct cs4265_private *cs4265;
+	struct gpio_desc *reset_gpio;
 	int ret;
 	unsigned int devid = 0;
 	unsigned int reg;
@@ -589,14 +589,14 @@  static int cs4265_i2c_probe(struct i2c_client *i2c_client,
 		return ret;
 	}
 
-	cs4265->reset_gpio = devm_gpiod_get_optional(&i2c_client->dev,
-		"reset", GPIOD_OUT_LOW);
-	if (IS_ERR(cs4265->reset_gpio))
-		return PTR_ERR(cs4265->reset_gpio);
+	reset_gpio = devm_gpiod_get_optional(&i2c_client->dev, "reset",
+					      GPIOD_OUT_LOW);
+	if (IS_ERR(reset_gpio))
+		return PTR_ERR(reset_gpio);
 
-	if (cs4265->reset_gpio) {
+	if (reset_gpio) {
 		mdelay(1);
-		gpiod_set_value_cansleep(cs4265->reset_gpio, 1);
+		gpiod_set_value_cansleep(reset_gpio, 1);
 	}
 
 	i2c_set_clientdata(i2c_client, cs4265);