[PATCH 06/10] staging: unisys: move parahotplug to sysfs

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

 



Move the /proc/visorchipset/parahotplug interface to sysfs under
/sys/devices/platform/visorchipset/guest/parahotplug.

The parahotplug interface is used to deal with recovery situations on s-Par
guest partitions. The command service partition will send a message to a guest
when a device that guest is using needs to be temporarily removed. The message
triggers a udev event that will cause a recovery script to run. When that
script has completed its work, it will write to the parahotplug interface to
send a message back to Command indicating that it is safe to remove the device.

Signed-off-by: Benjamin Romer <benjamin.romer@xxxxxxxxxx>
---
 .../unisys/visorchipset/visorchipset_main.c        | 49 ++++++----------------
 1 file changed, 12 insertions(+), 37 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index a5f992d..a82a5e7 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -130,9 +130,6 @@ static MYPROCTYPE *PartitionType;
 #define VISORCHIPSET_DIAG_PROC_ENTRY_FN "diagdump"
 static struct proc_dir_entry *diag_proc_dir;
 
-#define VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN "parahotplug"
-static struct proc_dir_entry *parahotplug_proc_dir;
-
 static LIST_HEAD(BusInfoList);
 static LIST_HEAD(DevInfoList);
 
@@ -324,6 +321,9 @@ static ssize_t store_remaining_steps(struct device *dev,
 static ssize_t store_chipsetready(struct device *dev,
 		struct device_attribute *attr, const char *buf, size_t count);
 
+static ssize_t store_parahotplug(struct device *dev,
+		struct device_attribute *attr, const char *buf, size_t count);
+
 static DEVICE_ATTR(toolaction, S_IRUSR | S_IWUSR, show_toolaction,
 	store_toolaction);
 
@@ -339,6 +339,8 @@ static DEVICE_ATTR(remaining_steps, S_IRUSR | S_IWUSR, show_remaining_steps,
 
 static DEVICE_ATTR(chipsetready, S_IWUSR, NULL, store_chipsetready);
 
+static DEVICE_ATTR(parahotplug, S_IWUSR, NULL, store_parahotplug);
+
 static struct attribute *visorchipset_install_attrs[] = {
 	&dev_attr_toolaction.attr,
 	&dev_attr_boottotool.attr,
@@ -355,6 +357,7 @@ static struct attribute_group visorchipset_install_group = {
 
 static struct attribute *visorchipset_guest_attrs[] = {
 	&dev_attr_chipsetready.attr,
+	&dev_attr_parahotplug.attr,
 	NULL
 };
 
@@ -1871,30 +1874,17 @@ parahotplug_process_message(CONTROLVM_MESSAGE *inmsg)
 
 /*
  * Gets called when the udev script writes to
- * /proc/visorchipset/parahotplug.  Expects input in the form of "<id>
- * <active>" where <id> is the identifier passed to the script that
- * matches a request on the request list, and <active> is 0 or 1
- * indicating whether the device is now enabled or not.
+ * /sys/devices/platform/visorchipset/guest/parahotplug.
+ * Expects input in the form of "<id> <active>" where <id> is the identifier
+ * passed to the script that matches a request on the request list, and <active>
+ * is 0 or 1 indicating whether the device is now enabled or not.
  */
-static ssize_t
-parahotplug_proc_write(struct file *file, const char __user *buffer,
-		       size_t count, loff_t *ppos)
+ssize_t store_parahotplug(struct device *dev, struct device_attribute *attr,
+		const char *buf, size_t count)
 {
-	char buf[64];
 	uint id;
 	ushort active;
 
-	if (count > sizeof(buf) - 1) {
-		LOGERR("parahotplug_proc_write: count (%d) exceeds size of buffer (%d)",
-		     (int) count, (int) sizeof(buf));
-		return -EINVAL;
-	}
-	if (copy_from_user(buf, buffer, count)) {
-		LOGERR("parahotplug_proc_write: copy_from_user failed");
-		return -EFAULT;
-	}
-	buf[count] = '\0';
-
 	if (sscanf(buf, "%u %hu", &id, &active) != 2) {
 		id = 0;
 		active = 0;
@@ -1910,12 +1900,6 @@ parahotplug_proc_write(struct file *file, const char __user *buffer,
 	return count;
 }
 
-static const struct file_operations parahotplug_proc_fops = {
-	.owner = THIS_MODULE,
-	.read = visorchipset_proc_read_writeonly,
-	.write = parahotplug_proc_write,
-};
-
 /* Process a controlvm message.
  * Return result:
  *    FALSE - this function will return FALSE only in the case where the
@@ -2574,9 +2558,6 @@ visorchipset_init(void)
 
 	memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
 
-	parahotplug_proc_dir =
-	    proc_create(VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN, 0200,
-			ProcDir, &parahotplug_proc_fops);
 	memset(&g_DelDumpMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
 
 	Putfile_buffer_list_pool =
@@ -2677,12 +2658,6 @@ visorchipset_exit(void)
 
 	memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
 
-	if (parahotplug_proc_dir) {
-		remove_proc_entry(VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN,
-				  ProcDir);
-		parahotplug_proc_dir = NULL;
-	}
-
 	memset(&g_DelDumpMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
 
 	proc_DeInit();
-- 
1.9.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux