Skip to contentSkip to conversation

drivers/soundwire/bus_type.c:102 sdw_bus_probe() error: Calling ida_alloc_max() with a 'max' argument which is a power of 2. -1 missing?

PATCH kernel test robot 1 participant 1 message Dec 23, 2025

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw

BCC: [email protected]
CC: [email protected]
TO: "Uwe Kleine-König" <[email protected]>
CC: Vinod Koul <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vkoul/soundwire.git next
head:   c6f1e99ab03c5a94ed6389f5930e91f274b3ba67
commit: 866160a51f5586d53e17ceab36029c8805ffea28 [5/7] soundwire: Use bus methods for .probe(), .remove() and .shutdown()

:::::: branch date: 13 hours ago
:::::: commit date: 13 hours ago
config: i386-randconfig-141-20251224 (https://download.01.org/0day-ci/archive/20251224/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0

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]/

smatch warnings:
drivers/soundwire/bus_type.c:102 sdw_bus_probe() error: Calling ida_alloc_max() with a 'max' argument which is a power of 2. -1 missing?

vim +/max +102 drivers/soundwire/bus_type.c

9251345dca24b6 Vinod Koul 2017-12-14 74
866160a51f5586 Uwe Kleine-König 2025-12-15 75 static int sdw_bus_probe(struct device *dev)

