2014-02-27 19:57:28

by Florian Vaussard

[permalink] [raw]
Subject: [PATCH] checkpatch: fix spurious vendor compatible warnings

With a compatible string like

compatible = "foo";

checkpatch will currently try to find "foo" in vendor-prefixes.txt,
which is wrong since the vendor prefix is empty in this specific case.

Skip the vendor test if the compatible is not like

compatible = "vendor,something";

Signed-off-by: Florian Vaussard <[email protected]>
---
scripts/checkpatch.pl | 1 +
1 file changed, 1 insertion(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 464dcef..35ec185 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2058,6 +2058,7 @@ sub process {
my $vendor = $compat;
my $vendor_path = $dt_path . "vendor-prefixes.txt";
next if (! -f $vendor_path);
+ next if not $vendor =~ /^[a-zA-Z0-9]+\,.*/;
$vendor =~ s/^([a-zA-Z0-9]+)\,.*/$1/;
`grep -Eq "$vendor" $vendor_path`;
if ( $? >> 8 ) {
--
1.8.5.3


2014-02-27 20:10:14

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] checkpatch: fix spurious vendor compatible warnings

On Thu, 2014-02-27 at 20:56 +0100, Florian Vaussard wrote:
> With a compatible string like
>
> compatible = "foo";
>
> checkpatch will currently try to find "foo" in vendor-prefixes.txt,
> which is wrong since the vendor prefix is empty in this specific case.
>
> Skip the vendor test if the compatible is not like
>
> compatible = "vendor,something";
>
> Signed-off-by: Florian Vaussard <[email protected]>
> ---
> scripts/checkpatch.pl | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 464dcef..35ec185 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2058,6 +2058,7 @@ sub process {
> my $vendor = $compat;
> my $vendor_path = $dt_path . "vendor-prefixes.txt";
> next if (! -f $vendor_path);
> + next if not $vendor =~ /^[a-zA-Z0-9]+\,.*/;
> $vendor =~ s/^([a-zA-Z0-9]+)\,.*/$1/;
> `grep -Eq "$vendor" $vendor_path`;
> if ( $? >> 8 ) {

Some vendor names have dashes.
I don't know if underscores are allowed.

$ grep -rP --include=*.[ch] -oh "compatible\s*=\s*\"[^,]+,\w" * | \
sed -r -e 's/\s//g' -e 's/,.$//' | sort | uniq -c | grep "[_-]"
1 compatible="active-semi
8 compatible="asahi-kasei

2014-02-27 20:24:44

by Florian Vaussard

[permalink] [raw]
Subject: Re: [PATCH] checkpatch: fix spurious vendor compatible warnings



On 02/27/2014 09:10 PM, Joe Perches wrote:
> On Thu, 2014-02-27 at 20:56 +0100, Florian Vaussard wrote:
>> With a compatible string like
>>
>> compatible = "foo";
>>
>> checkpatch will currently try to find "foo" in vendor-prefixes.txt,
>> which is wrong since the vendor prefix is empty in this specific case.
>>
>> Skip the vendor test if the compatible is not like
>>
>> compatible = "vendor,something";
>>
>> Signed-off-by: Florian Vaussard <[email protected]>
>> ---
>> scripts/checkpatch.pl | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>> index 464dcef..35ec185 100755
>> --- a/scripts/checkpatch.pl
>> +++ b/scripts/checkpatch.pl
>> @@ -2058,6 +2058,7 @@ sub process {
>> my $vendor = $compat;
>> my $vendor_path = $dt_path . "vendor-prefixes.txt";
>> next if (! -f $vendor_path);
>> + next if not $vendor =~ /^[a-zA-Z0-9]+\,.*/;
>> $vendor =~ s/^([a-zA-Z0-9]+)\,.*/$1/;
>> `grep -Eq "$vendor" $vendor_path`;
>> if ( $? >> 8 ) {
>
> Some vendor names have dashes.
> I don't know if underscores are allowed.
>
> $ grep -rP --include=*.[ch] -oh "compatible\s*=\s*\"[^,]+,\w" * | \
> sed -r -e 's/\s//g' -e 's/,.$//' | sort | uniq -c | grep "[_-]"
> 1 compatible="active-semi
> 8 compatible="asahi-kasei
>

Good catch. In ePAPR v1.1, I could not find any strict requirement. It
is just saying:

The recommended format is ?manufacturer,model?, where manufacturer is a
string describing the name of the manufacturer (such as a stock ticker
symbol), and model specifies the model number.

If I am not mistaking, the stock ticker symbol will not contain exotic
characters, but it is not always available. So we should probably add
the '-. I am not sure for the '_'.

Florian

2014-02-27 23:53:55

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH] checkpatch: fix spurious vendor compatible warnings

On Thu, 2014-02-27 at 21:24 +0100, Florian Vaussard wrote:
> On 02/27/2014 09:10 PM, Joe Perches wrote:
> > On Thu, 2014-02-27 at 20:56 +0100, Florian Vaussard wrote:
> >> With a compatible string like
> >> compatible = "foo";
> >> checkpatch will currently try to find "foo" in vendor-prefixes.txt,
> >> which is wrong since the vendor prefix is empty in this specific case.
[]
> > Some vendor names have dashes.
> > I don't know if underscores are allowed.
> >
> > $ grep -rP --include=*.[ch] -oh "compatible\s*=\s*\"[^,]+,\w" * | \
> > sed -r -e 's/\s//g' -e 's/,.$//' | sort | uniq -c | grep "[_-]"
> > 1 compatible="active-semi
> > 8 compatible="asahi-kasei
[]
> In ePAPR v1.1, I could not find any strict requirement. It
> is just saying:
>
> The recommended format is “manufacturer,model”, where manufacturer is a
> string describing the name of the manufacturer (such as a stock ticker
> symbol), and model specifies the model number.

Should there also be a check in .c and .h files for
.compatible = "somestring"
and
OF_DEV_AUXDATA("somestring",,,,)

?

2014-02-28 01:24:17

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH] checkpatch: fix spurious vendor compatible warnings

On Thu, Feb 27, 2014 at 5:53 PM, Joe Perches <[email protected]> wrote:
> On Thu, 2014-02-27 at 21:24 +0100, Florian Vaussard wrote:
>> On 02/27/2014 09:10 PM, Joe Perches wrote:
>> > On Thu, 2014-02-27 at 20:56 +0100, Florian Vaussard wrote:
>> >> With a compatible string like
>> >> compatible = "foo";
>> >> checkpatch will currently try to find "foo" in vendor-prefixes.txt,
>> >> which is wrong since the vendor prefix is empty in this specific case.
> []
>> > Some vendor names have dashes.
>> > I don't know if underscores are allowed.
>> >
>> > $ grep -rP --include=*.[ch] -oh "compatible\s*=\s*\"[^,]+,\w" * | \
>> > sed -r -e 's/\s//g' -e 's/,.$//' | sort | uniq -c | grep "[_-]"
>> > 1 compatible="active-semi
>> > 8 compatible="asahi-kasei
> []
>> In ePAPR v1.1, I could not find any strict requirement. It
>> is just saying:
>>
>> The recommended format is "manufacturer,model", where manufacturer is a
>> string describing the name of the manufacturer (such as a stock ticker
>> symbol), and model specifies the model number.
>
> Should there also be a check in .c and .h files for
> .compatible = "somestring"

Ideally, yes. I didn't do that because I figured there would be too
many variations in formatting compared to dts files.

> and
> OF_DEV_AUXDATA("somestring",,,,)

Probably not. OF_DEV_AUXDATA is hopefully temporary. There are 156
instances now and it looks like they've been going down since 3.8.

Rob