diff mbox series

[v2,1/2] dt-bindings: pwm: Allow decimal format in addition to hex format

Message ID 20221121115525.36362-1-tony@atomide.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/2] dt-bindings: pwm: Allow decimal format in addition to hex format | expand

Commit Message

Tony Lindgren Nov. 21, 2022, 11:55 a.m. UTC
Let's allow node numbering in decimal format too.

Simple human-readable increments/IDs are usually decimal, hex is only for
addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.

Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 Documentation/devicetree/bindings/pwm/pwm.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Krzysztof Kozlowski Nov. 21, 2022, 12:20 p.m. UTC | #1
On 21/11/2022 12:55, Tony Lindgren wrote:
> Let's allow node numbering in decimal format too.
> 
> Simple human-readable increments/IDs are usually decimal, hex is only for
> addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.
> 
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>


Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof
Uwe Kleine-König Nov. 21, 2022, 2:40 p.m. UTC | #2
On Mon, Nov 21, 2022 at 01:55:24PM +0200, Tony Lindgren wrote:
> Let's allow node numbering in decimal format too.
> 
> Simple human-readable increments/IDs are usually decimal, hex is only for
> addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.
> 
> Cc: Thierry Reding <thierry.reding@gmail.com>
> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
>  Documentation/devicetree/bindings/pwm/pwm.yaml | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/pwm/pwm.yaml b/Documentation/devicetree/bindings/pwm/pwm.yaml
> --- a/Documentation/devicetree/bindings/pwm/pwm.yaml
> +++ b/Documentation/devicetree/bindings/pwm/pwm.yaml
> @@ -13,7 +13,7 @@ select: false
>  
>  properties:
>    $nodename:
> -    pattern: "^pwm(@.*|-[0-9a-f])*$"
> +    pattern: "^pwm(@.*|-([0-9a-f]|1[0-5]))*$"

I wonder why you don't make this:

+    pattern: "^pwm(@.*|-[0-9a-f]*)$"

Is there a use case to match

	pwm-1-2-3-4-5

?

Best regards
Uwe
Tony Lindgren Nov. 21, 2022, 2:48 p.m. UTC | #3
* Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221121 14:30]:
> On Mon, Nov 21, 2022 at 01:55:24PM +0200, Tony Lindgren wrote:
> > Let's allow node numbering in decimal format too.
> > 
> > Simple human-readable increments/IDs are usually decimal, hex is only for
> > addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.
> > 
> > Cc: Thierry Reding <thierry.reding@gmail.com>
> > Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > Signed-off-by: Tony Lindgren <tony@atomide.com>
> > ---
> >  Documentation/devicetree/bindings/pwm/pwm.yaml | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/pwm/pwm.yaml b/Documentation/devicetree/bindings/pwm/pwm.yaml
> > --- a/Documentation/devicetree/bindings/pwm/pwm.yaml
> > +++ b/Documentation/devicetree/bindings/pwm/pwm.yaml
> > @@ -13,7 +13,7 @@ select: false
> >  
> >  properties:
> >    $nodename:
> > -    pattern: "^pwm(@.*|-[0-9a-f])*$"
> > +    pattern: "^pwm(@.*|-([0-9a-f]|1[0-5]))*$"
> 
> I wonder why you don't make this:
> 
> +    pattern: "^pwm(@.*|-[0-9a-f]*)$"

Hmm but I think this would also pass for node names like pwm-a-foo?

I just used the following to look for similar examples FYI:

$ find Documentation/devicetree/bindings/ -name \*.yaml | \
	xargs grep pattern: | grep '1\[0-'

> Is there a use case to match
> 
> 	pwm-1-2-3-4-5

I don't think so.

Regards,