9251345dca24b6 Vinod Koul           2017-12-14   76  {
9251345dca24b6 Vinod Koul           2017-12-14   77  	struct sdw_slave *slave = dev_to_sdw_dev(dev);
9251345dca24b6 Vinod Koul           2017-12-14   78  	struct sdw_driver *drv = drv_to_sdw_driver(dev->driver);
9251345dca24b6 Vinod Koul           2017-12-14   79  	const struct sdw_device_id *id;
9251345dca24b6 Vinod Koul           2017-12-14   80  	int ret;
9251345dca24b6 Vinod Koul           2017-12-14   81  
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   82  	/*
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   83  	 * fw description is mandatory to bind
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   84  	 */
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   85  	if (!dev->fwnode)
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   86  		return -ENODEV;
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   87  
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   88  	if (!IS_ENABLED(CONFIG_ACPI) && !dev->of_node)
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   89  		return -ENODEV;
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   90  
9251345dca24b6 Vinod Koul           2017-12-14   91  	id = sdw_get_device_id(slave, drv);
9251345dca24b6 Vinod Koul           2017-12-14   92  	if (!id)
9251345dca24b6 Vinod Koul           2017-12-14   93  		return -ENODEV;
9251345dca24b6 Vinod Koul           2017-12-14   94  
9251345dca24b6 Vinod Koul           2017-12-14   95  	/*
9251345dca24b6 Vinod Koul           2017-12-14   96  	 * attach to power domain but don't turn on (last arg)
9251345dca24b6 Vinod Koul           2017-12-14   97  	 */
d42c7c6fd66a6e Claudiu Beznea       2025-07-03   98  	ret = dev_pm_domain_attach(dev, 0);
29ffcc88f2065f Ulf Hansson          2018-04-26   99  	if (ret)
29ffcc88f2065f Ulf Hansson          2018-04-26  100  		return ret;
29ffcc88f2065f Ulf Hansson          2018-04-26  101  
aab12022b076f0 Charles Keepax       2025-04-29 @102  	ret = ida_alloc_max(&slave->bus->slave_ida, SDW_FW_MAX_DEVICES, GFP_KERNEL);
aab12022b076f0 Charles Keepax       2025-04-29  103  	if (ret < 0) {
aab12022b076f0 Charles Keepax       2025-04-29  104  		dev_err(dev, "Failed to allocated ID: %d\n", ret);
aab12022b076f0 Charles Keepax       2025-04-29  105  		return ret;
aab12022b076f0 Charles Keepax       2025-04-29  106  	}
aab12022b076f0 Charles Keepax       2025-04-29  107  	slave->index = ret;
aab12022b076f0 Charles Keepax       2025-04-29  108  
9251345dca24b6 Vinod Koul           2017-12-14  109  	ret = drv->probe(slave, id);
9251345dca24b6 Vinod Koul           2017-12-14  110  	if (ret) {
aab12022b076f0 Charles Keepax       2025-04-29  111  		ida_free(&slave->bus->slave_ida, slave->index);
9251345dca24b6 Vinod Koul           2017-12-14  112  		return ret;
29ffcc88f2065f Ulf Hansson          2018-04-26  113  	}
56d4fe31af77f6 Vinod Koul           2017-12-14  114  
3dca1f89ae3455 Richard Fitzgerald   2023-01-23  115  	mutex_lock(&slave->sdw_dev_lock);
3dca1f89ae3455 Richard Fitzgerald   2023-01-23  116  
56d4fe31af77f6 Vinod Koul           2017-12-14  117  	/* device is probed so let's read the properties now */
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  118  	if (drv->ops && drv->ops->read_prop)
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  119  		drv->ops->read_prop(slave);
56d4fe31af77f6 Vinod Koul           2017-12-14  120  
3b6c4a11bf2b81 Charles Keepax       2023-09-20  121  	if (slave->prop.use_domain_irq)
3b6c4a11bf2b81 Charles Keepax       2023-09-20  122  		sdw_irq_create_mapping(slave);
12a95123bfe1dd Lucas Tanure         2023-08-04  123  
f88c1afe338edb Greg Kroah-Hartman   2024-01-30  124  	/* init the dynamic sysfs attributes we need */
f88c1afe338edb Greg Kroah-Hartman   2024-01-30  125  	ret = sdw_slave_sysfs_dpn_init(slave);
bcac59029955ae Pierre-Louis Bossart 2020-05-19  126  	if (ret < 0)
663229e2425588 Johan Hovold         2024-07-12  127  		dev_warn(dev, "failed to initialise sysfs: %d\n", ret);
bcac59029955ae Pierre-Louis Bossart 2020-05-19  128  
56d4fe31af77f6 Vinod Koul           2017-12-14  129  	/*
56d4fe31af77f6 Vinod Koul           2017-12-14  130  	 * Check for valid clk_stop_timeout, use DisCo worst case value of
56d4fe31af77f6 Vinod Koul           2017-12-14  131  	 * 300ms
56d4fe31af77f6 Vinod Koul           2017-12-14  132  	 *
56d4fe31af77f6 Vinod Koul           2017-12-14  133  	 * TODO: check the timeouts and driver removal case
56d4fe31af77f6 Vinod Koul           2017-12-14  134  	 */
56d4fe31af77f6 Vinod Koul           2017-12-14  135  	if (slave->prop.clk_stop_timeout == 0)
56d4fe31af77f6 Vinod Koul           2017-12-14  136  		slave->prop.clk_stop_timeout = 300;
56d4fe31af77f6 Vinod Koul           2017-12-14  137  
56d4fe31af77f6 Vinod Koul           2017-12-14  138  	slave->bus->clk_stop_timeout = max_t(u32, slave->bus->clk_stop_timeout,
56d4fe31af77f6 Vinod Koul           2017-12-14  139  					     slave->prop.clk_stop_timeout);
56d4fe31af77f6 Vinod Koul           2017-12-14  140  
2140b66b5d3ecf Pierre-Louis Bossart 2020-01-14  141  	slave->probed = true;
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  142  
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  143  	/*
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  144  	 * if the probe happened after the bus was started, notify the codec driver
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  145  	 * of the current hardware status to e.g. start the initialization.
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  146  	 * Errors are only logged as warnings to avoid failing the probe.
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  147  	 */
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  148  	if (drv->ops && drv->ops->update_status) {
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  149  		ret = drv->ops->update_status(slave, slave->status);
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  150  		if (ret < 0)
663229e2425588 Johan Hovold         2024-07-12  151  			dev_warn(dev, "failed to update status at probe: %d\n", ret);
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  152  	}
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  153  
bd29c00edd0a5d Pierre-Louis Bossart 2022-06-21  154  	mutex_unlock(&slave->sdw_dev_lock);
2140b66b5d3ecf Pierre-Louis Bossart 2020-01-14  155  
2140b66b5d3ecf Pierre-Louis Bossart 2020-01-14  156  	dev_dbg(dev, "probe complete\n");
2140b66b5d3ecf Pierre-Louis Bossart 2020-01-14  157  
56d4fe31af77f6 Vinod Koul           2017-12-14  158  	return 0;
9251345dca24b6 Vinod Koul           2017-12-14  159  }
9251345dca24b6 Vinod Koul           2017-12-14  160  

:::::: The code at line 102 was first introduced by commit
:::::: aab12022b076f0b385b7a9a78e1161bd2df5d1e3 soundwire: bus: Add internal slave ID and use for IRQs

:::::: TO: Charles Keepax <[email protected]> :::::: CC: Vinod Koul <[email protected]>

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki