[openib-general] SRP [PATCH 2/4] remove target

Ishai Rabinovitz ishai at mellanox.co.il
Mon Jun 5 08:34:33 PDT 2006


Add support to remove_target from sysfs.
Signed-off-by: Ishai Rabinovitz <ishai at mellanox.co.il>

Index: last_stable/drivers/infiniband/ulp/srp/ib_srp.c
===================================================================
--- last_stable.orig/drivers/infiniband/ulp/srp/ib_srp.c	2006-06-05 16:46:55.000000000 +0300
+++ last_stable/drivers/infiniband/ulp/srp/ib_srp.c	2006-06-05 17:11:11.000000000 +0300
@@ -1516,6 +1516,10 @@
 	return sprintf(buf, "%d\n", target->zero_req_lim);
 }
 
+static ssize_t srp_remove_target(struct class_device *cdev,
+				 const char *buf, size_t count);
+
+static CLASS_DEVICE_ATTR(remove_target, S_IWUSR, NULL, srp_remove_target);
 static CLASS_DEVICE_ATTR(id_ext,	S_IRUGO, show_id_ext,		NULL);
 static CLASS_DEVICE_ATTR(ioc_guid,	S_IRUGO, show_ioc_guid,		NULL);
 static CLASS_DEVICE_ATTR(service_id,	S_IRUGO, show_service_id,	NULL);
@@ -1524,6 +1528,7 @@
 static CLASS_DEVICE_ATTR(zero_req_lim,	S_IRUGO, show_zero_req_lim,	NULL);
 
 static struct class_device_attribute *srp_host_attrs[] = {
+	&class_device_attr_remove_target,
 	&class_device_attr_id_ext,
 	&class_device_attr_ioc_guid,
 	&class_device_attr_service_id,
@@ -1814,6 +1819,23 @@
 
 static CLASS_DEVICE_ATTR(add_target, S_IWUSR, NULL, srp_create_target);
 
+static ssize_t srp_remove_target(struct class_device *cdev,
+				 const char *buf, size_t count)
+{
+	int ret;
+	const char const remove_str[] = "remove";
+
+	if (strncmp(buf, "remove", sizeof(remove_str)))
+		return -EINVAL;
+
+	ret = _srp_remove_target(host_to_target(class_to_shost(cdev)));
+
+	if (ret)
+		return ret;
+
+	return count;
+}
+
 static ssize_t show_ibdev(struct class_device *class_dev, char *buf)
 {
 	struct srp_host *host =
-- 
Ishai Rabinovitz



More information about the general mailing list