Skip to contentSkip to conversation

sound/arm/pxa2xx-ac97-lib.c:334 pxa2xx_ac97_hw_probe() warn: passing zero to 'PTR_ERR'

DISCUSSION Dan Carpenter 1 participant 1 message Apr 7

lore
Share & tools
lore

Dan Carpenter

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Peng Fan <[email protected]>
CC: Mark Brown <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   7ca6d1cfec80ebe46cc063f3284c5896c344d9a1
commit: c76d50b71e898694c946993eb3c77f50efa97254 ASoC: ac97: Convert to GPIO descriptors
date:   10 weeks ago

:::::: branch date: 4 hours ago
:::::: commit date: 10 weeks ago
config: microblaze-randconfig-r072-20260404 (https://download.01.org/0day-ci/archive/20260404/[email protected]/config)
compiler: microblaze-linux-gcc (GCC) 12.5.0
smatch: v0.5.0-9004-gb810ac53

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

| Fixes: c76d50b71e89 ("ASoC: ac97: Convert to GPIO descriptors")
| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
sound/arm/pxa2xx-ac97-lib.c:334 pxa2xx_ac97_hw_probe() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +334 sound/arm/pxa2xx-ac97-lib.c

9c63634221f6745 Dmitry Baryshkov 2008-09-10  319  
e21596bba143563 Bill Pemberton   2012-12-06  320  int pxa2xx_ac97_hw_probe(struct platform_device *dev)
9c63634221f6745 Dmitry Baryshkov 2008-09-10  321  {
9c63634221f6745 Dmitry Baryshkov 2008-09-10  322  	int ret;
2548e6c76ebfae0 Arnd Bergmann    2019-09-10  323  	int irq;
26ade896b6ba3fd Robert Jarzmik   2009-03-15  324  
8ff064521f97554 Arnd Bergmann    2019-09-18  325  	ac97_reg_base = devm_platform_ioremap_resource(dev, 0);
8ff064521f97554 Arnd Bergmann    2019-09-18  326  	if (IS_ERR(ac97_reg_base)) {
8ff064521f97554 Arnd Bergmann    2019-09-18  327  		dev_err(&dev->dev, "Missing MMIO resource\n");
8ff064521f97554 Arnd Bergmann    2019-09-18  328  		return PTR_ERR(ac97_reg_base);
8ff064521f97554 Arnd Bergmann    2019-09-18  329  	}
8ff064521f97554 Arnd Bergmann    2019-09-18  330  
be829277ef79aa6 Peng Fan         2026-01-22  331  	if (dev->dev.of_node) {
c76d50b71e89869 Peng Fan         2026-01-22  332  		/* Assert reset using GPIOD_OUT_HIGH, because reset is GPIO_ACTIVE_LOW */
c76d50b71e89869 Peng Fan         2026-01-22  333  		rst_gpio = devm_gpiod_get(&dev->dev, "reset", GPIOD_OUT_HIGH);
c76d50b71e89869 Peng Fan         2026-01-22 @334  		ret = PTR_ERR(rst_gpio);
c76d50b71e89869 Peng Fan         2026-01-22  335  		if (ret == -ENOENT)
be829277ef79aa6 Peng Fan         2026-01-22  336  			reset_gpio = -1;
c76d50b71e89869 Peng Fan         2026-01-22  337  		else if (ret)
c76d50b71e89869 Peng Fan         2026-01-22  338  			return ret;
c76d50b71e89869 Peng Fan         2026-01-22  339  		reset_gpio = desc_to_gpio(rst_gpio);
26ade896b6ba3fd Robert Jarzmik   2009-03-15  340  	} else {
26ade896b6ba3fd Robert Jarzmik   2009-03-15  341  		if (cpu_is_pxa27x())
26ade896b6ba3fd Robert Jarzmik   2009-03-15  342  			reset_gpio = 113;
26ade896b6ba3fd Robert Jarzmik   2009-03-15  343  	}
9c63634221f6745 Dmitry Baryshkov 2008-09-10  344  
9d1cf39be670976 Dmitry Baryshkov 2008-09-10  345  	if (cpu_is_pxa27x()) {
3b4bc7bccc78572 Mike Dunn        2013-01-07  346  		/*
3b4bc7bccc78572 Mike Dunn        2013-01-07  347  		 * This gpio is needed for a work-around to a bug in the ac97
3b4bc7bccc78572 Mike Dunn        2013-01-07  348  		 * controller during warm reset.  The direction and level is set
3b4bc7bccc78572 Mike Dunn        2013-01-07  349  		 * here so that it is an output driven high when switching from
3b4bc7bccc78572 Mike Dunn        2013-01-07  350  		 * AC97_nRESET alt function to generic gpio.
3b4bc7bccc78572 Mike Dunn        2013-01-07  351  		 */
c76d50b71e89869 Peng Fan         2026-01-22  352  		gpiod_set_consumer_name(rst_gpio, "pxa27x ac97 reset");
053fe0f166e540a Mike Dunn        2013-01-07  353  		pxa27x_configure_ac97reset(reset_gpio, false);
3b4bc7bccc78572 Mike Dunn        2013-01-07  354  
9c63634221f6745 Dmitry Baryshkov 2008-09-10  355  		ac97conf_clk = clk_get(&dev->dev, "AC97CONFCLK");
9c63634221f6745 Dmitry Baryshkov 2008-09-10  356  		if (IS_ERR(ac97conf_clk)) {
9c63634221f6745 Dmitry Baryshkov 2008-09-10  357  			ret = PTR_ERR(ac97conf_clk);
9c63634221f6745 Dmitry Baryshkov 2008-09-10  358  			ac97conf_clk = NULL;
796123368871e4a Dmitry Baryshkov 2009-01-05  359  			goto err_conf;
9c63634221f6745 Dmitry Baryshkov 2008-09-10  360  		}
9d1cf39be670976 Dmitry Baryshkov 2008-09-10  361  	}
9c63634221f6745 Dmitry Baryshkov 2008-09-10  362  
9c63634221f6745 Dmitry Baryshkov 2008-09-10  363  	ac97_clk = clk_get(&dev->dev, "AC97CLK");
9c63634221f6745 Dmitry Baryshkov 2008-09-10  364  	if (IS_ERR(ac97_clk)) {
9c63634221f6745 Dmitry Baryshkov 2008-09-10  365  		ret = PTR_ERR(ac97_clk);
9c63634221f6745 Dmitry Baryshkov 2008-09-10  366  		ac97_clk = NULL;
796123368871e4a Dmitry Baryshkov 2009-01-05  367  		goto err_clk;
9c63634221f6745 Dmitry Baryshkov 2008-09-10  368  	}
9c63634221f6745 Dmitry Baryshkov 2008-09-10  369  
4091d3425a2e494 Robert Jarzmik   2014-06-09  370  	ret = clk_prepare_enable(ac97_clk);
796123368871e4a Dmitry Baryshkov 2009-01-05  371  	if (ret)
796123368871e4a Dmitry Baryshkov 2009-01-05  372  		goto err_clk2;
796123368871e4a Dmitry Baryshkov 2009-01-05  373  
2548e6c76ebfae0 Arnd Bergmann    2019-09-10  374  	irq = platform_get_irq(dev, 0);
46cf1954de3f324 Yang Yingliang   2022-10-29  375  	if (irq < 0) {
46cf1954de3f324 Yang Yingliang   2022-10-29  376  		ret = irq;
2548e6c76ebfae0 Arnd Bergmann    2019-09-10  377  		goto err_irq;
46cf1954de3f324 Yang Yingliang   2022-10-29  378  	}
2548e6c76ebfae0 Arnd Bergmann    2019-09-10  379  
2548e6c76ebfae0 Arnd Bergmann    2019-09-10  380  	ret = request_irq(irq, pxa2xx_ac97_irq, 0, "AC97", NULL);
796123368871e4a Dmitry Baryshkov 2009-01-05  381  	if (ret < 0)
796123368871e4a Dmitry Baryshkov 2009-01-05  382  		goto err_irq;
796123368871e4a Dmitry Baryshkov 2009-01-05  383  
796123368871e4a Dmitry Baryshkov 2009-01-05  384  	return 0;
9c63634221f6745 Dmitry Baryshkov 2008-09-10  385  
9c63634221f6745 Dmitry Baryshkov 2008-09-10  386  err_irq:
8ff064521f97554 Arnd Bergmann    2019-09-18  387  	writel(readl(ac97_reg_base + GCR) | (GCR_ACLINK_OFF), ac97_reg_base + GCR);
796123368871e4a Dmitry Baryshkov 2009-01-05  388  err_clk2:
796123368871e4a Dmitry Baryshkov 2009-01-05  389  	clk_put(ac97_clk);
796123368871e4a Dmitry Baryshkov 2009-01-05  390  	ac97_clk = NULL;
796123368871e4a Dmitry Baryshkov 2009-01-05  391  err_clk:
9c63634221f6745 Dmitry Baryshkov 2008-09-10  392  	if (ac97conf_clk) {
9c63634221f6745 Dmitry Baryshkov 2008-09-10  393  		clk_put(ac97conf_clk);
9c63634221f6745 Dmitry Baryshkov 2008-09-10  394  		ac97conf_clk = NULL;
9c63634221f6745 Dmitry Baryshkov 2008-09-10  395  	}
796123368871e4a Dmitry Baryshkov 2009-01-05  396  err_conf:
9c63634221f6745 Dmitry Baryshkov 2008-09-10  397  	return ret;
9c63634221f6745 Dmitry Baryshkov 2008-09-10  398  }
9c63634221f6745 Dmitry Baryshkov 2008-09-10  399  EXPORT_SYMBOL_GPL(pxa2xx_ac97_hw_probe);
9c63634221f6745 Dmitry Baryshkov 2008-09-10  400  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki