forked from luck/tmp_suning_uos_patched
soundwire: bus: add unique bus id
Adding an unique id for each bus. Suggested-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com> Acked-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20200518174322.31561-4-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
90acca1d54
commit
dbb50c7a99
|
@ -9,6 +9,19 @@
|
|||
#include <linux/soundwire/sdw.h>
|
||||
#include "bus.h"
|
||||
|
||||
static DEFINE_IDA(sdw_ida);
|
||||
|
||||
static int sdw_get_id(struct sdw_bus *bus)
|
||||
{
|
||||
int rc = ida_alloc(&sdw_ida, GFP_KERNEL);
|
||||
|
||||
if (rc < 0)
|
||||
return rc;
|
||||
|
||||
bus->id = rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* sdw_bus_master_add() - add a bus Master instance
|
||||
* @bus: bus instance
|
||||
|
@ -29,6 +42,12 @@ int sdw_bus_master_add(struct sdw_bus *bus, struct device *parent,
|
|||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = sdw_get_id(bus);
|
||||
if (ret) {
|
||||
dev_err(bus->dev, "Failed to get bus id\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!bus->ops) {
|
||||
dev_err(bus->dev, "SoundWire Bus ops are not set\n");
|
||||
return -EINVAL;
|
||||
|
@ -144,6 +163,7 @@ void sdw_bus_master_delete(struct sdw_bus *bus)
|
|||
device_for_each_child(bus->dev, NULL, sdw_delete_slave);
|
||||
|
||||
sdw_bus_debugfs_exit(bus);
|
||||
ida_free(&sdw_ida, bus->id);
|
||||
}
|
||||
EXPORT_SYMBOL(sdw_bus_master_delete);
|
||||
|
||||
|
|
|
@ -789,6 +789,7 @@ struct sdw_master_ops {
|
|||
* struct sdw_bus - SoundWire bus
|
||||
* @dev: Master linux device
|
||||
* @link_id: Link id number, can be 0 to N, unique for each Master
|
||||
* @id: bus system-wide unique id
|
||||
* @slaves: list of Slaves on this bus
|
||||
* @assigned: Bitmap for Slave device numbers.
|
||||
* Bit set implies used number, bit clear implies unused number.
|
||||
|
@ -813,6 +814,7 @@ struct sdw_master_ops {
|
|||
struct sdw_bus {
|
||||
struct device *dev;
|
||||
unsigned int link_id;
|
||||
int id;
|
||||
struct list_head slaves;
|
||||
DECLARE_BITMAP(assigned, SDW_MAX_DEVICES);
|
||||
struct mutex bus_lock;
|
||||
|
|
Loading…
Reference in New Issue
Block a user