gpio: 74x164: shrink code
PATCH 1/1 gpio: 74x164: shrink code
From: Bartosz Golaszewski <[email protected]>
Use managed helpers to drop the goto label from probe() and shrink the remove() callback.
Signed-off-by Bartosz Golaszewski <[email protected]>
--- drivers/gpio/gpio-74x164.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/gpio/gpio-74x164.c +6 -15
@@ -143,24 +143,17 @@ static int gen_74x164_probe(struct spi_device *spi) chip->gpio_chip.parent = &spi->dev; chip->gpio_chip.owner =THIS_MODULE ; -mutex_init (&chip->lock); + ret =devm_mutex_init (&spi->dev, &chip->lock); +if (ret) +return ret; ret =__gen_74x164_write_config (chip); -if (ret) { -dev_err (&spi->dev,"Failed writing: %d\n" , ret); - goto exit_destroy; - } +if (ret) +return dev_err_probe (&spi->dev, ret,"Config write failed\n" );gpiod_set_value_cansleep (chip->gpiod_oe,1 ); - ret =gpiochip_add_data (&chip->gpio_chip, chip); -if (!ret) -return 0 ; - -exit_destroy: -mutex_destroy (&chip->lock); - -return ret; +return devm_gpiochip_add_data (&spi->dev, &chip->gpio_chip, chip); }static void gen_74x164_remove (struct spi_device *spi)
@@ -168,8 +161,6 @@ static void gen_74x164_remove(struct spi_device *spi)struct gen_74x164_chip *chip =spi_get_drvdata (spi);gpiod_set_value_cansleep (chip->gpiod_oe,0 ); -gpiochip_remove (&chip->gpio_chip); -mutex_destroy (&chip->lock); }static const struct spi_device_id gen_74x164_spi_ids[] = {
Signature · 1 line
2.43.0
Quoted 6 lines · Bartosz Golaszewski
From: Bartosz Golaszewski <[email protected]>
Use managed helpers to drop the goto label from
probe()and shrink theremove()callback.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 helpers to drop the goto label from
probe()and shrink theremove()callback.
Applied, thanks!
[1/1] gpio: 74x164: shrink code
commit: dacd8ed24c01e26c9b1f76189222cac8982fb75f
Best regards,
Signature · 1 line
Bartosz Golaszewski <[email protected]>