mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Michael Walle <michael@walle.cc>
To: "Vaittinen, Matti" <Matti.Vaittinen@fi.rohmeurope.com>
Cc: linux-power <linux-power@fi.rohmeurope.com>,
	linux-gpio@vger.kernel.org, bgolaszewski@baylibre.com,
	linux-kernel@vger.kernel.org, linus.walleij@linaro.org
Subject: Re: [PATCH 1/2] gpio: regmap: Support few IC specific operations
Date: Fri, 21 May 2021 09:10:57 +0200	[thread overview]
Message-ID: <75c35a7d5561ec3b206351849e2b89f2@walle.cc> (raw)
In-Reply-To: <7a76b454ddb4b143021dfea504608d9db67f33af.camel@fi.rohmeurope.com>

Am 2021-05-20 14:42, schrieb Vaittinen, Matti:
> On Thu, 2021-05-20 at 14:22 +0200, Michael Walle wrote:
>> Am 2021-05-20 14:00, schrieb Matti Vaittinen:
>> > On Thu, 2021-05-20 at 13:42 +0200, Michael Walle wrote:
>> > > Am 2021-05-20 13:28, schrieb Matti Vaittinen:
>> > > > The set_config and init_valid_mask GPIO operations are usually
>> > > > very
>> > > > IC
>> > > > specific. Allow IC drivers to provide these custom operations
>> > > > at
>> > > > gpio-regmap registration.
>> > > >
>> > > > Signed-off-by: Matti Vaittinen <
>> > > > matti.vaittinen@fi.rohmeurope.com>
>> > > > ---
>> > > >  drivers/gpio/gpio-regmap.c  | 49
>> > > > +++++++++++++++++++++++++++++++++++++
>> > > >  include/linux/gpio/regmap.h | 13 ++++++++++
>> > > >  2 files changed, 62 insertions(+)
>> > > >
>> > > > diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-
>> > > > regmap.c
>> > > > index 134cedf151a7..315285cacd3f 100644
>> > > > --- a/drivers/gpio/gpio-regmap.c
>> > > > +++ b/drivers/gpio/gpio-regmap.c
>> > > > @@ -27,6 +27,10 @@ struct gpio_regmap {
>> > > >  	int (*reg_mask_xlate)(struct gpio_regmap *gpio,
>> > > > unsigned int
>> > > > base,
>> > > >  			      unsigned int offset, unsigned int
>> > > > *reg,
>> > > >  			      unsigned int *mask);
>> > > > +	int (*set_config)(struct regmap *regmap, void *drvdata,
>> > > > +			  unsigned int offset, unsigned long
>> > > > config);
>> > > > +	int (*init_valid_mask)(struct regmap *regmap, void
>> > > > *drvdata,
>> > > > +				unsigned long *valid_mask,
>> > > > unsigned int
>> > > > ngpios);
>> > >
>> > > Maybe we should also make the first argument a "struct
>> > > gpio_regmap"
>> > > and provide a new gpio_regmap_get_regmap(struct gpio_regmap).
>> > > Thus
>> > > having a similar api as for the reg_mask_xlate(). Andy?
>> >
>> > I don't really see the reason of making this any more complicated
>> > for
>> > IC drivers. If we don't open the struct gpio_regmap to IC drivers -
>> > then they never need the struct gpio_regmap pointer itself but each
>> > IC
>> > driver would need to do some unnecessary function call
>> > (gpio_regmap_get_regmap() in this case). I'd say that would be
>> > unnecessary bloat.
>> 
>> If there is ever the need of additional parameters, you'll have to
>> modify that parameter list. Otherwise you'll just have to add a new
>> function. Thus might be more future proof.
> 
> I do hope the "void *drvdata" allows enough flexibility so that there
> is no need to add new parameters.

Thats for information passed from the user of gpio_regmap to the
callbacks.

> And if there is, then I don't see how
> the struct gpio_regmap pointer would have saved us - unless we open the
> contents of struct gpio_regmap to IC drivers. (Which might make sense
> because that already contains plenty of register details which may need
> to be duplicated to drvdata for some IC-specific callbacks. Here we
> again have analogy to regulator_desc - which I have often used also in
> IC-specific custom callbacks. But as long as we hope to keep the struct
> gpio_regmap private I would not add it in arguments).

Because that (opaque) argument is then used for the helper functions
of gpio_regmap.

-michael

      reply	other threads:[~2021-05-21  7:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 11:28 Matti Vaittinen
2021-05-20 11:29 ` [PATCH 2/2] gpio: bd71815: Use gpio-regmap Matti Vaittinen
2021-05-25 15:51   ` Linus Walleij
2021-05-26  5:40     ` Vaittinen, Matti
2021-05-20 11:39 ` [PATCH 1/2] gpio: regmap: Support few IC specific operations Vaittinen, Matti
2021-05-20 11:42 ` Michael Walle
2021-05-20 12:00   ` Matti Vaittinen
2021-05-20 12:22     ` Michael Walle
2021-05-20 12:42       ` Vaittinen, Matti
2021-05-21  7:10         ` Michael Walle [this message]

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=75c35a7d5561ec3b206351849e2b89f2@walle.cc \
    --to=michael@walle.cc \
    --cc=Matti.Vaittinen@fi.rohmeurope.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-power@fi.rohmeurope.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

all inboxes | Powered by JetHome®