Tony
Krzysztof Kozlowski Nov. 21, 2022, 4:15 p.m. UTC | #4
On 21/11/2022 15:48, Tony Lindgren wrote:
> * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221121 14:30]:
>> On Mon, Nov 21, 2022 at 01:55:24PM +0200, Tony Lindgren wrote:
>>> Let's allow node numbering in decimal format too.
>>>
>>> Simple human-readable increments/IDs are usually decimal, hex is only for
>>> addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.
>>>
>>> Cc: Thierry Reding <thierry.reding@gmail.com>
>>> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>>> Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>>> Signed-off-by: Tony Lindgren <tony@atomide.com>
>>> ---
>>>  Documentation/devicetree/bindings/pwm/pwm.yaml | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/Documentation/devicetree/bindings/pwm/pwm.yaml b/Documentation/devicetree/bindings/pwm/pwm.yaml
>>> --- a/Documentation/devicetree/bindings/pwm/pwm.yaml
>>> +++ b/Documentation/devicetree/bindings/pwm/pwm.yaml
>>> @@ -13,7 +13,7 @@ select: false
>>>  
>>>  properties:
>>>    $nodename:
>>> -    pattern: "^pwm(@.*|-[0-9a-f])*$"
>>> +    pattern: "^pwm(@.*|-([0-9a-f]|1[0-5]))*$"
>>
>> I wonder why you don't make this:
>>
>> +    pattern: "^pwm(@.*|-[0-9a-f]*)$"

Yes, the '*' should be within ().

> 
> Hmm but I think this would also pass for node names like pwm-a-foo?
> 

No, how?


Best regards,
Krzysztof
Tony Lindgren Nov. 22, 2022, 4:43 a.m. UTC | #5
* Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> [221121 16:05]:
> On 21/11/2022 15:48, Tony Lindgren wrote:
> > * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221121 14:30]:
> >> On Mon, Nov 21, 2022 at 01:55:24PM +0200, Tony Lindgren wrote:
> >>> Let's allow node numbering in decimal format too.
> >>>
> >>> Simple human-readable increments/IDs are usually decimal, hex is only for
> >>> addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.
> >>>
> >>> Cc: Thierry Reding <thierry.reding@gmail.com>
> >>> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> >>> Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> >>> Signed-off-by: Tony Lindgren <tony@atomide.com>
> >>> ---
> >>>  Documentation/devicetree/bindings/pwm/pwm.yaml | 2 +-
> >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>
> >>> diff --git a/Documentation/devicetree/bindings/pwm/pwm.yaml b/Documentation/devicetree/bindings/pwm/pwm.yaml
> >>> --- a/Documentation/devicetree/bindings/pwm/pwm.yaml
> >>> +++ b/Documentation/devicetree/bindings/pwm/pwm.yaml
> >>> @@ -13,7 +13,7 @@ select: false
> >>>  
> >>>  properties:
> >>>    $nodename:
> >>> -    pattern: "^pwm(@.*|-[0-9a-f])*$"
> >>> +    pattern: "^pwm(@.*|-([0-9a-f]|1[0-5]))*$"
> >>
> >> I wonder why you don't make this:
> >>
> >> +    pattern: "^pwm(@.*|-[0-9a-f]*)$"
> 
> Yes, the '*' should be within ().

Sorry I guess I don't follow. So for what type of naming is the second '*'
actually needed here, or is it needed at all?

We only want to match the following:

pwm@1234

pwm-0
...
pwm-f

And now also:

pwm-0
...
pwm-15

Is there yet another format I'm missing?

> > Hmm but I think this would also pass for node names like pwm-a-foo?
> > 
> 
> No, how?

Because of the second extra '*' there :)

Regards,

