Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1574614 > unrolled thread

[PATCH v2 0/7] gpio: mockup: extensions for testing purposes

Started byBartosz Golaszewski <bgolaszewski@baylibre.com>
First post2017-02-06 13:20 +0100
Last post2017-02-06 14:30 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2 0/7] gpio: mockup: extensions for testing purposes Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-02-06 13:20 +0100
    [PATCH v2 2/7] gpio: mockup: code shrink Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-02-06 13:20 +0100
      Re: [PATCH v2 2/7] gpio: mockup: code shrink Linus Walleij <linus.walleij@linaro.org> - 2017-02-06 14:30 +0100

#1574614 — [PATCH v2 0/7] gpio: mockup: extensions for testing purposes

FromBartosz Golaszewski <bgolaszewski@baylibre.com>
Date2017-02-06 13:20 +0100
Subject[PATCH v2 0/7] gpio: mockup: extensions for testing purposes
Message-ID<t7QqZ-4PJ-9@gated-at.bofh.it>
I would like to create an automated test-suite for libgpiod, but
the gpio-mockup driver is quite limited when it comes to current
user space functionality - I can't test neither line event
notifications nor finding GPIO lines by name.

This series proposes to extend the gpio framework by allowing to
inject line events from the kernel code and by providing a debugfs
interface for that to the gpio-mockup driver. We also allow the
user to request that the mockup driver name the lines.

The first two patches only contain coding style changes which, I
believe, will make the driver easier to maintain.

The third patch adds the option to have the lines named.

The fourth patch adds a devres flavor of irq_alloc_descs() to be used
in patch 5, which actually adds the dummy irqchip.

The last two patches implement the debugfs directory structure that
can be used by the user space to inject line events.

v1 -> v2:
- made the event injection self-contained within the driver by using
  the irq_work as suggested by Lars-Peter Clauses

Bartosz Golaszewski (7):
  gpio: mockup: readability tweaks
  gpio: mockup: code shrink
  gpio: mockup: implement naming the lines
  irqdesc: add memory managed version of irq_alloc_descs()
  gpio: mockup: add a dummy irqchip
  gpiolib: include <gpio/consumer.h> from gpiolib.h
  gpio: mockup: implement event injecting over debugfs

 drivers/gpio/Kconfig       |   1 +
 drivers/gpio/gpio-mockup.c | 349 ++++++++++++++++++++++++++++++++++++---------
 drivers/gpio/gpiolib.h     |   1 +
 include/linux/irq.h        |  19 +++
 kernel/irq/devres.c        |  38 +++++
 5 files changed, 338 insertions(+), 70 deletions(-)

-- 
2.9.3

[toc] | [next] | [standalone]


#1574616 — [PATCH v2 2/7] gpio: mockup: code shrink

FromBartosz Golaszewski <bgolaszewski@baylibre.com>
Date2017-02-06 13:20 +0100
Subject[PATCH v2 2/7] gpio: mockup: code shrink
Message-ID<t7Qr1-4PJ-51@gated-at.bofh.it>
In reply to#1574614
Moving a couple of lines around allows us to shrink the code a bit
while keeping the same functionality.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 drivers/gpio/gpio-mockup.c | 29 ++++++++---------------------
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index 5f6ed4b..d425601 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -92,7 +92,6 @@ static int gpio_mockup_add(struct device *dev,
 			   const char *name, int base, int ngpio)
 {
 	struct gpio_chip *gc = &chip->gc;
-	int ret;
 
 	gc->base = base;
 	gc->ngpio = ngpio;
@@ -107,21 +106,10 @@ static int gpio_mockup_add(struct device *dev,
 
 	chip->lines = devm_kzalloc(dev, sizeof(*chip->lines) * gc->ngpio,
 				   GFP_KERNEL);
-	if (!chip->lines) {
-		ret = -ENOMEM;
-		goto err;
-	}
-
-	ret = devm_gpiochip_add_data(dev, &chip->gc, chip);
-	if (ret)
-		goto err;
-
-	dev_info(dev, "gpio<%d..%d> add successful!", base, base + ngpio);
-	return 0;
+	if (!chip->lines)
+		return -ENOMEM;
 
-err:
-	dev_err(dev, "gpio<%d..%d> add failed!", base, base + ngpio);
-	return ret;
+	return devm_gpiochip_add_data(dev, &chip->gc, chip);
 }
 
 static int gpio_mockup_probe(struct platform_device *pdev)
@@ -164,15 +152,14 @@ static int gpio_mockup_probe(struct platform_device *pdev)
 		}
 
 		if (ret) {
-			if (base < 0)
-				dev_err(dev, "gpio<%d..%d> add failed\n",
-					base, ngpio);
-			else
-				dev_err(dev, "gpio<%d..%d> add failed\n",
-					base, base + ngpio);
+			dev_err(dev, "gpio<%d..%d> add failed\n",
+				base, base < 0 ? ngpio : base + ngpio);
 
 			return ret;
 		}
+
+		dev_info(dev, "gpio<%d..%d> add successful!",
+			 base, base + ngpio);
 	}
 
 	return 0;
-- 
2.9.3

[toc] | [prev] | [next] | [standalone]


#1574676 — Re: [PATCH v2 2/7] gpio: mockup: code shrink

FromLinus Walleij <linus.walleij@linaro.org>
Date2017-02-06 14:30 +0100
SubjectRe: [PATCH v2 2/7] gpio: mockup: code shrink
Message-ID<t7RwJ-5sW-11@gated-at.bofh.it>
In reply to#1574616
On Mon, Feb 6, 2017 at 1:10 PM, Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:

> Moving a couple of lines around allows us to shrink the code a bit
> while keeping the same functionality.
>
> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>

Patch applied.

Yours,
Linus Walleij

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web