[Deepin-Kernel-SIG] [linux 6.6.y] [Upstream] Upstream backport: checkpatch enhancements, README restructuring, and AI coding assistant docs #1647
Conversation
[Upstream commit 693fe59] - Fix spelling/capitalization s/Restructured/ReStructured/ Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Link: https://lore.kernel.org/r/20240207122127.9182-1-thorsten.blum@toblux.com Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit bf4401f] - ReStructured Text should be exactly reStructuredText - "reStructuredText" is ONE word, not two! according to https://docutils.sourceforge.io/rst.html Signed-off-by: Maki Hatano <Maki.Y.Hatano@gmail.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <20240313100136.20424-1-Maki.Y.Hatano@gmail.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit b9a565b] Reorganize README to provide targeted documentation paths for different user roles including developers, researchers, security experts, and maintainers. Add quick start section and essential docs links. Signed-off-by: Sasha Levin <sashal@kernel.org> Reviewed-by: Randy Dunlap <rdunlap@infradead.org> Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Reviewed-by: Kees Cook <kees@kernel.org> Reviewed-by: SeongJae Park <sj@kernel.org> Reviewed-by: Bagas Sanjaya <bagasdotme@gmail.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <20251121180009.2634393-1-sashal@kernel.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 78d979d] Add guidance for AI assistants and developers using AI tools for kernel contributions, per the consensus reached at the 2025 Maintainers Summit. Create Documentation/process/coding-assistants.rst with detailed guidance on licensing, Signed-off-by requirements, and attribution format. The README points AI tools to this documentation. This will allow coding assistants to easily parse these instructions and comply with guidelines set by the community. Link: https://lwn.net/Articles/1049830/ Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <20251223122110.2496946-1-sashal@kernel.org> [WangYuli: Fix conflicts] Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
Reviewer's GuideBackports a series of upstream improvements to scripts/checkpatch.pl (new style checks, false-positive reductions, and robustness fixes) and updates documentation by restructuring the top-level README and adding AI coding assistant contribution guidelines wired into the process docs. Sequence diagram for Fixes tag validation with git_commit_infosequenceDiagram
participant Dev as Developer
participant Checkpatch as checkpatch_pl
participant Git as git_commit_info
Dev->>Checkpatch: Run checkpatch on patch
Checkpatch->>Checkpatch: Detect Fixes line in commit log
Checkpatch->>Git: git_commit_info(orig_commit, id, title)
Git-->>Checkpatch: cid, ctitle
Checkpatch->>Checkpatch: Validate commit id length (12-40), case, spacing, quotes
alt Bad Fixes tag and cid defined
Checkpatch->>Checkpatch: Build corrected Fixes line
Checkpatch-->>Dev: WARN BAD_FIXES_TAG with suggested Fixes: cid ("ctitle")
opt --fix option enabled
Checkpatch->>Checkpatch: Replace line with corrected Fixes tag
end
else cid not defined
Checkpatch->>Checkpatch: Skip BAD_FIXES_TAG warning
end
Checkpatch-->>Dev: Continue reporting other issues and summary
Class diagram for logical components in checkpatch.plclassDiagram
class CheckpatchProcess {
+process(filename)
+exclude_global_initialisers(realfile)
+is_userspace(realfile)
}
class CommitLogChecks {
+check_placeholder_text(line, in_commit_log, in_header_lines)
+check_bad_commit_separator(line, in_commit_log, fix)
+check_fixes_tag(line, herecurr, fix)
+check_commit_log_long_line(line, herecurr)
+spell_check_line(rawline, misspellings, hereptr)
}
class ConfigHelpChecks {
+check_config_description(linenr, help_length, min_conf_desc_length)
}
class DeviceTreeChecks {
+check_uncommented_rgmii_mode(realfile, line, first_line, linenr, herecurr)
}
class ContextChecks {
+ctx_has_comment(first_line, linenr)
+check_context_unsafe(line, first_line, linenr, herecurr)
}
class StringUsageChecks {
+check_strcpy_usage(line, realfile, herecurr)
+check_strlcpy_usage(line, realfile, herecurr)
+check_strncpy_usage(line, realfile, herecurr)
}
class AllocationChecks {
+check_alloc_with_sizeof(stat, linenr, here, fix)
+check_alloc_with_multiply(stat, linenr, here, fix)
}
class DeviceIdChecks {
+dev_id_types
+check_device_id_sentinel(stat, line, here)
}
class PointerChecks {
+check_uninitialized_free_pointer(line, herecurr)
}
class GitIntegration {
+git_commit_info(orig_commit, id, title)
}
class SpellingSupport {
+decode_utf8(rawline)
+copy_spacing(rawline_utf8)
}
CheckpatchProcess --> CommitLogChecks : uses
CheckpatchProcess --> ConfigHelpChecks : uses
CheckpatchProcess --> DeviceTreeChecks : uses
CheckpatchProcess --> ContextChecks : uses
CheckpatchProcess --> StringUsageChecks : uses
CheckpatchProcess --> AllocationChecks : uses
CheckpatchProcess --> DeviceIdChecks : uses
CheckpatchProcess --> PointerChecks : uses
CommitLogChecks --> GitIntegration : uses
CommitLogChecks --> SpellingSupport : uses
ContextChecks <.. DeviceTreeChecks : uses
StringUsageChecks <.. CheckpatchProcess : calls is_userspace
DeviceIdChecks <.. CheckpatchProcess : uses dev_id_types
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
Adds a new process document describing expectations for AI-assisted kernel contributions and updates entry points so humans and tools can discover it (README + process index).
Changes:
- Expand
READMEinto a role-oriented entry document and add a prominent pointer for AI coding assistants to the new guidance. - Add
Documentation/process/coding-assistants.rstcovering licensing, DCO / Signed-off-by handling, and attribution expectations. - Include the new document in
Documentation/process/index.rstto surface it in the rendered “process” docs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| README | Reworks the top-level entry points and adds an explicit pointer to the AI assistants guidance. |
| Documentation/process/index.rst | Adds the new AI assistants document to the process toctree. |
| Documentation/process/coding-assistants.rst | Introduces AI-assistant contribution guidance (licensing, sign-off responsibilities, attribution format). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| When AI tools contribute to kernel development, proper attribution | ||
| helps track the evolving role of AI in the development process. | ||
| Contributions should include an Assisted-by tag in the following format:: | ||
|
|
||
| Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2] | ||
|
|
There was a problem hiding this comment.
The documented Assisted-by: format/example does not include a Name <email> identity. In this tree, scripts/checkpatch.pl treats any *-by: tag as a signature and will error out with “Unrecognized email address” when the text after the tag is not parseable as an email identity (see scripts/checkpatch.pl around the signature-style checks). Please adjust the documented format to include a valid email identity (or use a different tag name that doesn’t match *-by: / update checkpatch to explicitly accept the intended format).
| Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2] | ||
|
|
||
| Where: | ||
|
|
||
| * ``AGENT_NAME`` is the name of the AI tool or framework | ||
| * ``MODEL_VERSION`` is the specific model version used | ||
| * ``[TOOL1] [TOOL2]`` are optional specialized analysis tools used |
There was a problem hiding this comment.
The Assisted-by: format line uses [TOOL1] [TOOL2] (square brackets), but the example omits brackets. If the brackets are meant to indicate optional items (not literal characters), consider switching to a placeholder style that can’t be mistaken for part of the actual tag value and keep the format line and example consistent for tooling that will parse it.
| Assisted-by: AGENT_NAME:MODEL_VERSION [TOOL1] [TOOL2] | |
| Where: | |
| * ``AGENT_NAME`` is the name of the AI tool or framework | |
| * ``MODEL_VERSION`` is the specific model version used | |
| * ``[TOOL1] [TOOL2]`` are optional specialized analysis tools used | |
| Assisted-by: AGENT_NAME:MODEL_VERSION <TOOL1> <TOOL2> ... | |
| Where: | |
| * ``AGENT_NAME`` is the name of the AI tool or framework | |
| * ``MODEL_VERSION`` is the specific model version used | |
| * ``<TOOL1> <TOOL2> ...`` are optional specialized analysis tools used |
[Upstream commit 3735c52] Avoid string concatenation with an undefined variable when a reference to a missing commit is contained in a `Fixes` tag. Given this patch: : From: Tamir Duberstein <tamird@gmail.com> : Subject: Test patch : Date: Fri, 25 Oct 2024 19:30:51 -0400 : : This is a test patch. : : Fixes: deadbeef111 : Signed-off-by: Tamir Duberstein <tamird@gmail.com> : --- /dev/null : +++ b/new-file : @@ -0,0 +1 @@ : +Test. Before: WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: ("commit title")' WARNING: Unknown commit id 'deadbeef111', maybe rebased or not pulled? Use of uninitialized value $cid in concatenation (.) or string at scripts/checkpatch.pl line 3242. After: WARNING: Unknown commit id 'deadbeef111', maybe rebased or not pulled? This patch also reduce duplication slightly. [akpm@linux-foundation.org: s/12 chars of sha1/12+ chars of sha1/, per Jon] Link: https://lkml.kernel.org/r/87o70kt232.fsf@trenco.lwn.net Link: https://lkml.kernel.org/r/20241204-checkpatch-missing-commit-v1-1-68b34c94944e@gmail.com Signed-off-by: Tamir Duberstein <tamird@gmail.com> Cc: Andy Whitcroft <apw@canonical.com> Cc: Dwaipayan Ray <dwaipayanray1@gmail.com> Cc: Joe Perches <joe@perches.com> Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> Cc: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit bc2f19d] Neither the warning nor the help message gives any hint on the unit for length: Could be meters, inches, bytes, characters or ... lines. Extend the output of `--help` to name the unit "lines" and the default: - --min-conf-desc-length=n set the min description length, if shorter, warn + --min-conf-desc-length=n set the minimum description length for config symbols + in lines, if shorter, warn (default 4) Include the minimum number of lines as other error messages already do: - WARNING: please write a help paragraph that fully describes the config symbol + WARNING: please write a help paragraph that fully describes the config symbol with at least 4 lines Link: https://lkml.kernel.org/r/c71c170c90eba26265951e248adfedd3245fe575.1741605695.git.p.hahn@avm.de Signed-off-by: Philipp Hahn <p.hahn@avm.de> Cc: Andy Whitcroft <apw@canonical.com> Cc: Joe Perches <joe@perches.com> Cc: Dwaipayan Ray <dwaipayanray1@gmail.com> Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit e02adac] Historically, the RGMII PHY modes specified in Device Trees have been used inconsistently, often referring to the usage of delays on the PHY side rather than describing the board; many drivers still implement this incorrectly. Require a comment in Devices Trees using these modes (usually mentioning that the delay is realized on the PCB), so we can avoid adding more incorrect uses (or will at least notice which drivers still need to be fixed). Suggested-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://patch.msgid.link/bc112b8aa510cf9df9ab33178d122f234d0aebf7.1750756583.git.matthias.schiffer@ew.tq-group.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 5eee4c2] The current code that checks for misspelling verifies, in a more complex regex, if $rawline matches [^\w]($misspellings)[^\w] Being $rawline a byte-string, a utf-8 character in $rawline can match the non-word-char [^\w]. E.g.: ./scripts/checkpatch.pl --git 81c2f05 WARNING: 'ment' may be misspelled - perhaps 'meant'? deepin-community#36: FILE: MAINTAINERS:14360: +M: Clément Léger <clement.leger@bootlin.com> ^^^^ Use a utf-8 version of $rawline for spell checking. Link: https://lkml.kernel.org/r/20250616-b4-checkpatch-upstream-v2-1-5600ce4a3b43@foss.st.com Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com> Signed-off-by: Clément Le Goffic <clement.legoffic@foss.st.com> Cc: Andy Whitcroft <apw@canonical.com> Cc: Dwaipayan Ray <dwaipayanray1@gmail.com> Cc: Joe Perches <joe@perches.com> Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 22c2ed6] All of the ID tables based on <linux/mod_devicetable.h> (of_device_id, pci_device_id, ...) require their arrays to end in an empty sentinel value. That's usually spelled with an empty initializer entry (e.g., "{}"), but also sometimes with explicit 0 entries, field initializers (e.g., '.id = ""'), or even a macro entry (like PCMCIA_DEVICE_NULL). Without a sentinel, device-matching code may read out of bounds. I've found a number of such bugs in driver reviews, and we even occasionally commit one to the tree. See commit 5751eee ("i2c: nomadik: Add missing sentinel to match table") for example. Teach checkpatch to find these ID tables, and complain if it looks like there wasn't a sentinel value. Test output: $ git format-patch -1 a0d15cc --stdout | scripts/checkpatch.pl - ERROR: missing sentinel in ID array deepin-community#57: FILE: drivers/i2c/busses/i2c-nomadik.c:1073: +static const struct of_device_id nmk_i2c_eyeq_match_table[] = { { .compatible = "XXXXXXXXXXXXXXXXXX", .data = (void *)(NMK_I2C_EYEQ_FLAG_32B_BUS | NMK_I2C_EYEQ_FLAG_IS_EYEQ5), }, }; total: 1 errors, 0 warnings, 66 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. "[PATCH] i2c: nomadik: switch from of_device_is_compatible() to" has style problems, please review. NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS. When run across the entire tree (scripts/checkpatch.pl -q --types MISSING_SENTINEL -f ...), false positives exist: * where macros are used that hide the table from analysis (e.g., drivers/gpu/drm/radeon/radeon_drv.c / radeon_PCI_IDS). There are fewer than 5 of these. * where such tables are processed correctly via ARRAY_SIZE() (fewer than 5 instances). This is by far not the typical usage of *_device_id arrays. * some odd parsing artifacts, where ctx_statement_block() seems to quit in the middle of a block due to #if/#else/#endif. Also, not every "struct *_device_id" is in fact a sentinel-requiring structure, but even with such types, false positives are very rare. Link: https://lkml.kernel.org/r/20250702235245.1007351-1-briannorris@chromium.org Signed-off-by: Brian Norris <briannorris@chromium.org> Acked-by: Joe Perches <joe@perches.com> Cc: Andy Whitcroft <apw@canonical.com> Cc: Brian Norris <briannorris@chromium.org> Cc: Dwaipayan Ray <dwaipayanray1@gmail.com> Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit a6cf527] Dave Gilbert noticed that checkpatch warns about URL links over 75 chars in length in commit logs. Fix that. Link: https://lkml.kernel.org/r/3529faaf84a5a9a96c5c0ec4183ae0ba6e97673c.camel@perches.com Signed-off-by: Joe Perches <joe@perches.com> Cc: Dave Gilbert <linux@treblig.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 99b70ec] The checkpatch.pl script currently warns against the use of strcpy, strlcpy, and strncpy, recommending strscpy as a safer alternative. However, these warnings are also triggered for code under tools/ and scripts/, which are userspace utilities where strscpy is not available. This patch suppresses these warnings for files in tools/ and scripts/. Link: https://lkml.kernel.org/r/20250923171722.7798-1-suchitkarunakaran@gmail.com Signed-off-by: Suchit Karunakaran <suchitkarunakaran@gmail.com> Acked-by: Joe Perches <joe@perches.com> Cc: Andy Whitcroft <apw@canonical.com> Cc: Dwaipayan Ray <dwaipayanray1@gmail.com> Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> Cc: Shuah Khan <shuah@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit fc387a0] Add a new check PLACEHOLDER_USE to detect unhandled placeholders. This prevents sending patch series with incomplete patches (mostly in cover letters) containing auto generated subject or blurb lines. These placeholders can be seen on mailing lists. With this change, checkpatch will emit an error when such text is found. Link: https://lkml.kernel.org/r/20250917173725.22547-2-work@onurozkan.dev Signed-off-by: Onur Özkan <work@onurozkan.dev> Acked-by: Joe Perches <joe@perches.com> Cc: Andy Whitcroft <apw@canonical.com> Cc: Dwaipayan Ray <dwaipayanray1@gmail.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 464c7ea] As of commit 85656ec, the IDR interface is marked as deprecated in the documentation, but no checks are made in that regard for new code. Add the existing IDR initialization APIs to the deprecated list in checkpatch, so that if new code is introduced using these APIs, a warning is emitted. Link: https://lkml.kernel.org/r/20251031111908.2266077-2-clopez@suse.de Signed-off-by: Carlos López <clopez@suse.de> Suggested-by: Dan Williams <dan.j.williams@intel.com> Acked-by: Dan Williams <dan.j.williams@intel.com> Acked-by: Joe Perches <joe@perches.com> Cc: Andy Whitcroft <apw@canonical.com> Cc: Dwaipayan Ray <dwaipayanray1@gmail.com> Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> Cc: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 01da521] Uinitialized pointers with __free attribute can cause undefined behavior as the memory randomly assigned to the pointer is freed automatically when the pointer goes out of scope. add check in checkpatch to detect such issues. Link: https://lkml.kernel.org/r/20251203-aheev-checkpatch-uninitialized-free-v7-1-841e3b31d8f3@gmail.com Signed-off-by: Ally Heev <allyheev@gmail.com> Suggested-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/all/8a4c0b43-cf63-400d-b33d-d9c447b7e0b9@suswa.mountain/ Link: https://lore.kernel.org/all/58fd478f408a34b578ee8d949c5c4b4da4d4f41d.camel@HansenPartnership.com/ Acked-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Acked-by: Joe Perches <joe@perches.com> Cc: Andy Whitcroft <apw@canonical.com> Cc: David Hunter <david.hunter.linux@gmail.com> Cc: Dwaipayan Ray <dwaipayanray1@gmail.com> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Cc: James Bottomley <james.bottomley@HansenPartnership.com> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> Cc: Menon, Nishanth <nm@ti.com> Cc: Stephen Boyd <sboyd@kernel.org> Cc: Viresh Kumar <vireshk@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 25d3b21] Warn about applications of context_unsafe() without a comment, to encourage documenting the reasoning behind why it was deemed safe. Signed-off-by: Marco Elver <elver@google.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20251219154418.3592607-6-elver@google.com Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 070580b] To support shifting away from sized allocation towards typed allocations, suggest the kmalloc_obj family of macros when a sizeof() is present in the argument lists. Link: https://patch.msgid.link/20251203233036.3212363-2-kees@kernel.org Signed-off-by: Kees Cook <kees@kernel.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 74bc5f6] Currently, cacheline group macros trigger checkpatch warnings. For example: $ ./scripts/checkpatch.pl -g ba7e025a6c84aed012421468d83639e5dae982b0 WARNING: Missing a blank line after declarations deepin-community#58: FILE: drivers/gpio/gpio-virtio.c:32: + struct virtio_gpio_response res; + __dma_from_device_group_end(); $ ./scripts/checkpatch.pl -g 5d4cc87 WARNING: Missing a blank line after declarations deepin-community#267: FILE: include/net/sock.h:431: + int sk_rcvlowat; + __cacheline_group_end(sock_read_rx); But these are not actually statements - the following macros all expand to zero-length fields: __cacheline_group_begin() __cacheline_group_end() __cacheline_group_begin_aligned() __cacheline_group_end_aligned() __dma_from_device_group_begin() __dma_from_device_group_end() Add them to $declaration_macros so checkpatch recognizes this fact. Message-ID: <b345bb7e2d4e23672e3e5d1b283754dc11c7d8cd.1767647872.git.mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 931d5c3] Some versions of tools that apply patches incorrectly allow lines that start with 3 dashes and have additional content on the same line. Checkpatch will now emit an ERROR on these lines and optionally convert those lines from dashes to equals with --fix. Link: https://lkml.kernel.org/r/6ec1ed08328340db42655287afd5fa4067316b11.camel@perches.com Signed-off-by: Joe Perches <joe@perches.com> Suggested-by: Ian Rogers <irogers@google.com> Cc: Andy Whitcroft <apw@canonical.com> Cc: Dwaipayan Ray <dwaipayanray1@gmail.com> Cc: Kuan-Wei Chiu <visitorckw@gmail.com> Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com> Cc: Namhyung kim <namhyung@kernel.org> Cc: Stehen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit a45ff9dd3fec5d604f99b2665c40db26ce81ec0c] Patches which both remove and add/modify DT binding files are incorrectly flagged as needing to split the patch. The issue is the check sees "dev/null" as one of the files in the patch which is not a DT binding file. Add "dev/null" to the skipped files. Link: https://patch.msgid.link/20260121212715.144495-1-robh@kernel.org Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 20d00cf] Improve CamelCase recognition logic to avoid reporting on _Generic() use. Other C keywords, such as _Bool, are intentionally omitted, as those should be rather avoided in new source code. Reviewed-by: Wojciech Drewek <wojciech.drewek@intel.com> Reviewed-by: Simon Horman <horms@kernel.org> Signed-off-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com> Acked-by: Joe Perches <joe@perches.com> Signed-off-by: Przemek Kitszel <przemyslaw.kitszel@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
[Upstream commit 6356f18] The guidelines for git commit ID abbreviation are inconsistent: some places state to use 12 characters exactly, while other places recommend 12 characters or more. The same issue is present in the checkpatch.pl script. E.g. Documentation/dev-tools/checkpatch.rst says: **GIT_COMMIT_ID** The proper way to reference a commit id is: commit <12+ chars of sha1> ("<title line>") However, scripts/checkpatch.pl has two different checks: one warning check accepting 12 characters exactly: # Check Fixes: styles is correct Please use correct Fixes: style 'Fixes: <12 chars of sha1> (\"<title line>\")' and a second error check accepting 12-40 characters: # Check for git id commit length and improperly formed commit descriptions # A correctly formed commit description is: # commit <SHA-1 hash length 12+ chars> ("Complete commit subject") Please use git commit description style 'commit <12+ chars of sha1> Hence patches containing commit IDs with more than 12 characters are flagged by checkpatch, and sometimes rejected by maintainers or reviewers. This is becoming more important with the growth of the repository, as git may decide to use more characters in case of local conflicts. Fix this by settling on at least 12 characters, in both the documentation and in the checkpatch.pl script. Fixes: bd17e03 ("checkpatch: warn for non-standard fixes tag style") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://lore.kernel.org/r/1c244040bf6ce304656e31036e5178b4b9dfb719.1733421037.git.geert+renesas@glider.be Signed-off-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: WangYuli <wangyl5933@chinaunicom.cn>
There was a problem hiding this comment.
Hey - I've found 4 issues, and left some high level feedback:
- In the new ALLOC_WITH_SIZEOF and ALLOC_WITH_MULTIPLE checks, the capture groups from the regex are used incorrectly (e.g.,
$oldfunc = $3; my $a1 = $4;when the regex only defines$1..$3), which will result in wrong or undefined values at runtime; please realign the variable assignments with the actual capture indices (function name is$2, first argument$3, etc.). - The
$dev_id_typesregex only matches IDs starting with a lowercase ASCII letter ([a-z]), which may miss valid*_device_idtypes that start with an uppercase letter or underscore in future or out-of-tree code; consider relaxing this to\wor similar if you want the check to be more robust.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the new ALLOC_WITH_SIZEOF and ALLOC_WITH_MULTIPLE checks, the capture groups from the regex are used incorrectly (e.g., `$oldfunc = $3; my $a1 = $4;` when the regex only defines `$1..$3`), which will result in wrong or undefined values at runtime; please realign the variable assignments with the actual capture indices (function name is `$2`, first argument `$3`, etc.).
- The `$dev_id_types` regex only matches IDs starting with a lowercase ASCII letter (`[a-z]`), which may miss valid `*_device_id` types that start with an uppercase letter or underscore in future or out-of-tree code; consider relaxing this to `\w` or similar if you want the check to be more robust.
## Individual Comments
### Comment 1
<location path="scripts/checkpatch.pl" line_range="3102-3104" />
<code_context>
}
+# Check for invalid patch separator
+ if ($in_commit_log &&
+ $line =~ /^---.+/) {
+ if (ERROR("BAD_COMMIT_SEPARATOR",
+ "Invalid commit separator - some tools may have problems applying this\n" . $herecurr) &&
+ $fix) {
</code_context>
<issue_to_address>
**issue (bug_risk):** Auto-fix for BAD_COMMIT_SEPARATOR is overly aggressive
The fix uses `$fixed[$fixlinenr] =~ s/-/=/g;`, which replaces every dash on the line, not just the `---` separator. This risks altering commit message content on the same line. Please scope the substitution to the leading separator only (e.g. `s/^---/===/` or another prefix-limited pattern).
</issue_to_address>
### Comment 2
<location path="Documentation/dev-tools/checkpatch.rst" line_range="523" />
<code_context>
+ used inconsistently, often referring to the usage of delays on the PHY
+ side rather than describing the board.
+
+ PHY modes "rgmii", "rgmii-rxid" and "rgmii-txid" modes require the clock
+ signal to be delayed on the PCB; this unusual configuration should be
+ described in a comment. If they are not (meaning that the delay is realized
</code_context>
<issue_to_address>
**issue (typo):** Duplicated word "modes" in the RGMII PHY modes sentence
The phrase "PHY modes 'rgmii', 'rgmii-rxid' and 'rgmii-txid' modes" repeats "modes". Please drop the second occurrence, e.g. "PHY modes 'rgmii', 'rgmii-rxid' and 'rgmii-txid' require the clock".
```suggestion
PHY modes "rgmii", "rgmii-rxid" and "rgmii-txid" require the clock
```
</issue_to_address>
### Comment 3
<location path="Documentation/dev-tools/checkpatch.rst" line_range="633-634" />
<code_context>
+ **BAD_COMMIT_SEPARATOR**
+ The commit separator is a single line with 3 dashes.
+ The regex match is '^---$'
+ Lines that start with 3 dashes and have more content on the same line
+ may confuse tools that apply patches.
</code_context>
<issue_to_address>
**issue (typo):** Missing punctuation between two sentences in BAD_COMMIT_SEPARATOR description
"The regex match is '^---$'" runs directly into "Lines that start with 3 dashes..." without punctuation. Please add a period after the closing quote or rephrase to "The regex matches '^---$'."
Suggested implementation:
```
The regex matches '^---$'.
```
The snippet you provided doesn't show the "The regex match is '^---$'" line or the following "Lines that start with 3 dashes..." line, so you'll need to ensure this search string matches exactly what is in your file (indentation, spacing, and quoting). If the actual text differs (for example different quotes, extra spaces, or punctuation), adjust the SEARCH string accordingly while keeping the REPLACE text as suggested.
</issue_to_address>
### Comment 4
<location path="Documentation/dev-tools/checkpatch.rst" line_range="1023-1024" />
<code_context>
return bar;
+ **UNINITIALIZED_PTR_WITH_FREE**
+ Pointers with __free attribute should be declared at the place of use
+ and initialized (see include/linux/cleanup.h). In this case
+ declarations at the top of the function rule can be relaxed. Not doing
</code_context>
<issue_to_address>
**issue (typo):** Missing article before "__free attribute"
For correct grammar, use: "Pointers with the __free attribute should be declared at the place of use..."
```suggestion
**UNINITIALIZED_PTR_WITH_FREE**
Pointers with the __free attribute should be declared at the place of use
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| if ($in_commit_log && | ||
| $line =~ /^---.+/) { | ||
| if (ERROR("BAD_COMMIT_SEPARATOR", |
There was a problem hiding this comment.
issue (bug_risk): Auto-fix for BAD_COMMIT_SEPARATOR is overly aggressive
The fix uses $fixed[$fixlinenr] =~ s/-/=/g;, which replaces every dash on the line, not just the --- separator. This risks altering commit message content on the same line. Please scope the substitution to the leading separator only (e.g. s/^---/===/ or another prefix-limited pattern).
| used inconsistently, often referring to the usage of delays on the PHY | ||
| side rather than describing the board. | ||
|
|
||
| PHY modes "rgmii", "rgmii-rxid" and "rgmii-txid" modes require the clock |
There was a problem hiding this comment.
issue (typo): Duplicated word "modes" in the RGMII PHY modes sentence
The phrase "PHY modes 'rgmii', 'rgmii-rxid' and 'rgmii-txid' modes" repeats "modes". Please drop the second occurrence, e.g. "PHY modes 'rgmii', 'rgmii-rxid' and 'rgmii-txid' require the clock".
| PHY modes "rgmii", "rgmii-rxid" and "rgmii-txid" modes require the clock | |
| PHY modes "rgmii", "rgmii-rxid" and "rgmii-txid" require the clock |
| The regex match is '^---$' | ||
| Lines that start with 3 dashes and have more content on the same line |
There was a problem hiding this comment.
issue (typo): Missing punctuation between two sentences in BAD_COMMIT_SEPARATOR description
"The regex match is '^---$'" runs directly into "Lines that start with 3 dashes..." without punctuation. Please add a period after the closing quote or rephrase to "The regex matches '^---$'."
Suggested implementation:
The regex matches '^---$'.
The snippet you provided doesn't show the "The regex match is '^---$'" line or the following "Lines that start with 3 dashes..." line, so you'll need to ensure this search string matches exactly what is in your file (indentation, spacing, and quoting). If the actual text differs (for example different quotes, extra spaces, or punctuation), adjust the SEARCH string accordingly while keeping the REPLACE text as suggested.
| **UNINITIALIZED_PTR_WITH_FREE** | ||
| Pointers with __free attribute should be declared at the place of use |
There was a problem hiding this comment.
issue (typo): Missing article before "__free attribute"
For correct grammar, use: "Pointers with the __free attribute should be declared at the place of use..."
| **UNINITIALIZED_PTR_WITH_FREE** | |
| Pointers with __free attribute should be declared at the place of use | |
| **UNINITIALIZED_PTR_WITH_FREE** | |
| Pointers with the __free attribute should be declared at the place of use |
| my $newfunc = "kmalloc_objs"; | ||
| $newfunc = "kvmalloc_objs" if ($oldfunc eq "kvmalloc"); | ||
| $newfunc = "kvzalloc_objs" if ($oldfunc eq "kvzalloc"); | ||
| $newfunc = "kzalloc_objs" if ($oldfunc eq "kzalloc"); |
This PR backports upstream improvements to the kernel's patch checking infrastructure,
documentation, and contributor guidelines. All commits are signed-off and rebased.
checkpatch.pl improvements (16 commits)
Enhance the kernel patch style checker with new validations and bug fixes:
New checks:
False positive fixes:
Robustness & clarity:
Documentation (2 commits)
Documentation/process/coding-assistants.rstwith guidance for AI-assistedkernel contributions (licensing, Signed-off-by, attribution format)
READMEwith role-based documentation paths for developers, researchers,security experts, and maintainers; add quick-start section
README fixes (1 commit)
Files changed: 7
Insertions: 396, Deletions: 38
Summary by Sourcery
Document guidelines for using AI coding assistants in kernel development and surface this guidance from existing documentation entry points.
Enhancements:
Documentation:
Summary by Sourcery
Backport upstream improvements to the kernel checkpatch script and documentation, including new validations, clearer diagnostics, and guidance for AI-assisted contributions, while updating the top-level README structure.
New Features:
Bug Fixes:
Enhancements:
Documentation: