diff options
author | Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> | 2023-07-31 12:13:32 +0300 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2023-08-11 09:59:25 +0300 |
commit | 39d80b0e5fed2c32f66093fead626358b7106974 (patch) | |
tree | 3bc1f056e4bd3054a4d9e47ff92578a770ef9309 /drivers/soundwire/intel_auxdevice.c | |
parent | 23afc82fb22bccd3f1d2a856d3eccb70453f33b0 (diff) | |
download | linux-39d80b0e5fed2c32f66093fead626358b7106974.tar.xz |
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/intel_auxdevice.c')
-rw-r--r-- | drivers/soundwire/intel_auxdevice.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/soundwire/intel_auxdevice.c b/drivers/soundwire/intel_auxdevice.c index 3e7ca4a4964a..65cb3e7b7d25 100644 --- a/drivers/soundwire/intel_auxdevice.c +++ b/drivers/soundwire/intel_auxdevice.c @@ -125,6 +125,20 @@ static int intel_prop_read(struct sdw_bus *bus) return 0; } +static DEFINE_IDA(intel_peripheral_ida); + +static int intel_get_device_num_ida(struct sdw_bus *bus, struct sdw_slave *slave) +{ + return ida_alloc_range(&intel_peripheral_ida, + INTEL_DEV_NUM_IDA_MIN, SDW_MAX_DEVICES, + GFP_KERNEL); +} + +static void intel_put_device_num_ida(struct sdw_bus *bus, struct sdw_slave *slave) +{ + return ida_free(&intel_peripheral_ida, slave->dev_num); +} + static struct sdw_master_ops sdw_intel_ops = { .read_prop = intel_prop_read, .override_adr = sdw_dmi_override_adr, @@ -134,6 +148,8 @@ static struct sdw_master_ops sdw_intel_ops = { .pre_bank_switch = generic_pre_bank_switch, .post_bank_switch = generic_post_bank_switch, .read_ping_status = cdns_read_ping_status, + .get_device_num = intel_get_device_num_ida, + .put_device_num = intel_put_device_num_ida, .new_peripheral_assigned = generic_new_peripheral_assigned, }; @@ -167,7 +183,6 @@ static int intel_link_probe(struct auxiliary_device *auxdev, cdns->msg_count = 0; bus->link_id = auxdev->id; - bus->dev_num_ida_min = INTEL_DEV_NUM_IDA_MIN; bus->clk_stop_timeout = 1; sdw_cdns_probe(cdns); |