summaryrefslogtreecommitdiffstats
path: root/drivers/staging/unisys/visorchipset/visorchipset_main.c
diff options
context:
space:
mode:
authorBenjamin Romer2014-07-22 15:56:26 +0200
committerGreg Kroah-Hartman2014-07-23 01:11:00 +0200
commit54b312290077f56a1c2dfb15237e1b315667d225 (patch)
tree70adddf922720e3313c6ae1726a44919c5ef8f96 /drivers/staging/unisys/visorchipset/visorchipset_main.c
parentstaging: unisys: add toolaction to sysfs (diff)
downloadkernel-qcow2-linux-54b312290077f56a1c2dfb15237e1b315667d225.tar.gz
kernel-qcow2-linux-54b312290077f56a1c2dfb15237e1b315667d225.tar.xz
kernel-qcow2-linux-54b312290077f56a1c2dfb15237e1b315667d225.zip
staging: unisys: move boottotool out of proc to sysfs
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.romer@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/unisys/visorchipset/visorchipset_main.c')
-rw-r--r--drivers/staging/unisys/visorchipset/visorchipset_main.c132
1 files changed, 40 insertions, 92 deletions
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorchipset/visorchipset_main.c
index a0d34ebdf823..48db6eec257d 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,8 +309,15 @@ static ssize_t toolaction_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count);
static DEVICE_ATTR_RW(toolaction);
+static ssize_t boottotool_show(struct device *dev,
+ struct device_attribute *attr, char *buf);
+static ssize_t boottotool_store(struct device *dev,
+ struct device_attribute *attr, const char *buf, size_t count);
+static DEVICE_ATTR_RW(boottotool);
+
static struct attribute *visorchipset_install_attrs[] = {
&dev_attr_toolaction.attr,
+ &dev_attr_boottotool.attr,
NULL
};
@@ -377,6 +375,38 @@ ssize_t toolaction_store(struct device *dev, struct device_attribute *attr,
return -EIO;
}
+ssize_t boottotool_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ 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);
+}
+
+ssize_t boottotool_store(struct device *dev, struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ 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;
+}
static void
show_partition_property(struct seq_file *f, void *ctx, int property)
{
@@ -2408,84 +2438,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,
@@ -2498,7 +2450,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)
@@ -2575,9 +2526,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));