The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* drivers/soundwire/bus_type.c:108 sdw_drv_probe() error: Calling ida_alloc_max() with a 'max' argument which is a power of 2. -1 missing?
@ 2025-12-15  8:55 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2025-12-15  8:55 UTC (permalink / raw)
  To: oe-kbuild, Charles Keepax
  Cc: lkp, oe-kbuild-all, linux-kernel, Vinod Koul,
	Pierre-Louis Bossart

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   9551a26f17d9445eed497bd7c639d48dfc3c0af4
commit: aab12022b076f0b385b7a9a78e1161bd2df5d1e3 soundwire: bus: Add internal slave ID and use for IRQs
date:   7 months ago
config: i386-randconfig-r073-20251212 (https://download.01.org/0day-ci/archive/20251213/202512131339.LMMvaF5G-lkp@intel.com/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 <lkp@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202512131339.LMMvaF5G-lkp@intel.com/

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

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

9251345dca24b6 Vinod Koul           2017-12-14   81  static int sdw_drv_probe(struct device *dev)
9251345dca24b6 Vinod Koul           2017-12-14   82  {
9251345dca24b6 Vinod Koul           2017-12-14   83  	struct sdw_slave *slave = dev_to_sdw_dev(dev);
9251345dca24b6 Vinod Koul           2017-12-14   84  	struct sdw_driver *drv = drv_to_sdw_driver(dev->driver);
9251345dca24b6 Vinod Koul           2017-12-14   85  	const struct sdw_device_id *id;
9251345dca24b6 Vinod Koul           2017-12-14   86  	int ret;
9251345dca24b6 Vinod Koul           2017-12-14   87  
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   88  	/*
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   89  	 * fw description is mandatory to bind
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   90  	 */
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   91  	if (!dev->fwnode)
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   92  		return -ENODEV;
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   93  
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   94  	if (!IS_ENABLED(CONFIG_ACPI) && !dev->of_node)
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   95  		return -ENODEV;
fcb9d730be1d30 Srinivas Kandagatla  2020-09-24   96  
9251345dca24b6 Vinod Koul           2017-12-14   97  	id = sdw_get_device_id(slave, drv);
9251345dca24b6 Vinod Koul           2017-12-14   98  	if (!id)
9251345dca24b6 Vinod Koul           2017-12-14   99  		return -ENODEV;
9251345dca24b6 Vinod Koul           2017-12-14  100  
9251345dca24b6 Vinod Koul           2017-12-14  101  	/*
9251345dca24b6 Vinod Koul           2017-12-14  102  	 * attach to power domain but don't turn on (last arg)
9251345dca24b6 Vinod Koul           2017-12-14  103  	 */
9251345dca24b6 Vinod Koul           2017-12-14  104  	ret = dev_pm_domain_attach(dev, false);
29ffcc88f2065f Ulf Hansson          2018-04-26  105  	if (ret)
29ffcc88f2065f Ulf Hansson          2018-04-26  106  		return ret;
29ffcc88f2065f Ulf Hansson          2018-04-26  107  
aab12022b076f0 Charles Keepax       2025-04-29 @108  	ret = ida_alloc_max(&slave->bus->slave_ida, SDW_FW_MAX_DEVICES, GFP_KERNEL);

The SDW_FW_MAX_DEVICES macro is used here and also in sdw_irq_create().

	bus->domain = irq_domain_create_linear(fwnode, SDW_FW_MAX_DEVICES, ...

The ida_alloc_max() function an inclusive max so probably this should be
"SDW_FW_MAX_DEVICES - 1".

aab12022b076f0 Charles Keepax       2025-04-29  109  	if (ret < 0) {
aab12022b076f0 Charles Keepax       2025-04-29  110  		dev_err(dev, "Failed to allocated ID: %d\n", ret);
aab12022b076f0 Charles Keepax       2025-04-29  111  		return ret;
aab12022b076f0 Charles Keepax       2025-04-29  112  	}
aab12022b076f0 Charles Keepax       2025-04-29  113  	slave->index = ret;
aab12022b076f0 Charles Keepax       2025-04-29  114  
9251345dca24b6 Vinod Koul           2017-12-14  115  	ret = drv->probe(slave, id);
9251345dca24b6 Vinod Koul           2017-12-14  116  	if (ret) {
9251345dca24b6 Vinod Koul           2017-12-14  117  		dev_pm_domain_detach(dev, false);
aab12022b076f0 Charles Keepax       2025-04-29  118  		ida_free(&slave->bus->slave_ida, slave->index);

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-12-15  8:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-15  8:55 drivers/soundwire/bus_type.c:108 sdw_drv_probe() error: Calling ida_alloc_max() with a 'max' argument which is a power of 2. -1 missing? Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox