Move the proc entry controlling the boottotool flag to procfs. The field
appears in /sys/devices/platform/visorchipset/install/boottotool.

The boottotool flag controls s-Par behavior on the next boot of this guest.
Setting the flag will cause the guest to boot from the utility and installation
image, which will use the value in the toolaction field to determine what
operation is being requested.

Signed-off-by: Benjamin Romer <benjamin.ro...@unisys.com>
---
 .../unisys/visorchipset/visorchipset_main.c        | 143 ++++++++-------------
 1 file changed, 51 insertions(+), 92 deletions(-)

diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c 
b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index f45e352..6036bf5 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorchipset/visorchipset_main.c
@@ -149,21 +149,12 @@ static ssize_t proc_read_installer(struct file *file, 
char __user *buf,
 static ssize_t proc_write_installer(struct file *file,
                                    const char __user *buffer,
                                    size_t count, loff_t *ppos);
-static ssize_t proc_read_bootToTool(struct file *file, char __user *buf,
-                                   size_t len, loff_t *offset);
-static ssize_t proc_write_bootToTool(struct file *file,
-                                    const char __user *buffer,
-                                    size_t count, loff_t *ppos);
+
 static const struct file_operations proc_installer_fops = {
        .read = proc_read_installer,
        .write = proc_write_installer,
 };
 
-static const struct file_operations proc_bootToTool_fops = {
-       .read = proc_read_bootToTool,
-       .write = proc_write_bootToTool,
-};
-
 typedef struct {
        U8 __iomem *ptr;        /* pointer to base address of payload pool */
        U64 offset;             /* offset from beginning of controlvm
@@ -318,11 +309,21 @@ static ssize_t show_toolaction(struct device *dev,
 static ssize_t store_toolaction(struct device *dev,
        struct device_attribute *attr, const char *buf, size_t count);
 
+static ssize_t show_boottotool(struct device *dev,
+       struct device_attribute *attr, char *buf);
+
+static ssize_t store_boottotool(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);
 
+static DEVICE_ATTR(boottotool, S_IRUSR | S_IWUSR, show_boottotool,
+       store_boottotool);
+
 static struct attribute *visorchipset_install_attrs[] = {
        &dev_attr_toolaction.attr,
+       &dev_attr_boottotool.attr,
        NULL
 };
 
@@ -386,6 +387,46 @@ ssize_t store_toolaction(struct device *dev, struct 
device_attribute *attr,
                return -ENODEV;
 }
 
+ssize_t show_boottotool(struct device *dev, struct device_attribute *attr,
+               char *buf)
+{
+       if (ControlVm_channel) {
+               ULTRA_EFI_SPAR_INDICATION efiSparIndication;
+
+               visorchannel_read(ControlVm_channel,
+                       offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
+                               EfiSparIndication), &efiSparIndication,
+                       sizeof(ULTRA_EFI_SPAR_INDICATION));
+               return scnprintf(buf, PAGE_SIZE, "%u\n",
+                               efiSparIndication.BootToTool);
+       } else {
+               return -ENODEV;
+       }
+}
+
+ssize_t store_boottotool(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
+{
+       if (ControlVm_channel) {
+               int val;
+               ULTRA_EFI_SPAR_INDICATION efiSparIndication;
+
+               if (sscanf(buf, "%u\n", &val) == 1) {
+                       efiSparIndication.BootToTool = val;
+                       if (visorchannel_write(ControlVm_channel,
+                               offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
+                                        EfiSparIndication),
+                               &(efiSparIndication),
+                       sizeof(ULTRA_EFI_SPAR_INDICATION)) < 0)
+                                       return -EFAULT;
+                               else
+                                       return count;
+               } else
+                       return -EIO;
+       } else {
+               return -ENODEV;
+       }
+}
 static void
 show_partition_property(struct seq_file *f, void *ctx, int property)
 {
@@ -2417,84 +2458,6 @@ proc_write_installer(struct file *file,
        return count;
 }
 
-/**
- * Reads the EfiSparIndication.BootToTool field of ControlVMChannel.
- */
-static ssize_t
-proc_read_bootToTool(struct file *file, char __user *buf,
-                    size_t len, loff_t *offset)
-{
-       int length = 0;
-       ULTRA_EFI_SPAR_INDICATION efiSparIndication;
-       char *vbuf;
-       loff_t pos = *offset;
-
-       if (pos < 0)
-               return -EINVAL;
-
-       if (pos > 0 || !len)
-               return 0;
-
-       vbuf = kzalloc(len, GFP_KERNEL);
-       if (!vbuf)
-               return -ENOMEM;
-
-       visorchannel_read(ControlVm_channel,
-                         offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
-                                  EfiSparIndication), &efiSparIndication,
-                         sizeof(ULTRA_EFI_SPAR_INDICATION));
-
-       length = sprintf(vbuf, "%d\n", (int) efiSparIndication.BootToTool);
-       if (copy_to_user(buf, vbuf, length)) {
-               kfree(vbuf);
-               return -EFAULT;
-       }
-
-       kfree(vbuf);
-       *offset += length;
-       return length;
-}
-
-/**
- * Writes to the EfiSparIndication.BootToTool field of ControlVMChannel.
- * Input: 1 or 0 (1 being on, 0 being off)
- */
-static ssize_t
-proc_write_bootToTool(struct file *file,
-                     const char __user *buffer, size_t count, loff_t *ppos)
-{
-       char buf[3];
-       int inputVal;
-       ULTRA_EFI_SPAR_INDICATION efiSparIndication;
-
-       /* Check to make sure there is no buffer overflow */
-       if (count > (sizeof(buf) - 1))
-               return -EINVAL;
-
-       if (copy_from_user(buf, buffer, count)) {
-               WARN(1, "Error copying from user space\n");
-               return -EFAULT;
-       }
-
-       if (sscanf(buf, "%i", &inputVal) != 1)
-               inputVal = 0;
-
-       efiSparIndication.BootToTool = (inputVal == 1 ? 1 : 0);
-
-       if (visorchannel_write
-           (ControlVm_channel,
-            offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, EfiSparIndication),
-            &efiSparIndication, sizeof(ULTRA_EFI_SPAR_INDICATION)) < 0)
-               printk
-                   ("Installation BootToTool Write Failed - BootToTool = %d\n",
-                    (int) efiSparIndication.BootToTool);
-
-       /* So this function isn't called multiple times, must return
-        * size of buffer
-        */
-       return count;
-}
-
 static const struct file_operations chipset_proc_fops = {
        .owner = THIS_MODULE,
        .read = visorchipset_proc_read_writeonly,
@@ -2507,7 +2470,6 @@ visorchipset_init(void)
        int rc = 0, x = 0;
        char s[64];
        struct proc_dir_entry *installer_file;
-       struct proc_dir_entry *bootToTool_file;
        HOSTADDRESS addr;
 
        if (!unisys_spar_platform)
@@ -2584,9 +2546,6 @@ visorchipset_init(void)
        /* Setup Installation fields */
        installer_file = proc_create("installer", 0644, ProcDir,
                                     &proc_installer_fops);
-       /* Setup the BootToTool field */
-       bootToTool_file = proc_create("boottotool", 0644, ProcDir,
-                                     &proc_bootToTool_fops);
 
        memset(&g_DiagMsgHdr, 0, sizeof(CONTROLVM_MESSAGE_HEADER));
 
-- 
1.9.1

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

Reply via email to