linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Michael Walle <michael@walle.cc>
Cc: linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>,
	Mark Brown <broonie@kernel.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: Re: [PATCH v4 2/2] gpio: add a reusable generic gpio_chip using regmap
Date: Wed, 27 May 2020 19:31:53 -0500	[thread overview]
Message-ID: <fe44039a-4fa9-dab3-cd14-04967b729158@linux.intel.com> (raw)
In-Reply-To: <6d08ebbfbc9f656cb5650ede988cf36d@walle.cc>

Hi Michael,

>>> +struct gpio_regmap_config {
>>> +    struct device *parent;
>>> +    struct regmap *regmap;
>>> +
>>> +    const char *label;
>>> +    int ngpio;
>>
>> could we add a .names field for the gpio_chip, I found this useful for
>> PCM512x GPIO support, e.g.
> 
> Sure, I have the names in the device tree.
> 
> But I'd prefer that you'd do a patch on top of this (assuming it is
> applied soon), because you can actually test it and there might be
> missing more.

I am happy to report that this gpio-regmap worked like a charm for me, 
after I applied the minor diff below (complete code at 
https://github.com/plbossart/sound/tree/fix/regmap-gpios).

I worked around my previous comments by forcing the GPIO internal 
routing directly in regmap, and that allowed me to only play with the 
_set and _dir bases. I see the LEDs and clock selected as before, quite 
nice indeed.

The chip->label test is probably wrong, since the gpio_chip structure is 
zeroed out if(!chip->label) is always true so the label is always set to 
the device name. I don't know what the intent was so just removed that 
test - maybe the correct test should be if (!config->label) ?

I added the names support as well, and btw I don't understand how one 
would get them through device tree?

I still have a series of odd warnings I didn't have before:

[  101.400263] WARNING: CPU: 3 PID: 1129 at drivers/gpio/gpiolib.c:4084 
gpiod_set_value+0x3f/0x50

This seems to come from
	/* Should be using gpiod_set_value_cansleep() */
	WARN_ON(desc->gdev->chip->can_sleep);

so maybe we need an option here as well? Or use a different function?

Anyways, that gpio-regmap does simplify my code a great deal so thanks 
for this work, much appreciated.
-Pierre

diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c
index 3cb0e8493835..678d644a0a4b 100644
--- a/drivers/gpio/gpio-regmap.c
+++ b/drivers/gpio/gpio-regmap.c
@@ -251,10 +251,8 @@ struct gpio_regmap *gpio_regmap_register(const 
struct gpio_regmap_config *config
         chip->ngpio = config->ngpio;
         chip->can_sleep = true;

-       if (!chip->label)
-               chip->label = dev_name(config->parent);
-       else
-               chip->label = config->label;
+       chip->label = config->label;
+       chip->names = config->names;

         chip->get = gpio_regmap_get;
         if (gpio->reg_set_base && gpio->reg_clr_base)
diff --git a/include/linux/gpio-regmap.h b/include/linux/gpio-regmap.h
index bbdb2d79ef8f..c1f3e36ebf33 100644
--- a/include/linux/gpio-regmap.h
+++ b/include/linux/gpio-regmap.h
@@ -16,6 +16,7 @@ struct gpio_regmap;
   *                     given, the name of the device is used
   * @label:             (Optional) Descriptive name for GPIO controller.
   *                     If not given, the name of the device is used.
+ * @names:             (Optional) Array of names for gpios
   * @ngpio:             Number of GPIOs
   * @reg_dat_base:      (Optional) (in) register base address
   * @reg_set_base:      (Optional) set register base address
@@ -43,6 +44,7 @@ struct gpio_regmap_config {
         struct regmap *regmap;

         const char *label;
+       const char *const *names;
         int ngpio;

         unsigned int reg_dat_base;

  reply	other threads:[~2020-05-28  0:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25 16:07 [PATCH v4 0/2] gpio: generic regmap implementation Michael Walle
2020-05-25 16:07 ` [PATCH v4 1/2] gpiolib: Introduce gpiochip_irqchip_add_domain() Michael Walle
2020-05-25 16:07 ` [PATCH v4 2/2] gpio: add a reusable generic gpio_chip using regmap Michael Walle
     [not found]   ` <d245b4f5-065f-4c82-ef8e-d906b363fdcf@linux.intel.com>
2020-05-26 21:27     ` Michael Walle
2020-05-28  0:31       ` Pierre-Louis Bossart [this message]
2020-05-28  4:07         ` Michael Walle
2020-05-28  8:37           ` Andy Shevchenko
2020-05-28  8:46             ` Michael Walle
2020-05-28 10:08               ` Andy Shevchenko
2020-05-27 13:20 ` [PATCH v4 0/2] gpio: generic regmap implementation Bartosz Golaszewski

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=fe44039a-4fa9-dab3-cd14-04967b729158@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=broonie@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael@walle.cc \
    /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).