From: Linus Walleij <linus.walleij@linaro.org>
To: Peter Rosin <peda@axentia.se>
Cc: Alexandre Courbot <gnurou@gmail.com>,
Wolfram Sang <wsa-dev@sang-engineering.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Peter Korsgaard <peter.korsgaard@barco.com>,
Wolfram Sang <wsa@the-dreams.de>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>
Subject: Re: Getting at gpio- and pinctrl-devices as a consumer
Date: Fri, 25 Nov 2016 00:29:40 +0100 [thread overview]
Message-ID: <CACRpkdb0cdvxgnuOBNfdY+idVcTXMwzKRYfCsFpiRx2qaVrt=w@mail.gmail.com> (raw)
In-Reply-To: <b481ed92-c9d2-b4da-b484-6d8bec6038f0@axentia.se>
On Thu, Nov 24, 2016 at 10:35 PM, Peter Rosin <peda@axentia.se> wrote:
> The background is that the gpio- and pinctrl-based i2c-mux drivers
> need to know if the device that is used to control the mux of the
> i2c-bus is also sitting on that very same i2c-bus. If it is, the
> locking has to be different and a bit more relaxed. This relaxed
> mode cannot be used always, as that would change the mux behavior
> in an unacceptable way for stuff expecting the (traditional)
> stricter locking. See Documentation/i2c/i2c-topology for more
> details if you need it.
>
> To check this, the i2c mux drivers dig out the device connected to
> each gpio-pin (or pinctrl-state) and walks up the device tree to see
> if the root i2c adapter that is muxed is in the loop.
>
> When I wrote this code, I could not find a clean way to go from a
> struct gpio_desc * to the relevant device, short of doing
>
> #include "../../gpio/gpiolib.h"
>
> gpio_dev = &gpio_desc->gdev->dev;
>
> And similarly for pinctrl:
>
> #include "../../pinctrl/core.h"
>
> struct pinctrl_setting *setting;
> pinctrl_dev = setting->pctldev->dev;
>
> I'm not very proud of that, and wonder if there is a better way
> to get at the needed struct device? If not, then perhaps there
> should be?
Surely if I can be convinced that we need helpers for this
in GPIO and/or pin control we can add them.
They just need to be named something reasonable and
be generally useful for other situations of similar nature.
struct device *gpiod_get_backing_device(struct gpio_desc *d);
Is simple but is it really what you want?
Yours,
Linus Walleij
next prev parent reply other threads:[~2016-11-24 23:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1479908035-18284-1-git-send-email-peda@axentia.se>
[not found] ` <20161124151420.GF4271@katana>
[not found] ` <46be889f-a558-0174-f638-c685b23c8ed9@axentia.se>
[not found] ` <20161124195230.GA1666@katana>
2016-11-24 21:35 ` Getting at gpio- and pinctrl-devices as a consumer Peter Rosin
2016-11-24 23:29 ` Linus Walleij [this message]
2016-11-25 9:24 ` Peter Rosin
2016-11-25 13:39 ` Linus Walleij
2016-11-25 16:19 ` Peter Rosin
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='CACRpkdb0cdvxgnuOBNfdY+idVcTXMwzKRYfCsFpiRx2qaVrt=w@mail.gmail.com' \
--to=linus.walleij@linaro.org \
--cc=gnurou@gmail.com \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--cc=peter.korsgaard@barco.com \
--cc=wsa-dev@sang-engineering.com \
--cc=wsa@the-dreams.de \
/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).