diff options
author | Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> | 2023-07-31 17:13:32 +0800 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2023-08-11 07:59:25 +0100 |
commit | 39d80b0e5fed2c32f66093fead626358b7106974 (patch) | |
tree | 3bc1f056e4bd3054a4d9e47ff92578a770ef9309 /drivers/soundwire/bus.c | |
parent | 23afc82fb22bccd3f1d2a856d3eccb70453f33b0 (diff) |
soundwire: bus: add callbacks for device_number allocation
Rather than add logic in the core for vendor-specific usages, add
callbacks for vendor-specific device_number allocation and release.
This patch only moves the existing IDA-based allocator used only by
Intel to the intel_auxdevice.c file and does not change the
functionality. Follow-up patches will extend the behavior by modifying
the Intel callbacks.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Link: https://lore.kernel.org/r/20230731091333.3593132-3-yung-chuan.liao@linux.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/soundwire/bus.c')
-rw-r--r-- | drivers/soundwire/bus.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/drivers/soundwire/bus.c b/drivers/soundwire/bus.c index bdd0fed45a8d..0e1e4bedc708 100644 --- a/drivers/soundwire/bus.c +++ b/drivers/soundwire/bus.c @@ -12,7 +12,6 @@ #include "sysfs_local.h" static DEFINE_IDA(sdw_bus_ida); -static DEFINE_IDA(sdw_peripheral_ida); static int sdw_get_id(struct sdw_bus *bus) { @@ -168,8 +167,8 @@ static int sdw_delete_slave(struct device *dev, void *data) if (slave->dev_num) { /* clear dev_num if assigned */ clear_bit(slave->dev_num, bus->assigned); - if (bus->dev_num_ida_min) - ida_free(&sdw_peripheral_ida, slave->dev_num); + if (bus->ops && bus->ops->put_device_num) + bus->ops->put_device_num(bus, slave); } list_del_init(&slave->node); mutex_unlock(&bus->bus_lock); @@ -710,16 +709,15 @@ EXPORT_SYMBOL(sdw_compare_devid); /* called with bus_lock held */ static int sdw_get_device_num(struct sdw_slave *slave) { + struct sdw_bus *bus = slave->bus; int bit; - if (slave->bus->dev_num_ida_min) { - bit = ida_alloc_range(&sdw_peripheral_ida, - slave->bus->dev_num_ida_min, SDW_MAX_DEVICES, - GFP_KERNEL); + if (bus->ops && bus->ops->get_device_num) { + bit = bus->ops->get_device_num(bus, slave); if (bit < 0) goto err; } else { - bit = find_first_zero_bit(slave->bus->assigned, SDW_MAX_DEVICES); + bit = find_first_zero_bit(bus->assigned, SDW_MAX_DEVICES); if (bit == SDW_MAX_DEVICES) { bit = -ENODEV; goto err; @@ -730,7 +728,7 @@ static int sdw_get_device_num(struct sdw_slave *slave) * Do not update dev_num in Slave data structure here, * Update once program dev_num is successful */ - set_bit(bit, slave->bus->assigned); + set_bit(bit, bus->assigned); err: return bit; |