From: "Marek Behún" <kabel@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Marek Behún" <kabel@kernel.org>,
"Gregory CLEMENT" <gregory.clement@bootlin.com>,
"Arnd Bergmann" <arnd@arndb.de>,
soc@kernel.org, arm@kernel.org,
"Hans de Goede" <hdegoede@redhat.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Bartosz Golaszewski" <brgl@bgdev.pl>,
linux-gpio@vger.kernel.org
Subject: Re: [PATCH v8 3/9] platform: cznic: turris-omnia-mcu: Add support for MCU connected GPIOs
Date: Tue, 7 May 2024 19:44:41 +0200 [thread overview]
Message-ID: <20240507174441.uualqqy65es55gzf@kandell> (raw)
In-Reply-To: <CAHp75VcDi5hbG3wzygBJ=iGteVrzJp08sKD0cJyS1vvkx8fo6Q@mail.gmail.com>
On Sun, May 05, 2024 at 04:34:28PM +0300, Andy Shevchenko wrote:
> On Sun, May 5, 2024 at 11:18 AM Marek Behún <kabel@kernel.org> wrote:
> > On Fri, May 03, 2024 at 09:51:17PM +0300, Andy Shevchenko wrote:
> > > On Fri, May 03, 2024 at 10:28:17AM +0200, Marek Behún wrote:
> > > > On Fri, May 03, 2024 at 07:05:34AM +0300, Andy Shevchenko wrote:
> > > > > On Tue, Apr 30, 2024 at 2:51 PM Marek Behún <kabel@kernel.org> wrote:
>
> ...
>
> > > > > > +static const char * const omnia_mcu_gpio_templates[64] = {
> > > > > > + /* GPIOs with value read from the 16-bit wide status */
> > > > > > + [4] = "gpio%u.MiniPCIe0 Card Detect",
> > > > > > + [5] = "gpio%u.MiniPCIe0 mSATA Indicator",
> > > > > > + [6] = "gpio%u.Front USB3 port over-current",
> > > > > > + [7] = "gpio%u.Rear USB3 port over-current",
> > > > > > + [8] = "gpio%u.Front USB3 port power",
> > > > > > + [9] = "gpio%u.Rear USB3 port power",
> > > > > > + [12] = "gpio%u.Front Button",
> > > > > > +
> > > > > > + /* GPIOs with value read from the 32-bit wide extended status */
> > > > > > + [16] = "gpio%u.SFP nDET",
> > > > > > + [28] = "gpio%u.MiniPCIe0 LED",
> > > > > > + [29] = "gpio%u.MiniPCIe1 LED",
> > > > > > + [30] = "gpio%u.MiniPCIe2 LED",
> > > > > > + [31] = "gpio%u.MiniPCIe0 PAN LED",
> > > > > > + [32] = "gpio%u.MiniPCIe1 PAN LED",
> > > > > > + [33] = "gpio%u.MiniPCIe2 PAN LED",
> > > > > > + [34] = "gpio%u.WAN PHY LED0",
> > > > > > + [35] = "gpio%u.WAN PHY LED1",
> > > > > > + [36] = "gpio%u.LAN switch p0 LED0",
> > > > > > + [37] = "gpio%u.LAN switch p0 LED1",
> > > > > > + [38] = "gpio%u.LAN switch p1 LED0",
> > > > > > + [39] = "gpio%u.LAN switch p1 LED1",
> > > > > > + [40] = "gpio%u.LAN switch p2 LED0",
> > > > > > + [41] = "gpio%u.LAN switch p2 LED1",
> > > > > > + [42] = "gpio%u.LAN switch p3 LED0",
> > > > > > + [43] = "gpio%u.LAN switch p3 LED1",
> > > > > > + [44] = "gpio%u.LAN switch p4 LED0",
> > > > > > + [45] = "gpio%u.LAN switch p4 LED1",
> > > > > > + [46] = "gpio%u.LAN switch p5 LED0",
> > > > > > + [47] = "gpio%u.LAN switch p5 LED1",
> > > > > > +
> > > > > > + /* GPIOs with value read from the 16-bit wide extended control status */
> > > > > > + [48] = "gpio%u.eMMC nRESET",
> > > > > > + [49] = "gpio%u.LAN switch nRESET",
> > > > > > + [50] = "gpio%u.WAN PHY nRESET",
> > > > > > + [51] = "gpio%u.MiniPCIe0 nPERST",
> > > > > > + [52] = "gpio%u.MiniPCIe1 nPERST",
> > > > > > + [53] = "gpio%u.MiniPCIe2 nPERST",
> > > > > > + [54] = "gpio%u.WAN PHY SFP mux",
> > > > > > +};
> > > > >
> > > > > You may reduce the memory footprint of these just by doing "gpio%u."
> > > > > part(s) outside. Here compiler won't compress this (as in the case of
> > > > > repetitive string literals),
> > > >
> > > > Are you saying that I should dynamically create another array just to
> > > > pass it to the gpiochip's names pointer?
> > >
> > > I have looked into this again and now I'm puzzled how you tested this.
> > > To me it seems that those gpio%u will go as a fixed string to the user space,
> > > there is no %u --> number substitution happens. Moreover, this data anyway
> > > is redundant. Userspace and debugfs all have line numbers being printed.
> > >
> >
> > It gets substituted in drivers/gpio/gpiolib-sysfs.c, function
> > gpiod_export():
> >
> > dev = device_create_with_groups(&gpio_class, &gdev->dev,
> > MKDEV(0, 0), data, gpio_groups,
> > ioname ? ioname : "gpio%u",
> > desc_to_gpio(desc));
> >
> > The ioname variable contains the string.
> >
> > This is then visible in sysfs:
> >
> > $ cd /sys/class/gpio
> > $ echo 560 >export
> > $ ls
> > ...
> > gpio560.eMMC nRESET
> > ...
>
> Interesting. But before giving my conclusion on this, what is the
> output of /sys/kernel/debug/gpio and `gpioinfo` (the latter from
> libgpiod)?
It prints %u, as you suspected and I see you already posted patch to
avoid this. I'm dropping the "gpio%u." prefixes from GPIO line names.
Marek
next prev parent reply other threads:[~2024-05-07 17:44 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-30 11:51 [PATCH v8 0/9] Turris Omnia MCU driver Marek Behún
2024-04-30 11:51 ` [PATCH v8 1/9] dt-bindings: firmware: add cznic,turris-omnia-mcu binding Marek Behún
2024-04-30 11:51 ` [PATCH v8 2/9] platform: cznic: Add preliminary support for Turris Omnia MCU Marek Behún
2024-04-30 12:53 ` Andy Shevchenko
2024-04-30 14:05 ` Marek Behún
2024-04-30 15:10 ` Dan Carpenter
2024-04-30 15:17 ` Andy Shevchenko
2024-05-02 18:40 ` Marek Behún
2024-05-02 18:47 ` Andy Shevchenko
2024-05-02 19:17 ` Marek Behún
2024-05-03 3:59 ` Andy Shevchenko
2024-05-03 6:51 ` Marek Behún
2024-04-30 15:31 ` Ilpo Järvinen
2024-05-02 19:19 ` Marek Behún
2024-04-30 11:51 ` [PATCH v8 3/9] platform: cznic: turris-omnia-mcu: Add support for MCU connected GPIOs Marek Behún
2024-05-03 4:05 ` Andy Shevchenko
2024-05-03 8:28 ` Marek Behún
2024-05-03 18:51 ` Andy Shevchenko
2024-05-05 8:18 ` Marek Behún
2024-05-05 13:34 ` Andy Shevchenko
2024-05-07 17:44 ` Marek Behún [this message]
2024-05-03 8:43 ` Marek Behún
2024-05-03 17:33 ` Andy Shevchenko
2024-05-05 8:12 ` Marek Behún
2024-04-30 11:51 ` [PATCH v8 4/9] platform: cznic: turris-omnia-mcu: Add support for poweroff and wakeup Marek Behún
2024-04-30 11:51 ` [PATCH v8 5/9] platform: cznic: turris-omnia-mcu: Add support for MCU watchdog Marek Behún
2024-04-30 11:51 ` [PATCH v8 6/9] platform: cznic: turris-omnia-mcu: Add support for MCU provided TRNG Marek Behún
2024-04-30 11:51 ` [PATCH v8 7/9] platform: cznic: turris-omnia-mcu: Add support for digital message signing via debugfs Marek Behún
2024-04-30 11:51 ` [PATCH v8 8/9] ARM: dts: turris-omnia: Add MCU system-controller node Marek Behún
2024-04-30 11:51 ` [PATCH v8 9/9] ARM: dts: turris-omnia: Add GPIO key node for front button Marek Behún
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=20240507174441.uualqqy65es55gzf@kandell \
--to=kabel@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=arm@kernel.org \
--cc=arnd@arndb.de \
--cc=brgl@bgdev.pl \
--cc=gregory.clement@bootlin.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=soc@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 read-only IMAP folder(s) and NNTP newsgroup(s).