Re: [PATCH] checkpatch: Don't emit warnings for USB & PCI device DT compatible prefixes
From: Chen-Yu Tsai
Date: Thu May 14 2026 - 23:24:32 EST
On Fri, May 15, 2026 at 2:10 AM Joe Perches <joe@xxxxxxxxxxx> wrote:
>
> On Thu, 2026-05-14 at 10:40 -0700, Brian Norris wrote:
> > Hi Chen-Yu,
> > On Thu, May 14, 2026 at 06:51:50PM +0800, Chen-Yu Tsai wrote:
> > The USB and PCI device bindings define some compatible patterns based
> > > on device IDs that use the comma to separate vendor and product IDs.
> > >
> > > These patterns include:
> > >
> > > - usb[0-9a-f]{1,4},[0-9a-f]{1,4}
> > > - pci[0-9a-f]{2,4},[0-9a-f]{1,4}
> > > - pciclass,[01][0-9a-f]{3}([0-9a-f]{2})?
> > >
> > > These are not real vendor prefixes. Don't emit warnings for them.
> > >
> > > Signed-off-by: Chen-Yu Tsai <[wenst@xxxxxxxxxxxx](mailto:wenst@xxxxxxxxxxxx)>
> > > ---
> > > This is a simplified version of what Brian Norris previously posted [1],
> >
> > Wow, almost forgot about that one. Thanks for the blast from the past.
>
> You know Brian, you're different than me.
> I completely forgot about that one.
>
> > > but more comprehensive and more perl-y than what Yingying Tang posted
> > Is "perl-y" a good thing? :)
Well it depends on who's asking. :p
Seriously though, it matches the code style around the change.
> My sweet wife thinks so. It's spelled differently though.
>
> > > Hopefully everyone likes this version.
> > I like any version that eliminates obvious false positives!
> >
> > But one thing that can be improved: your version still requires that the
> > full ID string be documented explicitly. For example, this still gives a
> > false warning:
> >
> > $ git format-patch -1 --stdout 24af105962c8004edb9f5bf84bc587cbb30e52de | scripts/checkpatch.pl
> > [...]
> > WARNING: DT compatible string "pci0014,7a24.0" appears un-documented -- check ./Documentation/devicetree/bindings/
> > #234: FILE: arch/mips/boot/dts/loongson/ls7a-pch.dtsi:37:
> > + compatible = "pci0014,7a24.0",
> > The dtschema is clear that anything matching the pci pattern is OK, and
> > we don't need to list every possible variation in a yaml file.
I guess that means matching the full compatible string against the
pattern.
Joe, any concerns?
> > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > > @@ -3795,6 +3795,9 @@ sub process {
> > >
> > > next if $compat !~ /^([a-zA-Z0-9\-]+)\,/;
> > > my $vendor = $1;
> > > + next if $vendor eq "pciclass";
> > > + next if $vendor =~ /^pci[a-f0-9]{2,4}$/;
>
> Maybe
>
> + next if $vendor =~ /^pci[a-f0-9]{2,4}/;
>
> ?
Does that make a difference? The vendor prefix '$vendor' is already
split out at the comma, or rather captured using the regex above,
from the full compatible string.
> > > + next if $vendor =~ /^usb(if)?[a-f0-9]{1,4}$/;
Sashiko mentioned that this papers over the fact that the matching
in checkpatch.pl doesn't consider regular expressions used in the DT
schemas. I suppose we won't be supporting that?
We could import Documentation/devicetree/bindings/processed-schema.json
and match against the compatibles and vendor prefixes from that. It
might actually be faster (vs grepping through the entire DT bindings
directory), but it requires the user having run make commands that
produce it.
ChenYu