gpio: max730x: use devres to shrink and simplify code
PATCH 1/1 gpio: max730x: use devres to shrink and simplify code
From: Bartosz Golaszewski <[email protected]>
Use managed variants of gpiochip_add_data() and mutex_init() to drop a label and lose a couple LOC.
Signed-off-by Bartosz Golaszewski <[email protected]>
--- drivers/gpio/gpio-max730x.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/gpio/gpio-max730x.c +6 -11
@@ -165,7 +165,10 @@ int __max730x_probe(struct max7301 *ts) pdata =dev_get_platdata (dev); -mutex_init (&ts->lock); + ret =devm_mutex_init (ts->dev, &ts->lock); +if (ret) +return ret; +dev_set_drvdata (dev, ts);/* Power up the chip and disable IRQ output */
@@ -206,17 +209,11 @@ int __max730x_probe(struct max7301 *ts)int offset = (i -1 ) *4 + j; ret =max7301_direction_input (&ts->chip, offset);if (ret) - goto exit_destroy; +return ret; } } - ret =gpiochip_add_data (&ts->chip, ts); -if (!ret) -return ret; - -exit_destroy: -mutex_destroy (&ts->lock); -return ret; +return devm_gpiochip_add_data (ts->dev, &ts->chip, ts); }EXPORT_SYMBOL_GPL (__max730x_probe);
@@ -226,8 +223,6 @@ void __max730x_remove(struct device *dev)/* Power down the chip and disable IRQ output */ ts->write (dev,0x04 ,0x00 ); -gpiochip_remove (&ts->chip); -mutex_destroy (&ts->lock); }EXPORT_SYMBOL_GPL (__max730x_remove);
Signature · 1 line
2.43.0
Quoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Use managed variants of
gpiochip_add_data()andmutex_init()to drop a label and lose a couple LOC.Signed-off-by Bartosz Golaszewski <[email protected]>
Reviewed-by Linus Walleij <[email protected]>
Yours,
Linus Walleij
Bartosz Golaszewski
AppliedFrom: Bartosz Golaszewski <[email protected]>
Quoted 4 lines · Bartosz Golaszewski
Use managed variants of
gpiochip_add_data()andmutex_init()to drop a label and lose a couple LOC.
Applied, thanks!
[1/1] gpio: max730x: use devres to shrink and simplify code
commit: 57e0e7188712dae39045e4004c7c7f9ce0a36193
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>