drivers/soc/apple/dockchannel.c:240 dockchannel_init() warn: passing zero to 'dev_err_probe'
PATCH 14/21 drivers/soc/apple/dockchannel.c:240 dockchannel_init() warn: passing zero to 'dev_err_probe'
tree: https://github.com/AsahiLinux/linux bits/090-spi-hid head: 16871bb3228eaf55cbdb1dfb81c1cecec4ee0d52 commit: 7c1543b965b465df17e43246abe9ef43c4bd8358 [14/21] soc: apple: Add DockChannel driver config: mips-randconfig-r081-20231121 (https://download.01.org/0day-ci/archive/20231123/[email protected]/config) compiler: mips-linux-gcc (GCC) 13.2.0 reproduce: (https://download.01.org/0day-ci/archive/20231123/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
New smatch warnings:drivers/soc/apple/dockchannel.c:240 dockchannel_init() warn: passing zero to 'dev_err_probe' drivers/soc/apple/dockchannel.c:358 dockchannel_probe() warn: passing zero to 'dev_err_probe'
Old smatch warnings:drivers/soc/apple/dockchannel.c:246 dockchannel_init() warn: passing zero to 'dev_err_probe'
vim +/dev_err_probe +240 drivers/soc/apple/dockchannel.c
7c1543b965b465 Hector Martin 2022-07-08 212 struct dockchannel *dockchannel_init(struct platform_device *pdev)
7c1543b965b465 Hector Martin 2022-07-08 213 {
7c1543b965b465 Hector Martin 2022-07-08 214 struct device *dev = &pdev->dev;
7c1543b965b465 Hector Martin 2022-07-08 215 struct dockchannel *dockchannel;
7c1543b965b465 Hector Martin 2022-07-08 216 int ret;
7c1543b965b465 Hector Martin 2022-07-08 217
7c1543b965b465 Hector Martin 2022-07-08 218 dockchannel = devm_kzalloc(dev, sizeof(*dockchannel), GFP_KERNEL);
7c1543b965b465 Hector Martin 2022-07-08 219 if (!dockchannel)
7c1543b965b465 Hector Martin 2022-07-08 220 return ERR_PTR(-ENOMEM);
7c1543b965b465 Hector Martin 2022-07-08 221
7c1543b965b465 Hector Martin 2022-07-08 222 dockchannel->dev = dev;
7c1543b965b465 Hector Martin 2022-07-08 223 dockchannel->config_base = devm_platform_ioremap_resource_byname(pdev, "config");
7c1543b965b465 Hector Martin 2022-07-08 224 if (IS_ERR(dockchannel->config_base))
7c1543b965b465 Hector Martin 2022-07-08 225 return (__force void *)dockchannel->config_base;
7c1543b965b465 Hector Martin 2022-07-08 226
7c1543b965b465 Hector Martin 2022-07-08 227 dockchannel->data_base = devm_platform_ioremap_resource_byname(pdev, "data");
7c1543b965b465 Hector Martin 2022-07-08 228 if (IS_ERR(dockchannel->data_base))
7c1543b965b465 Hector Martin 2022-07-08 229 return (__force void *)dockchannel->data_base;
7c1543b965b465 Hector Martin 2022-07-08 230
7c1543b965b465 Hector Martin 2022-07-08 231 ret = of_property_read_u32(dev->of_node, "apple,fifo-size", &dockchannel->fifo_size);
7c1543b965b465 Hector Martin 2022-07-08 232 if (ret)
7c1543b965b465 Hector Martin 2022-07-08 233 return ERR_PTR(dev_err_probe(dev, ret, "Missing apple,fifo-size property"));
7c1543b965b465 Hector Martin 2022-07-08 234
7c1543b965b465 Hector Martin 2022-07-08 235 init_completion(&dockchannel->tx_comp);
7c1543b965b465 Hector Martin 2022-07-08 236 init_completion(&dockchannel->rx_comp);
7c1543b965b465 Hector Martin 2022-07-08 237
7c1543b965b465 Hector Martin 2022-07-08 238 dockchannel->tx_irq = platform_get_irq_byname(pdev, "tx");
7c1543b965b465 Hector Martin 2022-07-08 239 if (dockchannel->tx_irq <= 0) {Change this to < 0. platform_get_irq_byname() can never return zero.
7c1543b965b465 Hector Martin 2022-07-08 @240 return ERR_PTR(dev_err_probe(dev, dockchannel->tx_irq,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning.
7c1543b965b465 Hector Martin 2022-07-08 241 "Failed to get TX IRQ"));
7c1543b965b465 Hector Martin 2022-07-08 242 }
7c1543b965b465 Hector Martin 2022-07-08 243
7c1543b965b465 Hector Martin 2022-07-08 244 dockchannel->rx_irq = platform_get_irq_byname(pdev, "rx");
7c1543b965b465 Hector Martin 2022-07-08 245 if (dockchannel->rx_irq <= 0) {
7c1543b965b465 Hector Martin 2022-07-08 246 return ERR_PTR(dev_err_probe(dev, dockchannel->rx_irq,
7c1543b965b465 Hector Martin 2022-07-08 247 "Failed to get RX IRQ"));[ snip ]
7c1543b965b465 Hector Martin 2022-07-08 344 dcc->irq_base = devm_platform_ioremap_resource_byname(pdev, "irq"); 7c1543b965b465 Hector Martin 2022-07-08 345 if (IS_ERR(dcc->irq_base)) 7c1543b965b465 Hector Martin 2022-07-08 346 return PTR_ERR(dcc->irq_base); 7c1543b965b465 Hector Martin 2022-07-08 347 7c1543b965b465 Hector Martin 2022-07-08 348 writel_relaxed(0, dcc->irq_base + IRQ_MASK); 7c1543b965b465 Hector Martin 2022-07-08 349 writel_relaxed(~0, dcc->irq_base + IRQ_FLAG); 7c1543b965b465 Hector Martin 2022-07-08 350 7c1543b965b465 Hector Martin 2022-07-08 351 dcc->domain = irq_domain_add_linear(dev->of_node, DOCKCHANNEL_MAX_IRQ, 7c1543b965b465 Hector Martin 2022-07-08 352 &dockchannel_irq_domain_ops, dcc); 7c1543b965b465 Hector Martin 2022-07-08 353 if (!dcc->domain) 7c1543b965b465 Hector Martin 2022-07-08 354 return -ENOMEM; 7c1543b965b465 Hector Martin 2022-07-08 355 7c1543b965b465 Hector Martin 2022-07-08 356 dcc->irq = platform_get_irq(pdev, 0); 7c1543b965b465 Hector Martin 2022-07-08 357 if (dcc->irq <= 0)
7c1543b965b465 Hector Martin 2022-07-08 @358 return dev_err_probe(dev, dcc->irq, "Failed to get IRQ");
Same thing. platform_get_irq() can't return zero.
Prior to 2006 these did used to return zero and unfortunately, there are some legacy get_irq() functions which still do return zero. I think the trend is to slowly update them. Read my blog for more details:
https://staticthinking.wordpress.com/2023/08/07/writing-a-check-for-zero-irq-error-codes/
7c1543b965b465 Hector Martin 2022-07-08 359 7c1543b965b465 Hector Martin 2022-07-08 360 irq_set_handler_data(dcc->irq, dcc); 7c1543b965b465 Hector Martin 2022-07-08 361 irq_set_chained_handler(dcc->irq, dockchannel_irq); 7c1543b965b465 Hector Martin 2022-07-08 362 7c1543b965b465 Hector Martin 2022-07-08 363 for_each_child_of_node(dev->of_node, child) 7c1543b965b465 Hector Martin 2022-07-08 364 of_platform_device_create(child, NULL, dev); 7c1543b965b465 Hector Martin 2022-07-08 365 7c1543b965b465 Hector Martin 2022-07-08 366 return 0; 7c1543b965b465 Hector Martin 2022-07-08 367 }
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki