[RFC PATCH 7/9] target: add helper to iterate over devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This just adds a wrapper around idr_for_each so the xcopy
code can loop over the devices in the next patch.

Signed-off-by: Mike Christie <mchristi@xxxxxxxxxx>
---
 drivers/target/target_core_device.c   | 10 ++++++++++
 drivers/target/target_core_internal.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 9f2a527..eea52732 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -891,6 +891,16 @@ struct se_device *target_find_device(int id)
 }
 EXPORT_SYMBOL(target_find_device);
 
+int target_for_each_device(int (*fn)(int id, void *p, void *data), void *data)
+{
+	int ret;
+
+	mutex_lock(&g_device_mutex);
+	ret = idr_for_each(&devices_idr, fn, data);
+	mutex_unlock(&g_device_mutex);
+	return ret;
+}
+
 void target_init_device_idr(void)
 {
 	idr_init(&devices_idr);
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
index dfa923b..605e25b 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -87,6 +87,8 @@ void	core_dev_free_initiator_node_lun_acl(struct se_portal_group *,
 struct se_device *target_alloc_device(struct se_hba *hba, const char *name);
 int	target_configure_device(struct se_device *dev);
 void	target_free_device(struct se_device *);
+int	target_for_each_device(int (*fn)(int id, void *p, void *data),
+			       void *data);
 
 /* target_core_configfs.c */
 void	target_setup_backend_cits(struct target_backend *);
-- 
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



[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux