嵌入式 Linux 驱动工程师 — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited 嵌入式 Linux 驱动工程师 (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
insmod 能加载和在量产设备上稳定运行之间的区别Documentation/process/coding-style.rst——Tab 缩进、80 列软限制、内核命名风格devm_* 系列 API(devm_kzalloc、devm_request_irq、devm_clk_get)实现自动资源管理probe() 中分配的非 devm 资源必须在 remove() 中按逆序释放sleep 系列函数于原子上下文Documentation/devicetree/bindings/ 下的 YAML schemacompatible 字符串必须遵循 "vendor,device" 格式,且与驱动的 of_match_table 一致status = "okay" / "disabled" 控制设备启用,不要用 #if 宏mutex(可睡眠上下文)、spinlock(中断上下文)、RCU(读多写少)lockdep 和 PROVE_LOCKING 验证锁序——不要等死锁出现在量产设备上才发现dma_alloc_coherent() 或 streaming DMA API,注意 cache 一致性Kconfig 和 Makefile 必须正确集成到内核构建树ARCH 和 CROSS_COMPILE,不要依赖宿主机工具链make M= 构建,但量产驱动应争取合入内核主线#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/io.h>
struct mydev_priv {
void __iomem *base;
struct clk *clk;
int irq;
};
static int mydev_probe(struct platform_device *pdev)
{
struct mydev_priv *priv;
struct resource *res;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
priv->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->base))
return PTR_ERR(priv->base);
priv->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(priv->clk))
return PTR_ERR(priv->clk);
priv->irq = platform_get_irq(pdev, 0);
if (priv->irq < 0)
return priv->irq;
platform_set_drvdata(pdev, priv);
dev_info(&pdev->dev, "probed successfully\n");
return 0;
}
static const struct of_device_id mydev_of_match[] = {
{ .compatible = "vendor,mydevice" },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, mydev_of_match);
static struct platform_driver mydev_driver = {
.probe = mydev_probe,
.driver = {
.name = "mydevice",
.of_match_table = mydev_of_match,
},
};
module_platform_driver(mydev_driver);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("My Device Driver");
MODULE_AUTHOR("Author");/ {
mydevice@40000000 {
compatible = "vendor,mydevice";
reg = <0x40000000 0x1000>;
interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&cru CLK_MYDEV>;
clock-names = "core";
pinctrl-names = "default";
pinctrl-0 = <&mydev_pins>;
status = "okay";
};
};static int myiic_probe(struct i2c_client *client)
{
struct myiic_priv *priv;
priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->regmap = devm_regmap_init_i2c(client, &myiic_regmap_config);
if (IS_ERR(priv->regmap))
return PTR_ERR(priv->regmap);
i2c_set_clientdata(client, priv);
return 0;
}
static const struct i2c_device_id myiic_id[] = {
{ "myiic", 0 },
{ }
};
MODULE_DEVICE_TABLE(i2c, myiic_id);
static const struct of_device_id myiic_of_match[] = {
{ .compatible = "vendor,myiic-sensor" },
{ }
};
MODULE_DEVICE_TABLE(of, myiic_of_match);
static struct i2c_driver myiic_driver = {
.driver = {
.name = "myiic",
.of_match_table = myiic_of_match,
},
.probe = myiic_probe,
.id_table = myiic_id,
};
module_i2c_driver(myiic_driver);SUMMARY = "My custom kernel module"
LICENSE = "GPL-2.0-only"
LIC_FILES_CHKSUM = "file://COPYING;md5=..."
inherit module
SRC_URI = "file://mydriver.c \
file://Makefile \
"
S = "${WORKDIR}"
RPROVIDES:${PN} += "kernel-module-mydriver"Documentation/driver-api/dma-buf.rst 了解 DMA-BUF 共享机制"devm_platform_ioremap_resource() 从 5.1 开始可用,旧内核需要手动 platform_get_resource + devm_ioremap_resource"spin_lock_irqsave 保护区域内调用 kmalloc(GFP_KERNEL) 会导致调度——必须用 GFP_ATOMIC"checkpatch.pl --strict 零警告kmemleak 验证)ftrace 测量且在规格范围内dt_binding_check YAML schema 验证BR2_EXTERNAL)结构化管理自定义包和驱动ftrace 函数追踪和事件追踪(trace-cmd record -p function_graph)perf 性能分析:采样热点、硬件计数器、调度延迟devcoredump 实现驱动级 crash dump 收集/proc 和 debugfs 接口实现运行时诊断信息导出CONFIG_MODULE_SIG)确保只加载可信模块/dev/mem 的访问MODULE_LICENSE("GPL") 和 EXPORT_SYMBOL_GPL~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.