linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Peter Rosin <peda@axentia.se>
Cc: Sebastian Reichel <sre@kernel.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: [PATCH v2 3/3] power: supply: bq24735-charger: allow chargers to share the ac-detect gpio
Date: Mon, 9 Jan 2017 19:55:48 +0100	[thread overview]
Message-ID: <CACRpkdbyzLwsK6bosbCZAniPNTU9PMp_8Wi7J0sQCjsh8RLPcw@mail.gmail.com> (raw)
In-Reply-To: <c3d66181-3076-0d0f-d74e-ec0205b3f547@axentia.se>

On Mon, Jan 2, 2017 at 9:31 AM, Peter Rosin <peda@axentia.se> wrote:
> On 2016-12-30 08:49, Linus Walleij wrote:
>> On Wed, Dec 14, 2016 at 6:41 PM, Peter Rosin <peda@axentia.se> wrote:
>>> On 2016-12-14 18:01, Sebastian Reichel wrote:
>>>> [of course I forgot to actually add gpio people, let's try again]
>>>>
>>>> On Wed, Dec 14, 2016 at 05:59:21PM +0100, Sebastian Reichel wrote:
>>>>> Hi,
>>>>>
>>>>> On Wed, Dec 14, 2016 at 12:56:45AM +0100, Peter Rosin wrote:
>>>>>> If several parallel bq24735 chargers have their ac-detect gpios wired
>>>>>> together (or if only one of the parallel bq24735 chargers have its
>>>>>> ac-detect pin wired to a gpio, and the others are assumed to react the
>>>>>> same), then all driver instances need to check the same gpio. But the
>>>>>> gpio subsystem does not allow sharing gpios, so handle that locally.
>>>>>
>>>>> Adding GPIO subsystem people to see if they can come up with
>>>>> something in the gpiod API for this usecase.
>>>
>>> Right, I don't like how my new code steps away from gpio descriptors.
>>
>> The issue of shared gpiods have come up over and over again.
>> For example the messy regulator code needs this too.
>>
>> It is better if we implement something like gpiod_get_shared()
>> in the gpiolib of these cases.
>>
>> Just put a refcount in struct gpio_desc in drivers/gpio/gpiolib.h
>> for this case I guess?
>
> I actually tried that, but ran into atomicy issues with the
> FLAG_REQUESTED bit and gave up. Didn't really try all that hard
> though, but I simply didn't feel comfortable with going near such
> fundamental designs...

Oh I see. Well if it is of any help that would make me nervous too.

I would just remove the use of FLAG_REQUESTED altogether,
redefine the flags in gpiolib.h from 0 and add a struct kref into the struct
to deal with the refcounting.

That should do it. I think.

Yours,
Linus Walleij

      reply	other threads:[~2017-01-09 18:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1481673405-4547-1-git-send-email-peda@axentia.se>
     [not found] ` <1481673405-4547-4-git-send-email-peda@axentia.se>
     [not found]   ` <20161214165921.jsatcznbljd7anqi@earth>
2016-12-14 17:01     ` [PATCH v2 3/3] power: supply: bq24735-charger: allow chargers to share the ac-detect gpio Sebastian Reichel
2016-12-14 17:41       ` Peter Rosin
2016-12-30  7:49         ` Linus Walleij
2017-01-02  8:31           ` Peter Rosin
2017-01-09 18:55             ` Linus Walleij [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=CACRpkdbyzLwsK6bosbCZAniPNTU9PMp_8Wi7J0sQCjsh8RLPcw@mail.gmail.com \
    --to=linus.walleij@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=gnurou@gmail.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=peda@axentia.se \
    --cc=sre@kernel.org \
    /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).