Tony
Krzysztof Kozlowski Nov. 22, 2022, 7:36 a.m. UTC | #6
On 22/11/2022 05:43, Tony Lindgren wrote:
> * Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> [221121 16:05]:
>> On 21/11/2022 15:48, Tony Lindgren wrote:
>>> * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221121 14:30]:
>>>> On Mon, Nov 21, 2022 at 01:55:24PM +0200, Tony Lindgren wrote:
>>>>> Let's allow node numbering in decimal format too.
>>>>>
>>>>> Simple human-readable increments/IDs are usually decimal, hex is only for
>>>>> addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.
>>>>>
>>>>> Cc: Thierry Reding <thierry.reding@gmail.com>
>>>>> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>>>>> Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>>>>> Signed-off-by: Tony Lindgren <tony@atomide.com>
>>>>> ---
>>>>>  Documentation/devicetree/bindings/pwm/pwm.yaml | 2 +-
>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/Documentation/devicetree/bindings/pwm/pwm.yaml b/Documentation/devicetree/bindings/pwm/pwm.yaml
>>>>> --- a/Documentation/devicetree/bindings/pwm/pwm.yaml
>>>>> +++ b/Documentation/devicetree/bindings/pwm/pwm.yaml
>>>>> @@ -13,7 +13,7 @@ select: false
>>>>>  
>>>>>  properties:
>>>>>    $nodename:
>>>>> -    pattern: "^pwm(@.*|-[0-9a-f])*$"
>>>>> +    pattern: "^pwm(@.*|-([0-9a-f]|1[0-5]))*$"
>>>>
>>>> I wonder why you don't make this:
>>>>
>>>> +    pattern: "^pwm(@.*|-[0-9a-f]*)$"
>>
>> Yes, the '*' should be within ().
> 
> Sorry I guess I don't follow. So for what type of naming is the second '*'
> actually needed here, or is it needed at all?
> 
> We only want to match the following:
> 
> pwm@1234
> 
> pwm-0
> ...
> pwm-f
> 
> And now also:
> 
> pwm-0
> ...
> pwm-15
> 
> Is there yet another format I'm missing?
> 
>>> Hmm but I think this would also pass for node names like pwm-a-foo?
>>>
>>
>> No, how?
> 
> Because of the second extra '*' there :)

It cannot multiple dashes...

> 
> Regards,
> 
> Tony

Best regards,
Krzysztof
Tony Lindgren Nov. 22, 2022, 8:11 a.m. UTC | #7
* Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> [221122 07:26]:
> On 22/11/2022 05:43, Tony Lindgren wrote:
> > * Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> [221121 16:05]:
> >> On 21/11/2022 15:48, Tony Lindgren wrote:
> >>> * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221121 14:30]:
> >>>> On Mon, Nov 21, 2022 at 01:55:24PM +0200, Tony Lindgren wrote:
> >>>>> Let's allow node numbering in decimal format too.
> >>>>>
> >>>>> Simple human-readable increments/IDs are usually decimal, hex is only for
> >>>>> addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.
> >>>>>
> >>>>> Cc: Thierry Reding <thierry.reding@gmail.com>
> >>>>> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> >>>>> Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> >>>>> Signed-off-by: Tony Lindgren <tony@atomide.com>
> >>>>> ---
> >>>>>  Documentation/devicetree/bindings/pwm/pwm.yaml | 2 +-
> >>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>>>>
> >>>>> diff --git a/Documentation/devicetree/bindings/pwm/pwm.yaml b/Documentation/devicetree/bindings/pwm/pwm.yaml
> >>>>> --- a/Documentation/devicetree/bindings/pwm/pwm.yaml
> >>>>> +++ b/Documentation/devicetree/bindings/pwm/pwm.yaml
> >>>>> @@ -13,7 +13,7 @@ select: false
> >>>>>  
> >>>>>  properties:
> >>>>>    $nodename:
> >>>>> -    pattern: "^pwm(@.*|-[0-9a-f])*$"
> >>>>> +    pattern: "^pwm(@.*|-([0-9a-f]|1[0-5]))*$"
> >>>>
> >>>> I wonder why you don't make this:
> >>>>
> >>>> +    pattern: "^pwm(@.*|-[0-9a-f]*)$"
> >>
> >> Yes, the '*' should be within ().
> > 
> > Sorry I guess I don't follow. So for what type of naming is the second '*'
> > actually needed here, or is it needed at all?
> > 
> > We only want to match the following:
> > 
> > pwm@1234
> > 
> > pwm-0
> > ...
> > pwm-f
> > 
> > And now also:
> > 
> > pwm-0
> > ...
> > pwm-15
> > 
> > Is there yet another format I'm missing?
> > 
> >>> Hmm but I think this would also pass for node names like pwm-a-foo?
> >>>
> >>
> >> No, how?
> > 
> > Because of the second extra '*' there :)
> 
> It cannot multiple dashes...

Sorry I'm still confused.. Care to specify what match do you want to
use here and why?

Regards,

Tony
Krzysztof Kozlowski Nov. 22, 2022, 8:29 a.m. UTC | #8
On 22/11/2022 09:11, Tony Lindgren wrote:
> * Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> [221122 07:26]:
>> On 22/11/2022 05:43, Tony Lindgren wrote:
>>> * Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> [221121 16:05]:
>>>> On 21/11/2022 15:48, Tony Lindgren wrote:
>>>>> * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221121 14:30]:
>>>>>> On Mon, Nov 21, 2022 at 01:55:24PM +0200, Tony Lindgren wrote:
>>>>>>> Let's allow node numbering in decimal format too.
>>>>>>>
>>>>>>> Simple human-readable increments/IDs are usually decimal, hex is only for
>>>>>>> addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.
>>>>>>>
>>>>>>> Cc: Thierry Reding <thierry.reding@gmail.com>
>>>>>>> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>>>>>>> Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
>>>>>>> Signed-off-by: Tony Lindgren <tony@atomide.com>
>>>>>>> ---
>>>>>>>  Documentation/devicetree/bindings/pwm/pwm.yaml | 2 +-
>>>>>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>>>>>
>>>>>>> diff --git a/Documentation/devicetree/bindings/pwm/pwm.yaml b/Documentation/devicetree/bindings/pwm/pwm.yaml
>>>>>>> --- a/Documentation/devicetree/bindings/pwm/pwm.yaml
>>>>>>> +++ b/Documentation/devicetree/bindings/pwm/pwm.yaml
>>>>>>> @@ -13,7 +13,7 @@ select: false
>>>>>>>  
>>>>>>>  properties:
>>>>>>>    $nodename:
>>>>>>> -    pattern: "^pwm(@.*|-[0-9a-f])*$"
>>>>>>> +    pattern: "^pwm(@.*|-([0-9a-f]|1[0-5]))*$"
>>>>>>
>>>>>> I wonder why you don't make this:
>>>>>>
>>>>>> +    pattern: "^pwm(@.*|-[0-9a-f]*)$"
>>>>
>>>> Yes, the '*' should be within ().
>>>
>>> Sorry I guess I don't follow. So for what type of naming is the second '*'
>>> actually needed here, or is it needed at all?
>>>
>>> We only want to match the following:
>>>
>>> pwm@1234
>>>
>>> pwm-0
>>> ...
>>> pwm-f
>>>
>>> And now also:
>>>
>>> pwm-0
>>> ...
>>> pwm-15
>>>
>>> Is there yet another format I'm missing?
>>>
>>>>> Hmm but I think this would also pass for node names like pwm-a-foo?
>>>>>
>>>>
>>>> No, how?
>>>
>>> Because of the second extra '*' there :)
>>
>> It cannot multiple dashes...

Yeah, it should be - it cannot match multiple dashes...

> 
> Sorry I'm still confused.. Care to specify what match do you want to
> use here and why?

Pattern:
-[0-9a-f]*
cannot match -1-2-3 because it does not cover the dash.

Best regards,
Krzysztof
Uwe Kleine-König Nov. 22, 2022, 9:36 a.m. UTC | #9
On Tue, Nov 22, 2022 at 06:43:55AM +0200, Tony Lindgren wrote:
> * Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> [221121 16:05]:
> > On 21/11/2022 15:48, Tony Lindgren wrote:
> > > * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221121 14:30]:
> > >> On Mon, Nov 21, 2022 at 01:55:24PM +0200, Tony Lindgren wrote:
> > >>> Let's allow node numbering in decimal format too.
> > >>>
> > >>> Simple human-readable increments/IDs are usually decimal, hex is only for
> > >>> addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.
> > >>>
> > >>> Cc: Thierry Reding <thierry.reding@gmail.com>
> > >>> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > >>> Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > >>> Signed-off-by: Tony Lindgren <tony@atomide.com>
> > >>> ---
> > >>>  Documentation/devicetree/bindings/pwm/pwm.yaml | 2 +-
> > >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> > >>>
> > >>> diff --git a/Documentation/devicetree/bindings/pwm/pwm.yaml b/Documentation/devicetree/bindings/pwm/pwm.yaml
> > >>> --- a/Documentation/devicetree/bindings/pwm/pwm.yaml
> > >>> +++ b/Documentation/devicetree/bindings/pwm/pwm.yaml
> > >>> @@ -13,7 +13,7 @@ select: false
> > >>>  
> > >>>  properties:
> > >>>    $nodename:
> > >>> -    pattern: "^pwm(@.*|-[0-9a-f])*$"
> > >>> +    pattern: "^pwm(@.*|-([0-9a-f]|1[0-5]))*$"
> > >>
> > >> I wonder why you don't make this:
> > >>
> > >> +    pattern: "^pwm(@.*|-[0-9a-f]*)$"
> > 
> > Yes, the '*' should be within ().
> 
> Sorry I guess I don't follow. So for what type of naming is the second '*'
> actually needed here, or is it needed at all?
> 
> We only want to match the following:
> 
> pwm@1234
> 
> pwm-0
> ...
> pwm-f
> 
> And now also:
> 
> pwm-0
> ...
> pwm-15
> 
> Is there yet another format I'm missing?

I think there is a misunderstanding about the type of pattern here. Do
we talk about a shell pattern where "[0-9a-f]*" matches a name starting
with a hex digit followed by any number of any caracter, or is it a
regexp where the * means "any number of the preceding pattern", so
effectively a word consisting of only hex digits.

The .* part makes me think we're talking about a regexp, so the old
pattern ("^pwm(@.*|-[0-9a-f])*$") means that

	pwm-1-2-3-4

is allowed but

	pwm-10

isn't. And I think what we want is:

	"^pwm(@.*|-[0-9a-f]*)$"

(or maybe better "^pwm(@.+|-[0-9a-f]+)$" ?)

