aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Romer <benjamin.romer@unisys.com>2014-07-24 14:08:43 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-24 18:06:44 -0400
commit18b87ed1d041e7b1162481e38e2dc5a87b9a1689 (patch)
tree33e2840a12e91d75f284f0066c93cbe5b6a6ac03
parent422af17c67b8ea2bcf39b6f6db7341f5b62c1b12 (diff)
staging: unisys: move chipsetready to sysfs
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. The store function is simplified as well, to use scanf() instead of copying the buffer and using strsep(). Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/unisys/visorchipset/visorchipset_main.c76
1 files changed, 24 insertions, 52 deletions
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index 14eb0ab93b71..4211731c5dd3 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -129,9 +129,6 @@ static MYPROCTYPE *PartitionType;
129#define VISORCHIPSET_DIAG_PROC_ENTRY_FN "diagdump" 129#define VISORCHIPSET_DIAG_PROC_ENTRY_FN "diagdump"
130static struct proc_dir_entry *diag_proc_dir; 130static struct proc_dir_entry *diag_proc_dir;
131 131
132#define VISORCHIPSET_CHIPSET_PROC_ENTRY_FN "chipsetready"
133static struct proc_dir_entry *chipset_proc_dir;
134
135#define VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN "parahotplug" 132#define VISORCHIPSET_PARAHOTPLUG_PROC_ENTRY_FN "parahotplug"
136static struct proc_dir_entry *parahotplug_proc_dir; 133static struct proc_dir_entry *parahotplug_proc_dir;
137 134
@@ -323,6 +320,10 @@ static ssize_t remaining_steps_store(struct device *dev,
323 struct device_attribute *attr, const char *buf, size_t count); 320 struct device_attribute *attr, const char *buf, size_t count);
324static DEVICE_ATTR_RW(remaining_steps); 321static DEVICE_ATTR_RW(remaining_steps);
325 322
323static ssize_t chipsetready_store(struct device *dev,
324 struct device_attribute *attr, const char *buf, size_t count);
325static DEVICE_ATTR_WO(chipsetready);
326
326static struct attribute *visorchipset_install_attrs[] = { 327static struct attribute *visorchipset_install_attrs[] = {
327 &dev_attr_toolaction.attr, 328 &dev_attr_toolaction.attr,
328 &dev_attr_boottotool.attr, 329 &dev_attr_boottotool.attr,
@@ -337,8 +338,19 @@ static struct attribute_group visorchipset_install_group = {
337 .attrs = visorchipset_install_attrs 338 .attrs = visorchipset_install_attrs
338}; 339};
339 340
341static struct attribute *visorchipset_guest_attrs[] = {
342 &dev_attr_chipsetready.attr,
343 NULL
344};
345
346static struct attribute_group visorchipset_guest_group = {
347 .name = "guest",
348 .attrs = visorchipset_guest_attrs
349};
350
340static const struct attribute_group *visorchipset_dev_groups[] = { 351static const struct attribute_group *visorchipset_dev_groups[] = {
341 &visorchipset_install_group, 352 &visorchipset_install_group,
353 &visorchipset_guest_group,
342 NULL 354 NULL
343}; 355};
344 356
@@ -2369,49 +2381,21 @@ visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln)
2369 kmem_cache_free(pool, p); 2381 kmem_cache_free(pool, p);
2370} 2382}
2371 2383
2372#define gettoken(bufp) strsep(bufp, " -\t\n") 2384static ssize_t chipsetready_store(struct device *dev,
2373 2385 struct device_attribute *attr, const char *buf, size_t count)
2374static ssize_t
2375chipset_proc_write(struct file *file, const char __user *buffer,
2376 size_t count, loff_t *ppos)
2377{ 2386{
2378 char buf[512]; 2387 char msgtype[64];
2379 char *token, *p;
2380 2388
2381 if (count > sizeof(buf) - 1) { 2389 if (sscanf(buf, "%63s", msgtype) == 1) {
2382 LOGERR("chipset_proc_write: count (%d) exceeds size of buffer (%d)", 2390 if (strcmp(msgtype, "CALLHOMEDISK_MOUNTED") == 0)
2383 (int) count, (int) sizeof(buffer));
2384 return -EINVAL;
2385 }
2386 if (copy_from_user(buf, buffer, count)) {
2387 LOGERR("chipset_proc_write: copy_from_user failed");
2388 return -EFAULT;
2389 }
2390 buf[count] = '\0';
2391
2392 p = buf;
2393 token = gettoken(&p);
2394
2395 if (strcmp(token, "CALLHOMEDISK_MOUNTED") == 0) {
2396 token = gettoken(&p);
2397 /* The Call Home Disk has been mounted */
2398 if (strcmp(token, "0") == 0)
2399 chipset_events[0] = 1; 2391 chipset_events[0] = 1;
2400 } else if (strcmp(token, "MODULES_LOADED") == 0) { 2392 else if (strcmp(msgtype, "MODULES_LOADED") == 0)
2401 token = gettoken(&p);
2402 /* All modules for the partition have been loaded */
2403 if (strcmp(token, "0") == 0)
2404 chipset_events[1] = 1; 2393 chipset_events[1] = 1;
2405 } else if (token == NULL) { 2394 else
2406 /* No event specified */ 2395 return -EINVAL;
2407 LOGERR("No event was specified to send CHIPSET_READY response");
2408 return -1;
2409 } else { 2396 } else {
2410 /* Unsupported event specified */ 2397 return -EINVAL;
2411 LOGERR("%s is an invalid event for sending CHIPSET_READY response", token);
2412 return -1;
2413 } 2398 }
2414
2415 return count; 2399 return count;
2416} 2400}
2417 2401
@@ -2422,12 +2406,6 @@ visorchipset_proc_read_writeonly(struct file *file, char __user *buf,
2422 return 0; 2406 return 0;
2423} 2407}
2424 2408
2425static const struct file_operations chipset_proc_fops = {
2426 .owner = THIS_MODULE,
2427 .read = visorchipset_proc_read_writeonly,
2428 .write = chipset_proc_write,
2429};
2430
2431static int __init 2409static int __init
2432visorchipset_init(void) 2410visorchipset_init(void)
2433{ 2411{
@@ -2508,8 +2486,6 @@ visorchipset_init(void)
2508 2486
2509 memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); 2487 memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
2510 2488
2511 chipset_proc_dir = proc_create(VISORCHIPSET_CHIPSET_PROC_ENTRY_FN,
2512 0644, ProcDir, &chipset_proc_fops);
2513 memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); 2489 memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
2514 2490
2515 parahotplug_proc_dir = 2491 parahotplug_proc_dir =
@@ -2613,10 +2589,6 @@ visorchipset_exit(void)
2613 } 2589 }
2614 memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); 2590 memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
2615 2591
2616 if (chipset_proc_dir) {
2617 remove_proc_entry(VISORCHIPSET_CHIPSET_PROC_ENTRY_FN, ProcDir);
2618 chipset_proc_dir = NULL;
2619 }
2620 memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER)); 2592 memset(&g_ChipSetMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
2621 2593
2622 if (parahotplug_proc_dir) { 2594 if (parahotplug_proc_dir) {