Hello Yulin Lu,
Commit 5b797bcc00ef ("pinctrl: eswin: Add EIC7700 pinctrl driver")
from Jun 12, 2025 (linux-next), leads to the following Smatch static
checker warning:
drivers/pinctrl/pinctrl-eic7700.c:638 eic7700_pinctrl_probe()
warn: passing zero to 'PTR_ERR'
drivers/pinctrl/pinctrl-eic7700.c
619 static int eic7700_pinctrl_probe(struct platform_device *pdev)
620 {
621 struct device *dev = &pdev->dev;
622 struct pinctrl_dev *pctldev;
623 struct eic7700_pinctrl *pc;
624 struct regulator *regulator;
625 u32 rgmii0_mode, rgmii1_mode;
626 int ret, voltage;
627
628 pc = devm_kzalloc(dev, struct_size(pc, functions, EIC7700_FUNCTIONS_COUNT), GFP_KERNEL);
629 if (!pc)
630 return -ENOMEM;
631
632 pc->base = devm_platform_ioremap_resource(pdev, 0);
633 if (IS_ERR(pc->base))
634 return PTR_ERR(pc->base);
635
636 regulator = devm_regulator_get(dev, "vrgmii");
637 if (IS_ERR_OR_NULL(regulator)) {
--> 638 return dev_err_probe(dev, PTR_ERR(regulator),
devm_regulator_get() will return NULL if CONFIG_REGULATOR is disabled.
PTR_ERR(NULL) is success.
639 "failed to get vrgmii regulator\n");
640 }
641
642 voltage = regulator_get_voltage(regulator);
643 if (voltage < 0) {
644 return dev_err_probe(&pdev->dev, voltage,
645 "Failed to get voltage from regulator\n");
If CONFIG_REGULATOR is disabled then this will return negative. So this
driver can't work without a regulator. Ideally the KConfig would enforce
that so we don't build drivers which can't work.
In that case the if (IS_ERR_OR_NULL()) check should be changed to
if (IS_ERR()) {. See my blog for more details:
https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/
646 }
647
648 rgmii0_mode = readl_relaxed(pc->base + EIC7700_RGMII0_SEL_MODE);
regards,
dan carpenter