Best regards
Uwe
Tony Lindgren Nov. 22, 2022, 10:37 a.m. UTC | #10
* Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221122 09:26]:
> On Tue, Nov 22, 2022 at 06:43:55AM +0200, Tony Lindgren wrote:
> > * Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> [221121 16:05]:
> > > On 21/11/2022 15:48, Tony Lindgren wrote:
> > > > * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221121 14:30]:
> > > >> On Mon, Nov 21, 2022 at 01:55:24PM +0200, Tony Lindgren wrote:
> > > >>> Let's allow node numbering in decimal format too.
> > > >>>
> > > >>> Simple human-readable increments/IDs are usually decimal, hex is only for
> > > >>> addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.
> > > >>>
> > > >>> Cc: Thierry Reding <thierry.reding@gmail.com>
> > > >>> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > >>> Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > > >>> Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > >>> ---
> > > >>>  Documentation/devicetree/bindings/pwm/pwm.yaml | 2 +-
> > > >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >>>
> > > >>> diff --git a/Documentation/devicetree/bindings/pwm/pwm.yaml b/Documentation/devicetree/bindings/pwm/pwm.yaml
> > > >>> --- a/Documentation/devicetree/bindings/pwm/pwm.yaml
> > > >>> +++ b/Documentation/devicetree/bindings/pwm/pwm.yaml
> > > >>> @@ -13,7 +13,7 @@ select: false
> > > >>>  
> > > >>>  properties:
> > > >>>    $nodename:
> > > >>> -    pattern: "^pwm(@.*|-[0-9a-f])*$"
> > > >>> +    pattern: "^pwm(@.*|-([0-9a-f]|1[0-5]))*$"
> > > >>
> > > >> I wonder why you don't make this:
> > > >>
> > > >> +    pattern: "^pwm(@.*|-[0-9a-f]*)$"
> > > 
> > > Yes, the '*' should be within ().
> > 
> > Sorry I guess I don't follow. So for what type of naming is the second '*'
> > actually needed here, or is it needed at all?
> > 
> > We only want to match the following:
> > 
> > pwm@1234
> > 
> > pwm-0
> > ...
> > pwm-f
> > 
> > And now also:
> > 
> > pwm-0
> > ...
> > pwm-15
> > 
> > Is there yet another format I'm missing?
> 
> I think there is a misunderstanding about the type of pattern here. Do
> we talk about a shell pattern where "[0-9a-f]*" matches a name starting
> with a hex digit followed by any number of any caracter, or is it a
> regexp where the * means "any number of the preceding pattern", so
> effectively a word consisting of only hex digits.
> 
> The .* part makes me think we're talking about a regexp, so the old
> pattern ("^pwm(@.*|-[0-9a-f])*$") means that
> 
> 	pwm-1-2-3-4
> 
> is allowed but
> 
> 	pwm-10
> 
> isn't. And I think what we want is:
> 
> 	"^pwm(@.*|-[0-9a-f]*)$"

Heh so this fails for just node name pwm:

pwm: $nodename:0: 'pwm' does not match '^pwm(@.*|-[0-9a-f]*)$'

Maybe that's why the second '..)*$' was there originally for?
And adding it back there fixes pwm but allows pwm-1-2-3..

> (or maybe better "^pwm(@.+|-[0-9a-f]+)$" ?)

And this too fails for just pwm node name.

Regards,

