[PATCH 05/10] staging: unisys: move chipsetready to sysfs

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

 



Move the chipsetready proc entry to sysfs under a new directory guest. This
entry is used by Unisys application software on the guest to acknowledge
completion of specific events for integration purposes, but these
acknowledgements are not required for the guest to operate correctly.

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

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index d4987b1..a5f992d 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_CHIPSET_PROC_ENTRY_FN "chipsetready"
-static struct proc_dir_entry *chipset_proc_dir;
-
 #define VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN "parahotplug"
 static struct proc_dir_entry *parahotplug_proc_dir;
 
@@ -324,6 +321,9 @@ static ssize_t show_remaining_steps(struct device *dev,
 static ssize_t store_remaining_steps(struct device *dev,
 	struct device_attribute *attr, const char *buf, size_t count);
 
+static ssize_t store_chipsetready(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);
 
@@ -337,6 +337,8 @@ static DEVICE_ATTR(textid, S_IRUSR | S_IWUSR, show_textid, store_textid);
 static DEVICE_ATTR(remaining_steps, S_IRUSR | S_IWUSR, show_remaining_steps,
 	store_remaining_steps);
 
+static DEVICE_ATTR(chipsetready, S_IWUSR, NULL, store_chipsetready);
+
 static struct attribute *visorchipset_install_attrs[] = {
 	&dev_attr_toolaction.attr,
 	&dev_attr_boottotool.attr,
@@ -351,8 +353,19 @@ static struct attribute_group visorchipset_install_group = {
 	.attrs = visorchipset_install_attrs
 };
 
+static struct attribute *visorchipset_guest_attrs[] = {
+	&dev_attr_chipsetready.attr,
+	NULL
+};
+
+static struct attribute_group visorchipset_guest_group = {
+	.name = "guest",
+	.attrs = visorchipset_guest_attrs
+};
+
 static const struct attribute_group *visorchipset_dev_groups[] = {
 	&visorchipset_install_group,
+	&visorchipset_guest_group,
 	NULL
 };
 
@@ -2466,36 +2479,20 @@ visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln)
 	kmem_cache_free(pool, p);
 }
 
-#define gettoken(bufp) strsep(bufp, " -\t\n")
-
-static ssize_t
-chipset_proc_write(struct file *file, const char __user *buffer,
-		   size_t count, loff_t *ppos)
+ssize_t store_chipsetready(struct device *dev, struct device_attribute *attr,
+		const char *buf, size_t count)
 {
-	char buf[512];
-	char *token, *p;
-
-	if (count > sizeof(buf) - 1) {
-		LOGERR("chipset_proc_write: count (%d) exceeds size of buffer (%d)",
-		     (int) count, (int) sizeof(buffer));
-		return -EINVAL;
-	}
-	if (copy_from_user(buf, buffer, count)) {
-		LOGERR("chipset_proc_write: copy_from_user failed");
-		return -EFAULT;
-	}
-	buf[count] = '\0';
+	char *token, *p = (char *)buf;
 
-	p = buf;
-	token = gettoken(&p);
+	token = strsep(&p, " -\t\n");
 
 	if (strcmp(token, "CALLHOMEDISK_MOUNTED") == 0) {
-		token = gettoken(&p);
+		token = strsep(&p, " -\t\n");
 		/* The Call Home Disk has been mounted */
 		if (strcmp(token, "0") == 0)
 			chipset_events[0] = 1;
 	} else if (strcmp(token, "MODULES_LOADED") == 0) {
-		token = gettoken(&p);
+		token = strsep(&p, " -\t\n");
 		/* All modules for the partition have been loaded */
 		if (strcmp(token, "0") == 0)
 			chipset_events[1] = 1;
@@ -2505,7 +2502,8 @@ chipset_proc_write(struct file *file, const char __user *buffer,
 		return -1;
 	} else {
 		/* Unsupported event specified */
-		LOGERR("%s is an invalid event for sending CHIPSET_READY response",		     token);
+		LOGERR("%s is an invalid event for sending CHIPSET_READY response",
+			token);
 		return -1;
 	}
 
@@ -2519,12 +2517,6 @@ visorchipset_proc_read_writeonly(struct file *file, char __user *buf,
 	return 0;
 }
 
-static const struct file_operations chipset_proc_fops = {
-	.owner = THIS_MODULE,
-	.read = visorchipset_proc_read_writeonly,
-	.write = chipset_proc_write,
-};
-
 static int __init
 visorchipset_init(void)
 {
@@ -2580,8 +2572,6 @@ visorchipset_init(void)
 
 	memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
 
-	chipset_proc_dir = proc_create(VISORCHIPSET_CHIPSET_PROC_ENTRY_FN,
-				       0644, ProcDir, &chipset_proc_fops);
 	memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
 
 	parahotplug_proc_dir =
@@ -2685,10 +2675,6 @@ visorchipset_exit(void)
 	}
 	memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
 
-	if (chipset_proc_dir) {
-		remove_proc_entry(VISORCHIPSET_CHIPSET_PROC_ENTRY_FN, ProcDir);
-		chipset_proc_dir = NULL;
-	}
 	memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
 
 	if (parahotplug_proc_dir) {
-- 
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