This adds a helper to find a se_device by dev_index. It will be used in the next patches so tcmu's netlink interface can execute commands on specific devices. Signed-off-by: Mike Christie <mchristi@xxxxxxxxxx> --- drivers/target/target_core_device.c | 11 +++++++++++ include/target/target_core_backend.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index d4090f7..9f2a527 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -880,6 +880,17 @@ sector_t target_to_linux_sector(struct se_device *dev, sector_t lb) } EXPORT_SYMBOL(target_to_linux_sector); +struct se_device *target_find_device(int id) +{ + struct se_device *dev; + + mutex_lock(&g_device_mutex); + dev = idr_find(&devices_idr, id); + mutex_unlock(&g_device_mutex); + return dev; +} +EXPORT_SYMBOL(target_find_device); + void target_init_device_idr(void) { idr_init(&devices_idr); diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index b760711..3f015ab 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -105,6 +105,8 @@ sense_reason_t transport_generic_map_mem_to_cmd(struct se_cmd *, sense_reason_t passthrough_parse_cdb(struct se_cmd *cmd, sense_reason_t (*exec_cmd)(struct se_cmd *cmd)); +struct se_device *target_find_device(int id); + bool target_sense_desc_format(struct se_device *dev); sector_t target_to_linux_sector(struct se_device *dev, sector_t lb); bool target_configure_unmap_from_queue(struct se_dev_attrib *attrib, -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html