Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1566683
| From | Bartosz Golaszewski <bgolaszewski@baylibre.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 6/7] gpio: mockup: implement naming the GPIO lines |
| Date | 2017-01-25 16:40 +0100 |
| Message-ID | <t3xPY-3w9-19@gated-at.bofh.it> (permalink) |
| References | <t3xPX-3w9-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Implement a new boolean module argument that indicates that the mockup
lines should be named. The names are created by appending the line
offset to the chip label.
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
drivers/gpio/gpio-mockup.c | 30 +++++++++++++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c
index c5eb530..dabf3ec 100644
--- a/drivers/gpio/gpio-mockup.c
+++ b/drivers/gpio/gpio-mockup.c
@@ -17,6 +17,7 @@
#include <linux/platform_device.h>
#include <linux/debugfs.h>
#include <linux/uaccess.h>
+#include <linux/slab.h>
#include "gpiolib.h"
@@ -48,6 +49,10 @@ static int gpio_mockup_ranges[MAX_GC << 1];
static int gpio_mockup_params_nr;
module_param_array(gpio_mockup_ranges, int, &gpio_mockup_params_nr, 0400);
+static bool gpio_mockup_named_lines;
+module_param_named(gpio_mockup_named_lines,
+ gpio_mockup_named_lines, bool, 0400);
+
static const char pins_name_start = 'A';
static struct dentry *dbg_dir;
@@ -169,7 +174,8 @@ static int mockup_gpio_add(struct device *dev,
struct mockup_gpio_controller *cntr,
const char *name, int base, int ngpio)
{
- int ret;
+ char **names;
+ int ret, i;
cntr->gc.base = base;
cntr->gc.ngpio = ngpio;
@@ -188,6 +194,28 @@ static int mockup_gpio_add(struct device *dev,
ret = -ENOMEM;
goto err;
}
+
+ if (gpio_mockup_named_lines) {
+ names = devm_kzalloc(dev,
+ sizeof(char *) * cntr->gc.ngpio,
+ GFP_KERNEL);
+ if (!names) {
+ ret = -ENOMEM;
+ goto err;
+ }
+
+ for (i = 0; i < cntr->gc.ngpio; i++) {
+ names[i] = devm_kasprintf(dev, GFP_KERNEL,
+ "%s-%d", cntr->gc.label, i);
+ if (!names[i]) {
+ ret = -ENOMEM;
+ goto err;
+ }
+ }
+
+ cntr->gc.names = (const char *const*)names;
+ }
+
ret = devm_gpiochip_add_data(dev, &cntr->gc, cntr);
if (ret)
goto err;
--
2.9.3
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH 6/7] gpio: mockup: implement naming the GPIO lines Bartosz Golaszewski <bgolaszewski@baylibre.com> - 2017-01-25 16:40 +0100
csiph-web