diff mbox series

[dt-schema] schemas: gpio: gpio-consumer: Fix false positives on nodes named gpio

Message ID 20231023144134.1881973-1-geert+renesas@glider.be (mailing list archive)
State Awaiting Upstream
Delegated to: Geert Uytterhoeven
Headers show
Series [dt-schema] schemas: gpio: gpio-consumer: Fix false positives on nodes named gpio | expand

Commit Message

Geert Uytterhoeven Oct. 23, 2023, 2:41 p.m. UTC
Just like for "gpio", nodes can be named "gpios" or
"<something>-gpio(s)", causing false positive failures.

See also commit 80120fccde170902 ("schemas: gpio: fix false positive
failures on nodes named 'gpio'").

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Seen on Linux, e.g.:

    arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: /: keyboard-gpio: {'compatible': ['gpio-keys-polled'], 'poll-interval': [[50]], 'pinctrl-0': [[29]], 'pinctrl-names': ['default'], 'key-3': {'gpios': [[28, 19, 1]], 'linux,code': [[4]], 'label': ['SW1-3'], 'debounce-interval': [[20]]}, 'key-4': {'gpios': [[28, 20, 1]], 'linux,code': [[5]], 'label': ['SW1-4'], 'debounce-interval': [[20]]}} is not of type 'array'
	    from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
    arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: pinctrl@fffc0000: keyboard-gpio: {'pins': ['GP_0_19', 'GP_0_20'], 'bias-pull-up': True, 'phandle': [[29]]} is not of type 'array'
	    from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#

    arch/arm/boot/dts/microchip/at91-kizbox3-hs.dtb: /: gpios: {'compatible': ['gpio'], 'status': ['okay'], 'rf_on': {'label': ['rf on'], 'gpio': [[38, 83, 0]], 'output': True, 'init-low': True}, 'wifi_on': {'label': ['wifi on'], 'gpio': [[38, 84, 0]], 'output': True, 'init-low': True}, 'zbe_test_radio': {'label': ['zbe test radio'], 'gpio': [[38, 53, 0]], 'output': True, 'init-low': True}, 'zbe_rst': {'label': ['zbe rst'], 'gpio': [[38, 57, 0]], 'output': True, 'init-low': True}, 'io_reset': {'label': ['io reset'], 'gpio': [[38, 62, 0]], 'output': True, 'init-low': True}, 'io_test_radio': {'label': ['io test radio'], 'gpio': [[38, 73, 0]], 'output': True, 'init-low': True}, 'io_boot_0': {'label': ['io boot 0'], 'gpio': [[38, 75, 0]], 'output': True, 'init-low': True}, 'io_boot_1': {'label': ['io boot 1'], 'gpio': [[38, 81, 0]], 'output': True, 'init-low': True}, 'verbose_bootloader': {'label': ['verbose bootloader'], 'gpio': [[38, 43, 0]], 'input': True}, 'nail_bed_detection': {'label': ['nail bed detection'], 'gpio': [[38, 44, 0]], 'input': True}, 'id_usba': {'label': ['id usba'], 'gpio': [[38, 64, 1]], 'input': True}} is not of type 'array'
	    from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#

For marzen, the alternative fix would be to
s/keyboard-gpio/keyboard-polled/g.
---
 dtschema/schemas/gpio/gpio-consumer.yaml | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Krzysztof Kozlowski Oct. 23, 2023, 3:24 p.m. UTC | #1
On 23/10/2023 16:41, Geert Uytterhoeven wrote:
> Just like for "gpio", nodes can be named "gpios" or
> "<something>-gpio(s)", causing false positive failures.
> 
> See also commit 80120fccde170902 ("schemas: gpio: fix false positive
> failures on nodes named 'gpio'").
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Seen on Linux, e.g.:
> 
>     arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: /: keyboard-gpio: {'compatible': ['gpio-keys-polled'], 'poll-interval': [[50]], 'pinctrl-0': [[29]], 'pinctrl-names': ['default'], 'key-3': {'gpios': [[28, 19, 1]], 'linux,code': [[4]], 'label': ['SW1-3'], 'debounce-interval': [[20]]}, 'key-4': {'gpios': [[28, 20, 1]], 'linux,code': [[5]], 'label': ['SW1-4'], 'debounce-interval': [[20]]}} is not of type 'array'
> 	    from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
>     arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: pinctrl@fffc0000: keyboard-gpio: {'pins': ['GP_0_19', 'GP_0_20'], 'bias-pull-up': True, 'phandle': [[29]]} is not of type 'array'
> 	    from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#

keyboard-gpio is not commonly used names. Most (almost all) boards just
call it "gpio-keys".

> 
>     arch/arm/boot/dts/microchip/at91-kizbox3-hs.dtb: /: gpios: {'compatible': ['gpio'], 'status': ['okay'], 'rf_on': {'label': ['rf on'], 'gpio': [[38, 83, 0]], 'output': True, 'init-low': True}, 'wifi_on': {'label': ['wifi on'], 'gpio': [[38, 84, 0]], 'output': True, 'init-low': True}, 'zbe_test_radio': {'label': ['zbe test radio'], 'gpio': [[38, 53, 0]], 'output': True, 'init-low': True}, 'zbe_rst': {'label': ['zbe rst'], 'gpio': [[38, 57, 0]], 'output': True, 'init-low': True}, 'io_reset': {'label': ['io reset'], 'gpio': [[38, 62, 0]], 'output': True, 'init-low': True}, 'io_test_radio': {'label': ['io test radio'], 'gpio': [[38, 73, 0]], 'output': True, 'init-low': True}, 'io_boot_0': {'label': ['io boot 0'], 'gpio': [[38, 75, 0]], 'output': True, 'init-low': True}, 'io_boot_1': {'label': ['io boot 1'], 'gpio': [[38, 81, 0]], 'output': True, 'init-low': True}, 'verbose_bootloader': {'label': ['verbose bootloader'], 'gpio': [[38, 43, 0]], 'input': True}, 'nail_bed_detection': {'label': ['nail bed detection'], 'gpio': [[38, 44, 0]], 'input': True}, 'id_usba': {'label': ['id usba'], 'gpio': [[38, 64, 1]], 'input': True}} is not of type 'array'
> 	    from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#

compatible = "gpio"? Is there such binding?

I think we should not allow "gpios" as a node, at least above examples
do not justify it.

> 
> For marzen, the alternative fix would be to
> s/keyboard-gpio/keyboard-polled/g.
> ---



Best regards,
Krzysztof
Geert Uytterhoeven Oct. 23, 2023, 6:08 p.m. UTC | #2
Hi Krzysztof,

On Mon, Oct 23, 2023 at 5:24 PM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:
> On 23/10/2023 16:41, Geert Uytterhoeven wrote:
> > Just like for "gpio", nodes can be named "gpios" or
> > "<something>-gpio(s)", causing false positive failures.
> >
> > See also commit 80120fccde170902 ("schemas: gpio: fix false positive
> > failures on nodes named 'gpio'").
> >
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > ---
> > Seen on Linux, e.g.:
> >
> >     arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: /: keyboard-gpio: {'compatible': ['gpio-keys-polled'], 'poll-interval': [[50]], 'pinctrl-0': [[29]], 'pinctrl-names': ['default'], 'key-3': {'gpios': [[28, 19, 1]], 'linux,code': [[4]], 'label': ['SW1-3'], 'debounce-interval': [[20]]}, 'key-4': {'gpios': [[28, 20, 1]], 'linux,code': [[5]], 'label': ['SW1-4'], 'debounce-interval': [[20]]}} is not of type 'array'
> >           from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
> >     arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: pinctrl@fffc0000: keyboard-gpio: {'pins': ['GP_0_19', 'GP_0_20'], 'bias-pull-up': True, 'phandle': [[29]]} is not of type 'array'
> >           from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
>
> keyboard-gpio is not commonly used names. Most (almost all) boards just
> call it "gpio-keys".

Most call it "keyboard".

Marzen has 4 keys split in two keyboards due to hardware limitations,
hence I had called them "keyboard-irq" (using falling edge interrupts,
i.e. no real key-up events)  and "keyboard-gpio" (gpio polling
without interrupts).

> >     arch/arm/boot/dts/microchip/at91-kizbox3-hs.dtb: /: gpios: {'compatible': ['gpio'], 'status': ['okay'], 'rf_on': {'label': ['rf on'], 'gpio': [[38, 83, 0]], 'output': True, 'init-low': True}, 'wifi_on': {'label': ['wifi on'], 'gpio': [[38, 84, 0]], 'output': True, 'init-low': True}, 'zbe_test_radio': {'label': ['zbe test radio'], 'gpio': [[38, 53, 0]], 'output': True, 'init-low': True}, 'zbe_rst': {'label': ['zbe rst'], 'gpio': [[38, 57, 0]], 'output': True, 'init-low': True}, 'io_reset': {'label': ['io reset'], 'gpio': [[38, 62, 0]], 'output': True, 'init-low': True}, 'io_test_radio': {'label': ['io test radio'], 'gpio': [[38, 73, 0]], 'output': True, 'init-low': True}, 'io_boot_0': {'label': ['io boot 0'], 'gpio': [[38, 75, 0]], 'output': True, 'init-low': True}, 'io_boot_1': {'label': ['io boot 1'], 'gpio': [[38, 81, 0]], 'output': True, 'init-low': True}, 'verbose_bootloader': {'label': ['verbose bootloader'], 'gpio': [[38, 43, 0]], 'input': True}, 'nail_bed_detection': {'label': ['nail bed detection'], 'gpio': [[38, 44, 0]], 'input': True}, 'id_usba': {'label': ['id usba'], 'gpio': [[38, 64, 1]], 'input': True}} is not of type 'array'
> >           from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
>
> compatible = "gpio"? Is there such binding?
>
> I think we should not allow "gpios" as a node, at least above examples
> do not justify it.

Note that there are more.  I used grep, and picked just one to see if I could
fix that one too while at it:

$ git grep "\<gpios\s*{"
arch/arm/boot/dts/marvell/kirkwood-db.dtsi:
pmx_sdio_gpios: pmx-sdio-gpios {
arch/arm/boot/dts/marvell/orion5x-netgear-wnr854t.dts:  pmx_pci_gpios:
pmx-pci-gpios {
arch/arm/boot/dts/marvell/orion5x-rd88f5182-nas.dts:
pmx_misc_gpios: pmx-misc-gpios {
arch/arm/boot/dts/marvell/orion5x-rd88f5182-nas.dts:    pmx_pci_gpios:
pmx-pci-gpios {
arch/arm/boot/dts/microchip/at91-kizbox3-hs.dts:        gpios {
arch/arm/boot/dts/qcom/qcom-apq8064-pins.dtsi:  sdc4_gpios: sdc4-gpios {
arch/arm/boot/dts/st/ste-hrefv60plus.dtsi:                      gpios {
arch/mips/boot/dts/ingenic/qi_lb60.dts:         mmc-gpios {

Or:

$ git grep -e "-gpio\s*{" | wc -l
64

> > For marzen, the alternative fix would be to
> > s/keyboard-gpio/keyboard-polled/g.

Do you prefer the alternative?

Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Krzysztof Kozlowski Oct. 24, 2023, 7:33 a.m. UTC | #3
On 23/10/2023 20:08, Geert Uytterhoeven wrote:
> Hi Krzysztof,
> 
> On Mon, Oct 23, 2023 at 5:24 PM Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org> wrote:
>> On 23/10/2023 16:41, Geert Uytterhoeven wrote:
>>> Just like for "gpio", nodes can be named "gpios" or
>>> "<something>-gpio(s)", causing false positive failures.
>>>
>>> See also commit 80120fccde170902 ("schemas: gpio: fix false positive
>>> failures on nodes named 'gpio'").
>>>
>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>>> ---
>>> Seen on Linux, e.g.:
>>>
>>>     arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: /: keyboard-gpio: {'compatible': ['gpio-keys-polled'], 'poll-interval': [[50]], 'pinctrl-0': [[29]], 'pinctrl-names': ['default'], 'key-3': {'gpios': [[28, 19, 1]], 'linux,code': [[4]], 'label': ['SW1-3'], 'debounce-interval': [[20]]}, 'key-4': {'gpios': [[28, 20, 1]], 'linux,code': [[5]], 'label': ['SW1-4'], 'debounce-interval': [[20]]}} is not of type 'array'
>>>           from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
>>>     arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: pinctrl@fffc0000: keyboard-gpio: {'pins': ['GP_0_19', 'GP_0_20'], 'bias-pull-up': True, 'phandle': [[29]]} is not of type 'array'
>>>           from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
>>
>> keyboard-gpio is not commonly used names. Most (almost all) boards just
>> call it "gpio-keys".
> 
> Most call it "keyboard".

Most? My grep counted only 14.

520 for gpio-keys (not counting -polled)

But sure, can be keyboard.

> 
> Marzen has 4 keys split in two keyboards due to hardware limitations,
> hence I had called them "keyboard-irq" (using falling edge interrupts,
> i.e. no real key-up events)  and "keyboard-gpio" (gpio polling
> without interrupts).
keyboard-0
keyboard-1

> 
>>>     arch/arm/boot/dts/microchip/at91-kizbox3-hs.dtb: /: gpios: {'compatible': ['gpio'], 'status': ['okay'], 'rf_on': {'label': ['rf on'], 'gpio': [[38, 83, 0]], 'output': True, 'init-low': True}, 'wifi_on': {'label': ['wifi on'], 'gpio': [[38, 84, 0]], 'output': True, 'init-low': True}, 'zbe_test_radio': {'label': ['zbe test radio'], 'gpio': [[38, 53, 0]], 'output': True, 'init-low': True}, 'zbe_rst': {'label': ['zbe rst'], 'gpio': [[38, 57, 0]], 'output': True, 'init-low': True}, 'io_reset': {'label': ['io reset'], 'gpio': [[38, 62, 0]], 'output': True, 'init-low': True}, 'io_test_radio': {'label': ['io test radio'], 'gpio': [[38, 73, 0]], 'output': True, 'init-low': True}, 'io_boot_0': {'label': ['io boot 0'], 'gpio': [[38, 75, 0]], 'output': True, 'init-low': True}, 'io_boot_1': {'label': ['io boot 1'], 'gpio': [[38, 81, 0]], 'output': True, 'init-low': True}, 'verbose_bootloader': {'label': ['verbose bootloader'], 'gpio': [[38, 43, 0]], 'input': True}, 'nail_bed_detection': {'label': ['nail bed detection'], 'gpio': [[38, 44, 0]], 'input': True}, 'id_usba': {'label': ['id usba'], 'gpio': [[38, 64, 1]], 'input': True}} is not of type 'array'
>>>           from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
>>
>> compatible = "gpio"? Is there such binding?
>>
>> I think we should not allow "gpios" as a node, at least above examples
>> do not justify it.
> 
> Note that there are more.  I used grep, and picked just one to see if I could
> fix that one too while at it:
> 
> $ git grep "\<gpios\s*{"
> arch/arm/boot/dts/marvell/kirkwood-db.dtsi:
> pmx_sdio_gpios: pmx-sdio-gpios {
> arch/arm/boot/dts/marvell/orion5x-netgear-wnr854t.dts:  pmx_pci_gpios:
> pmx-pci-gpios {
> arch/arm/boot/dts/marvell/orion5x-rd88f5182-nas.dts:
> pmx_misc_gpios: pmx-misc-gpios {
> arch/arm/boot/dts/marvell/orion5x-rd88f5182-nas.dts:    pmx_pci_gpios:
> pmx-pci-gpios {
> arch/arm/boot/dts/microchip/at91-kizbox3-hs.dts:        gpios {
> arch/arm/boot/dts/qcom/qcom-apq8064-pins.dtsi:  sdc4_gpios: sdc4-gpios {
> arch/arm/boot/dts/st/ste-hrefv60plus.dtsi:                      gpios {
> arch/mips/boot/dts/ingenic/qi_lb60.dts:         mmc-gpios {

These look like pins so they would have their own schema, most likely
not "gpios" but "pins" or something similar.

> 
> Or:
> 
> $ git grep -e "-gpio\s*{" | wc -l
> 64

For example Xilinx ones are pincfg, so they should have some name with
known pattern (e.g. mentioned "pins").

> 
>>> For marzen, the alternative fix would be to
>>> s/keyboard-gpio/keyboard-polled/g.
> 
> Do you prefer the alternative?

I would propose to change the names in the DTS. For pin configuration
nodes this however might require first having DT schema for them.

Best regards,
Krzysztof
Geert Uytterhoeven Oct. 24, 2023, 7:39 a.m. UTC | #4
Hi Krzysztof,

On Tue, Oct 24, 2023 at 9:33 AM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:
> On 23/10/2023 20:08, Geert Uytterhoeven wrote:
> > On Mon, Oct 23, 2023 at 5:24 PM Krzysztof Kozlowski
> > <krzysztof.kozlowski@linaro.org> wrote:
> >> On 23/10/2023 16:41, Geert Uytterhoeven wrote:
> >>> Just like for "gpio", nodes can be named "gpios" or
> >>> "<something>-gpio(s)", causing false positive failures.
> >>>
> >>> See also commit 80120fccde170902 ("schemas: gpio: fix false positive
> >>> failures on nodes named 'gpio'").
> >>>
> >>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >>> ---
> >>> Seen on Linux, e.g.:
> >>>
> >>>     arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: /: keyboard-gpio: {'compatible': ['gpio-keys-polled'], 'poll-interval': [[50]], 'pinctrl-0': [[29]], 'pinctrl-names': ['default'], 'key-3': {'gpios': [[28, 19, 1]], 'linux,code': [[4]], 'label': ['SW1-3'], 'debounce-interval': [[20]]}, 'key-4': {'gpios': [[28, 20, 1]], 'linux,code': [[5]], 'label': ['SW1-4'], 'debounce-interval': [[20]]}} is not of type 'array'
> >>>           from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
> >>>     arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: pinctrl@fffc0000: keyboard-gpio: {'pins': ['GP_0_19', 'GP_0_20'], 'bias-pull-up': True, 'phandle': [[29]]} is not of type 'array'
> >>>           from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
> >>
> >> keyboard-gpio is not commonly used names. Most (almost all) boards just
> >> call it "gpio-keys".
> >
> > Most call it "keyboard".
>
> Most? My grep counted only 14.
>
> 520 for gpio-keys (not counting -polled)
>
> But sure, can be keyboard.

Sorry, I meant Section 2.2.2 "Generic Names Recommendation" in
the Devicetree Specification ;-)

> > Marzen has 4 keys split in two keyboards due to hardware limitations,
> > hence I had called them "keyboard-irq" (using falling edge interrupts,
> > i.e. no real key-up events)  and "keyboard-gpio" (gpio polling
> > without interrupts).
> keyboard-0
> keyboard-1

OK, will do.

Gr{oetje,eeting}s,

                        Geert
Krzysztof Kozlowski Oct. 24, 2023, 9:15 a.m. UTC | #5
On 24/10/2023 09:39, Geert Uytterhoeven wrote:
> Hi Krzysztof,
> 
> On Tue, Oct 24, 2023 at 9:33 AM Krzysztof Kozlowski
> <krzysztof.kozlowski@linaro.org> wrote:
>> On 23/10/2023 20:08, Geert Uytterhoeven wrote:
>>> On Mon, Oct 23, 2023 at 5:24 PM Krzysztof Kozlowski
>>> <krzysztof.kozlowski@linaro.org> wrote:
>>>> On 23/10/2023 16:41, Geert Uytterhoeven wrote:
>>>>> Just like for "gpio", nodes can be named "gpios" or
>>>>> "<something>-gpio(s)", causing false positive failures.
>>>>>
>>>>> See also commit 80120fccde170902 ("schemas: gpio: fix false positive
>>>>> failures on nodes named 'gpio'").
>>>>>
>>>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>>>>> ---
>>>>> Seen on Linux, e.g.:
>>>>>
>>>>>     arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: /: keyboard-gpio: {'compatible': ['gpio-keys-polled'], 'poll-interval': [[50]], 'pinctrl-0': [[29]], 'pinctrl-names': ['default'], 'key-3': {'gpios': [[28, 19, 1]], 'linux,code': [[4]], 'label': ['SW1-3'], 'debounce-interval': [[20]]}, 'key-4': {'gpios': [[28, 20, 1]], 'linux,code': [[5]], 'label': ['SW1-4'], 'debounce-interval': [[20]]}} is not of type 'array'
>>>>>           from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
>>>>>     arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: pinctrl@fffc0000: keyboard-gpio: {'pins': ['GP_0_19', 'GP_0_20'], 'bias-pull-up': True, 'phandle': [[29]]} is not of type 'array'
>>>>>           from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
>>>>
>>>> keyboard-gpio is not commonly used names. Most (almost all) boards just
>>>> call it "gpio-keys".
>>>
>>> Most call it "keyboard".
>>
>> Most? My grep counted only 14.
>>
>> 520 for gpio-keys (not counting -polled)
>>
>> But sure, can be keyboard.
> 
> Sorry, I meant Section 2.2.2 "Generic Names Recommendation" in
> the Devicetree Specification ;-)

Yes, that's right. Keyboard is generic thus indeed seems more suitable,
because "gpio-keys" already includes specific part - GPIO. OTOH, we tend
to think about keyboard as something with keys for the full alphabet,
like PC 10x keyboard. How to call a node in an embedded board or phone
with 4 buttons or 4 keys in total?

> 
>>> Marzen has 4 keys split in two keyboards due to hardware limitations,
>>> hence I had called them "keyboard-irq" (using falling edge interrupts,
>>> i.e. no real key-up events)  and "keyboard-gpio" (gpio polling
>>> without interrupts).
>> keyboard-0
>> keyboard-1
Best regards,
Krzysztof
Geert Uytterhoeven Oct. 24, 2023, 9:20 a.m. UTC | #6
Hi Krzysztof,

On Tue, Oct 24, 2023 at 11:15 AM Krzysztof Kozlowski
<krzysztof.kozlowski@linaro.org> wrote:
> On 24/10/2023 09:39, Geert Uytterhoeven wrote:
> > On Tue, Oct 24, 2023 at 9:33 AM Krzysztof Kozlowski
> > <krzysztof.kozlowski@linaro.org> wrote:
> >> On 23/10/2023 20:08, Geert Uytterhoeven wrote:
> >>> On Mon, Oct 23, 2023 at 5:24 PM Krzysztof Kozlowski
> >>> <krzysztof.kozlowski@linaro.org> wrote:
> >>>> On 23/10/2023 16:41, Geert Uytterhoeven wrote:
> >>>>> Just like for "gpio", nodes can be named "gpios" or
> >>>>> "<something>-gpio(s)", causing false positive failures.
> >>>>>
> >>>>> See also commit 80120fccde170902 ("schemas: gpio: fix false positive
> >>>>> failures on nodes named 'gpio'").
> >>>>>
> >>>>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >>>>> ---
> >>>>> Seen on Linux, e.g.:
> >>>>>
> >>>>>     arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: /: keyboard-gpio: {'compatible': ['gpio-keys-polled'], 'poll-interval': [[50]], 'pinctrl-0': [[29]], 'pinctrl-names': ['default'], 'key-3': {'gpios': [[28, 19, 1]], 'linux,code': [[4]], 'label': ['SW1-3'], 'debounce-interval': [[20]]}, 'key-4': {'gpios': [[28, 20, 1]], 'linux,code': [[5]], 'label': ['SW1-4'], 'debounce-interval': [[20]]}} is not of type 'array'
> >>>>>           from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
> >>>>>     arch/arm/boot/dts/renesas/r8a7779-marzen.dtb: pinctrl@fffc0000: keyboard-gpio: {'pins': ['GP_0_19', 'GP_0_20'], 'bias-pull-up': True, 'phandle': [[29]]} is not of type 'array'
> >>>>>           from schema $id: http://devicetree.org/schemas/gpio/gpio-consumer.yaml#
> >>>>
> >>>> keyboard-gpio is not commonly used names. Most (almost all) boards just
> >>>> call it "gpio-keys".
> >>>
> >>> Most call it "keyboard".
> >>
> >> Most? My grep counted only 14.
> >>
> >> 520 for gpio-keys (not counting -polled)
> >>
> >> But sure, can be keyboard.
> >
> > Sorry, I meant Section 2.2.2 "Generic Names Recommendation" in
> > the Devicetree Specification ;-)
>
> Yes, that's right. Keyboard is generic thus indeed seems more suitable,
> because "gpio-keys" already includes specific part - GPIO. OTOH, we tend
> to think about keyboard as something with keys for the full alphabet,
> like PC 10x keyboard. How to call a node in an embedded board or phone
> with 4 buttons or 4 keys in total?

On hackaday.com, they would call that a keypad.

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/dtschema/schemas/gpio/gpio-consumer.yaml b/dtschema/schemas/gpio/gpio-consumer.yaml
index 1ac35244de7317bc..9572a9cd0febef19 100644
--- a/dtschema/schemas/gpio/gpio-consumer.yaml
+++ b/dtschema/schemas/gpio/gpio-consumer.yaml
@@ -17,7 +17,10 @@  select:
 
 properties:
   gpios:
-    $ref: /schemas/types.yaml#/definitions/phandle-array
+    # 'gpios' can appear as a property or node name
+    oneOf:
+      - type: object
+      - $ref: /schemas/types.yaml#/definitions/phandle-array
 
   gpio:
     # 'gpio' can appear as a property or node name
@@ -28,6 +31,9 @@  properties:
 
 patternProperties:
   "(?<!,nr)-gpios?$":
-    $ref: /schemas/types.yaml#/definitions/phandle-array
+    # these can appear as properties or node names
+    oneOf:
+      - type: object
+      - $ref: /schemas/types.yaml#/definitions/phandle-array
 
 additionalProperties: true