From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
Linus Walleij <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Cc: Bartosz Golaszewski <brgl@bgdev.pl>, Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v1 5/7] gpio: 74x164: Fully convert to use managed resources
Date: Mon, 3 Feb 2025 14:17:21 +0200 [thread overview]
Message-ID: <20250203121843.3183991-6-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20250203121843.3183991-1-andriy.shevchenko@linux.intel.com>
Convert the driver probe stage to use managed resources.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/gpio/gpio-74x164.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-74x164.c b/drivers/gpio/gpio-74x164.c
index 0f720d539fa7..920d3b9c1087 100644
--- a/drivers/gpio/gpio-74x164.c
+++ b/drivers/gpio/gpio-74x164.c
@@ -95,6 +95,19 @@ static int gen_74x164_direction_output(struct gpio_chip *gc,
return 0;
}
+static void gen_74x164_deactivate(void *data)
+{
+ struct gen_74x164_chip *chip = data;
+
+ gpiod_set_value_cansleep(chip->gpiod_oe, 0);
+}
+
+static int gen_74x164_activate(struct device *dev, struct gen_74x164_chip *chip)
+{
+ gpiod_set_value_cansleep(chip->gpiod_oe, 1);
+ return devm_add_action_or_reset(dev, gen_74x164_deactivate, chip);
+}
+
static int gen_74x164_probe(struct spi_device *spi)
{
struct device *dev = &spi->dev;
@@ -128,8 +141,6 @@ static int gen_74x164_probe(struct spi_device *spi)
if (IS_ERR(chip->gpiod_oe))
return PTR_ERR(chip->gpiod_oe);
- spi_set_drvdata(spi, chip);
-
chip->gpio_chip.label = spi->modalias;
chip->gpio_chip.direction_output = gen_74x164_direction_output;
chip->gpio_chip.get = gen_74x164_get_value;
@@ -149,7 +160,9 @@ static int gen_74x164_probe(struct spi_device *spi)
if (ret)
return dev_err_probe(&spi->dev, ret, "Config write failed\n");
- gpiod_set_value_cansleep(chip->gpiod_oe, 1);
+ ret = gen_74x164_activate(dev, chip);
+ if (ret)
+ return ret;
return devm_gpiochip_add_data(&spi->dev, &chip->gpio_chip, chip);
}
@@ -181,7 +194,6 @@ static struct spi_driver gen_74x164_driver = {
.of_match_table = gen_74x164_dt_ids,
},
.probe = gen_74x164_probe,
- .remove = gen_74x164_remove,
.id_table = gen_74x164_spi_ids,
};
module_spi_driver(gen_74x164_driver);
--
2.43.0.rc1.1336.g36b5255a03ac
next prev parent reply other threads:[~2025-02-03 12:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-03 12:17 [PATCH v1 0/7] gpio: 74x164: Refactor and clean up the driver Andy Shevchenko
2025-02-03 12:17 ` [PATCH v1 1/7] gpio: 74x164: Remove unneeded dependency to OF_GPIO Andy Shevchenko
2025-02-07 8:01 ` Bartosz Golaszewski
2025-02-07 8:56 ` Geert Uytterhoeven
2025-02-03 12:17 ` [PATCH v1 2/7] gpio: 74x164: Simplify code with cleanup helpers Andy Shevchenko
2025-02-10 9:12 ` Linus Walleij
2025-02-03 12:17 ` [PATCH v1 3/7] gpio: 74x164: Annotate buffer with __counted_by() Andy Shevchenko
2025-02-04 1:28 ` Gustavo A. R. Silva
2025-02-03 12:17 ` [PATCH v1 4/7] gpio: 74x164: Make use of the macros from bits.h Andy Shevchenko
2025-02-10 9:12 ` Linus Walleij
2025-02-10 9:16 ` Andy Shevchenko
2025-02-03 12:17 ` Andy Shevchenko [this message]
2025-02-07 8:22 ` [PATCH v1 5/7] gpio: 74x164: Fully convert to use managed resources Bartosz Golaszewski
2025-02-03 12:17 ` [PATCH v1 6/7] gpio: 74x164: Switch to use dev_err_probe() Andy Shevchenko
2025-02-11 9:15 ` Linus Walleij
2025-02-03 12:17 ` [PATCH v1 7/7] gpio: 74x164: Utilise temporary variable for struct device Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250203121843.3183991-6-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=gustavoars@kernel.org \
--cc=kees@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).