Tony
Uwe Kleine-König Nov. 22, 2022, 10:57 a.m. UTC | #11
On Tue, Nov 22, 2022 at 12:37:26PM +0200, Tony Lindgren wrote:
> * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221122 09:26]:
> > On Tue, Nov 22, 2022 at 06:43:55AM +0200, Tony Lindgren wrote:
> > > * Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> [221121 16:05]:
> > > > On 21/11/2022 15:48, Tony Lindgren wrote:
> > > > > * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221121 14:30]:
> > > > >> On Mon, Nov 21, 2022 at 01:55:24PM +0200, Tony Lindgren wrote:
> > > > >>> Let's allow node numbering in decimal format too.
> > > > >>>
> > > > >>> Simple human-readable increments/IDs are usually decimal, hex is only for
> > > > >>> addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.
> > > > >>>
> > > > >>> Cc: Thierry Reding <thierry.reding@gmail.com>
> > > > >>> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > > >>> Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > > > >>> Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > > >>> ---
> > > > >>>  Documentation/devicetree/bindings/pwm/pwm.yaml | 2 +-
> > > > >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >>>
> > > > >>> diff --git a/Documentation/devicetree/bindings/pwm/pwm.yaml b/Documentation/devicetree/bindings/pwm/pwm.yaml
> > > > >>> --- a/Documentation/devicetree/bindings/pwm/pwm.yaml
> > > > >>> +++ b/Documentation/devicetree/bindings/pwm/pwm.yaml
> > > > >>> @@ -13,7 +13,7 @@ select: false
> > > > >>>  
> > > > >>>  properties:
> > > > >>>    $nodename:
> > > > >>> -    pattern: "^pwm(@.*|-[0-9a-f])*$"
> > > > >>> +    pattern: "^pwm(@.*|-([0-9a-f]|1[0-5]))*$"
> > > > >>
> > > > >> I wonder why you don't make this:
> > > > >>
> > > > >> +    pattern: "^pwm(@.*|-[0-9a-f]*)$"
> > > > 
> > > > Yes, the '*' should be within ().
> > > 
> > > Sorry I guess I don't follow. So for what type of naming is the second '*'
> > > actually needed here, or is it needed at all?
> > > 
> > > We only want to match the following:
> > > 
> > > pwm@1234
> > > 
> > > pwm-0
> > > ...
> > > pwm-f
> > > 
> > > And now also:
> > > 
> > > pwm-0
> > > ...
> > > pwm-15
> > > 
> > > Is there yet another format I'm missing?
> > 
> > I think there is a misunderstanding about the type of pattern here. Do
> > we talk about a shell pattern where "[0-9a-f]*" matches a name starting
> > with a hex digit followed by any number of any caracter, or is it a
> > regexp where the * means "any number of the preceding pattern", so
> > effectively a word consisting of only hex digits.
> > 
> > The .* part makes me think we're talking about a regexp, so the old
> > pattern ("^pwm(@.*|-[0-9a-f])*$") means that
> > 
> > 	pwm-1-2-3-4
> > 
> > is allowed but
> > 
> > 	pwm-10
> > 
> > isn't. And I think what we want is:
> > 
> > 	"^pwm(@.*|-[0-9a-f]*)$"
> 
> Heh so this fails for just node name pwm:
> 
> pwm: $nodename:0: 'pwm' does not match '^pwm(@.*|-[0-9a-f]*)$'
> 
> Maybe that's why the second '..)*$' was there originally for?
> And adding it back there fixes pwm but allows pwm-1-2-3..
> 
> > (or maybe better "^pwm(@.+|-[0-9a-f]+)$" ?)
> 
> And this too fails for just pwm node name.

Then let's pick:


	"^pwm(@.+|-[0-9a-f]+)?$"

