From: Mauri Sandberg <maukka@ext.kapsi.fi>
To: sandberg@mailfence.com
Cc: andy.shevchenko@gmail.com, bgolaszewski@baylibre.com,
geert+renesas@glider.be, linus.walleij@linaro.org,
linux-gpio@vger.kernel.org, robh+dt@kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
drew@beagleboard.org, Mauri Sandberg <maukka@ext.kapsi.fi>
Subject: [PATCH v7 0/2] gpio: gpio-cascade: add generic GPIO cascade
Date: Tue, 19 Oct 2021 23:08:29 +0300 [thread overview]
Message-ID: <20211019200831.3817-1-maukka@ext.kapsi.fi> (raw)
In-Reply-To: <20210325122832.119147-1-sandberg@mailfence.com>
Thanks for you prompt feedback Andy. Here are the highlights on this round:
- no changes in the bindings file.
- added better help text in Kconfig
- refactored the return code handling for claiming upstream gpio line
- refactored the return and exit at the end of the function
Thanks,
Mauri
rangediff v6 -> v7:
1: 1283751fadd4 = 1: 434637e7188e dt-bindings: gpio-cascade: add documentation
2: 46541776733a ! 2: a72e186f8e3b gpio: gpio-cascade: add generic GPIO cascade
@@ Commit message
Signed-off-by: Mauri Sandberg <maukka@ext.kapsi.fi>
---
+ v6 -> v7:
+ - In Kconfig add info about module name
+ - adhere to new convention that allows lines longer than 80 chars
+ - use dev_probe_err with upstream gpio line too
+ - refactor for cleaner exit of probe function.
v5 -> v6:
- In Kconfig, remove dependency to OF_GPIO and select only MULTIPLEXER
- refactor code preferring one-liners
@@ drivers/gpio/Kconfig: config GPIO_VIRTIO
+ This allows building one-to-many cascades of GPIO lines using
+ different types of multiplexers readily available. At the
+ moment only input lines are supported.
++
++ To build the driver as a module choose 'm' and the resulting module
++ will be called 'gpio-cascade'.
+
endif
@@ drivers/gpio/gpio-cascade.c (new)
+ */
+
+#include <linux/module.h>
-+#include <linux/gpio/consumer.h>
-+#include <linux/gpio/driver.h>
+#include <linux/slab.h>
+#include <linux/platform_device.h>
+#include <linux/mux/consumer.h>
+
++#include <linux/gpio/consumer.h>
++#include <linux/gpio/driver.h>
++
+struct gpio_cascade {
+ struct device *parent;
+ struct gpio_chip gpio_chip;
@@ drivers/gpio/gpio-cascade.c (new)
+ struct mux_control *mc;
+ struct gpio_desc *upstream;
+ struct gpio_chip *gc;
-+ int err;
+
+ cas = devm_kzalloc(dev, sizeof(*cas), GFP_KERNEL);
+ if (!cas)
@@ drivers/gpio/gpio-cascade.c (new)
+
+ mc = devm_mux_control_get(dev, NULL);
+ if (IS_ERR(mc))
-+ return dev_err_probe(dev,
-+ PTR_ERR(mc),
-+ "unable to get mux-control\n");
++ return dev_err_probe(dev, PTR_ERR(mc), "unable to get mux-control\n");
+
+ cas->mux_control = mc;
+ upstream = devm_gpiod_get(dev, "upstream", GPIOD_IN);
-+ if (IS_ERR(upstream)) {
-+ dev_err(dev, "unable to claim upstream GPIO line\n");
-+ return -ENODEV;
-+ }
++ if (IS_ERR(upstream))
++ return dev_err_probe(dev, PTR_ERR(upstream), "unable to claim upstream GPIO line\n");
+
+ cas->upstream_line = upstream;
+ cas->parent = dev;
@@ drivers/gpio/gpio-cascade.c (new)
+ gc = &cas->gpio_chip;
+ gc->get = gpio_cascade_get_value;
+ gc->get_direction = gpio_cascade_get_direction;
-+
+ gc->base = -1;
+ gc->ngpio = mux_control_states(mc);
+ gc->label = dev_name(cas->parent);
+ gc->parent = cas->parent;
+ gc->owner = THIS_MODULE;
+
-+ err = devm_gpiochip_add_data(dev, &cas->gpio_chip, NULL);
-+ if (err) {
-+ dev_err(dev, "unable to add gpio chip\n");
-+ return err;
-+ }
-+
+ platform_set_drvdata(pdev, cas);
-+ return 0;
++ return devm_gpiochip_add_data(dev, &cas->gpio_chip, NULL);
+}
+
+static const struct of_device_id gpio_cascade_id[] = {
Mauri Sandberg (2):
dt-bindings: gpio-cascade: add documentation
gpio: gpio-cascade: add generic GPIO cascade
.../bindings/gpio/gpio-cascade.yaml | 103 +++++++++++++++
drivers/gpio/Kconfig | 15 +++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-cascade.c | 118 ++++++++++++++++++
4 files changed, 237 insertions(+)
create mode 100644 Documentation/devicetree/bindings/gpio/gpio-cascade.yaml
create mode 100644 drivers/gpio/gpio-cascade.c
base-commit: f4a20dfac88c06c9b529a41ff4cf9acba8f3fdff
--
2.25.1
next prev parent reply other threads:[~2021-10-19 20:09 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210325122832.119147-1-sandberg@mailfence.com>
2021-05-30 16:13 ` [PATCH v4 0/2] gpio: add generic gpio input multiplexer Mauri Sandberg
2021-05-30 16:13 ` [PATCH v4 1/2] dt-bindings: gpio-mux-input: add documentation Mauri Sandberg
2021-06-01 10:10 ` Linus Walleij
2021-06-01 10:44 ` Linus Walleij
2021-06-02 9:31 ` Mauri Sandberg
2021-06-02 10:35 ` Linus Walleij
2021-06-02 11:21 ` Mauri Sandberg
2021-06-04 7:51 ` Linus Walleij
2021-06-01 13:32 ` Rob Herring
2021-06-02 11:36 ` Mauri Sandberg
2021-05-30 16:13 ` [PATCH v4 2/2] gpio: gpio-mux-input: add generic gpio input multiplexer Mauri Sandberg
2021-05-30 18:09 ` Andy Shevchenko
2021-05-30 19:02 ` Mauri Sandberg
2021-05-30 19:38 ` Andy Shevchenko
2021-05-31 10:19 ` Mauri Sandberg
2021-06-01 10:38 ` Linus Walleij
2021-06-21 17:20 ` [PATCH v5 0/2] gpio: add generic gpio cascade Mauri Sandberg
2021-06-21 17:20 ` [PATCH v5 1/2] dt-bindings: gpio-cascade: add documentation Mauri Sandberg
2021-06-24 18:30 ` Rob Herring
2021-06-21 17:20 ` [PATCH v5 2/2] gpio: gpio-cascade: add generic GPIO cascade Mauri Sandberg
2021-06-21 17:43 ` Andy Shevchenko
2021-06-21 18:31 ` Enrico Weigelt, metux IT consult
2021-10-15 12:56 ` Mauri Sandberg
2021-10-15 17:20 ` Andy Shevchenko
2021-10-19 12:57 ` [PATCH v6 0/2] " Mauri Sandberg
2021-10-19 12:57 ` [PATCH v6 1/2] dt-bindings: gpio-cascade: add documentation Mauri Sandberg
2021-10-19 12:57 ` [PATCH v6 2/2] gpio: gpio-cascade: add generic GPIO cascade Mauri Sandberg
2021-10-19 13:12 ` Andy Shevchenko
2021-10-19 20:08 ` Mauri Sandberg [this message]
2021-10-19 20:08 ` [PATCH v7 1/2] dt-bindings: gpio-cascade: add documentation Mauri Sandberg
2021-10-24 22:18 ` Linus Walleij
2021-10-19 20:08 ` [PATCH v7 2/2] gpio: gpio-cascade: add generic GPIO cascade Mauri Sandberg
2021-10-24 22:17 ` Linus Walleij
2021-10-25 9:29 ` Andy Shevchenko
2021-10-26 19:15 ` [PATCH v8 0/2] " Mauri Sandberg
2021-10-26 19:15 ` [PATCH v8 1/2] dt-bindings: gpio-cascade: add documentation Mauri Sandberg
2021-10-26 19:15 ` [PATCH v8 2/2] gpio: gpio-cascade: add generic GPIO cascade Mauri Sandberg
2022-02-05 21:59 ` [RESEND v8 0/2] " Mauri Sandberg
2022-02-05 21:59 ` [RESEND v8 1/2] dt-bindings: gpio-cascade: add documentation Mauri Sandberg
2022-02-05 21:59 ` [RESEND v8 2/2] gpio: gpio-cascade: add generic GPIO cascade Mauri Sandberg
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=20211019200831.3817-1-maukka@ext.kapsi.fi \
--to=maukka@ext.kapsi.fi \
--cc=andy.shevchenko@gmail.com \
--cc=bgolaszewski@baylibre.com \
--cc=devicetree@vger.kernel.org \
--cc=drew@beagleboard.org \
--cc=geert+renesas@glider.be \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh+dt@kernel.org \
--cc=sandberg@mailfence.com \
/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).