Best regards
Uwe
Tony Lindgren Nov. 22, 2022, 11:11 a.m. UTC | #12
* Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221122 10:47]:
> On Tue, Nov 22, 2022 at 12:37:26PM +0200, Tony Lindgren wrote:
> > * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221122 09:26]:
> > > On Tue, Nov 22, 2022 at 06:43:55AM +0200, Tony Lindgren wrote:
> > > > * Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> [221121 16:05]:
> > > > > On 21/11/2022 15:48, Tony Lindgren wrote:
> > > > > > * Uwe Kleine-König <u.kleine-koenig@pengutronix.de> [221121 14:30]:
> > > > > >> On Mon, Nov 21, 2022 at 01:55:24PM +0200, Tony Lindgren wrote:
> > > > > >>> Let's allow node numbering in decimal format too.
> > > > > >>>
> > > > > >>> Simple human-readable increments/IDs are usually decimal, hex is only for
> > > > > >>> addresses as noted by Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>.
> > > > > >>>
> > > > > >>> Cc: Thierry Reding <thierry.reding@gmail.com>
> > > > > >>> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > > > > >>> Suggested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> > > > > >>> Signed-off-by: Tony Lindgren <tony@atomide.com>
> > > > > >>> ---
> > > > > >>>  Documentation/devicetree/bindings/pwm/pwm.yaml | 2 +-
> > > > > >>>  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > >>>
> > > > > >>> diff --git a/Documentation/devicetree/bindings/pwm/pwm.yaml b/Documentation/devicetree/bindings/pwm/pwm.yaml
> > > > > >>> --- a/Documentation/devicetree/bindings/pwm/pwm.yaml
> > > > > >>> +++ b/Documentation/devicetree/bindings/pwm/pwm.yaml
> > > > > >>> @@ -13,7 +13,7 @@ select: false
> > > > > >>>  
> > > > > >>>  properties:
> > > > > >>>    $nodename:
> > > > > >>> -    pattern: "^pwm(@.*|-[0-9a-f])*$"
> > > > > >>> +    pattern: "^pwm(@.*|-([0-9a-f]|1[0-5]))*$"
> > > > > >>
> > > > > >> I wonder why you don't make this:
> > > > > >>
> > > > > >> +    pattern: "^pwm(@.*|-[0-9a-f]*)$"
> > > > > 
> > > > > Yes, the '*' should be within ().
> > > > 
> > > > Sorry I guess I don't follow. So for what type of naming is the second '*'
> > > > actually needed here, or is it needed at all?
> > > > 
> > > > We only want to match the following:
> > > > 
> > > > pwm@1234
> > > > 
> > > > pwm-0
> > > > ...
> > > > pwm-f
> > > > 
> > > > And now also:
> > > > 
> > > > pwm-0
> > > > ...
> > > > pwm-15
> > > > 
> > > > Is there yet another format I'm missing?
> > > 
> > > I think there is a misunderstanding about the type of pattern here. Do
> > > we talk about a shell pattern where "[0-9a-f]*" matches a name starting
> > > with a hex digit followed by any number of any caracter, or is it a
> > > regexp where the * means "any number of the preceding pattern", so
> > > effectively a word consisting of only hex digits.
> > > 
> > > The .* part makes me think we're talking about a regexp, so the old
> > > pattern ("^pwm(@.*|-[0-9a-f])*$") means that
> > > 
> > > 	pwm-1-2-3-4
> > > 
> > > is allowed but
> > > 
> > > 	pwm-10
> > > 
> > > isn't. And I think what we want is:
> > > 
> > > 	"^pwm(@.*|-[0-9a-f]*)$"
> > 
> > Heh so this fails for just node name pwm:
> > 
> > pwm: $nodename:0: 'pwm' does not match '^pwm(@.*|-[0-9a-f]*)$'
> > 
> > Maybe that's why the second '..)*$' was there originally for?
> > And adding it back there fixes pwm but allows pwm-1-2-3..
> > 
> > > (or maybe better "^pwm(@.+|-[0-9a-f]+)$" ?)
> > 
> > And this too fails for just pwm node name.
> 
> Then let's pick:
> 
> 
> 	"^pwm(@.+|-[0-9a-f]+)?$"

That works for pwm and pwm-11, but now fails for pwm11 :)

Tony
Krzysztof Kozlowski Nov. 22, 2022, 11:30 a.m. UTC | #13
On 22/11/2022 12:11, Tony Lindgren wrote:
>> Then let's pick:
>>
>>
>> 	"^pwm(@.+|-[0-9a-f]+)?$"
> 
> That works for pwm and pwm-11, but now fails for pwm11 :)

Which was never valid, so no problem.

Best regards,
Krzysztof
Tony Lindgren Nov. 22, 2022, 11:40 a.m. UTC | #14
* Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> [221122 11:20]:
> On 22/11/2022 12:11, Tony Lindgren wrote:
> >> Then let's pick:
> >>
> >>
> >> 	"^pwm(@.+|-[0-9a-f]+)?$"
> > 
> > That works for pwm and pwm-11, but now fails for pwm11 :)
> 
> Which was never valid, so no problem.

OK, let's go with that then! Thanks Krzysztof & Uwe, I'll post
updated patches.

Regards,

Tony
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/pwm/pwm.yaml b/Documentation/devicetree/bindings/pwm/pwm.yaml
--- a/Documentation/devicetree/bindings/pwm/pwm.yaml
+++ b/Documentation/devicetree/bindings/pwm/pwm.yaml
@@ -13,7 +13,7 @@  select: false
 
 properties:
   $nodename:
-    pattern: "^pwm(@.*|-[0-9a-f])*$"
+    pattern: "^pwm(@.*|-([0-9a-f]|1[0-5]))*$"
 
   "#pwm-cells":
     description: