staging: unisys: fix visorchipset sysfs attribute functions
This patch cleans up the style, error handling, and string handling in the sysfs functions recently added to visorchipset: - Use of sscanf() was changed to type-appropriate kstrto*() functions - error handling was simplified - the error return value of visorchannel_write() was corrected - switch use of driver-specific types to kernel types Signed-off-by: Benjamin Romer <benjamin.romer@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e010a2a04c
commit
66e24b7686
|
@ -370,29 +370,31 @@ static void controlvm_respond_physdev_changestate(CONTROLVM_MESSAGE_HEADER *
|
||||||
ssize_t toolaction_show(struct device *dev, struct device_attribute *attr,
|
ssize_t toolaction_show(struct device *dev, struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
U8 toolAction;
|
u8 toolAction;
|
||||||
|
|
||||||
visorchannel_read(ControlVm_channel,
|
visorchannel_read(ControlVm_channel,
|
||||||
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
|
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
|
||||||
ToolAction), &toolAction, sizeof(U8));
|
ToolAction), &toolAction, sizeof(u8));
|
||||||
return scnprintf(buf, PAGE_SIZE, "%u\n", toolAction);
|
return scnprintf(buf, PAGE_SIZE, "%u\n", toolAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t toolaction_store(struct device *dev, struct device_attribute *attr,
|
ssize_t toolaction_store(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
U8 toolAction;
|
u8 toolAction;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (sscanf(buf, "%hhu\n", &toolAction) == 1) {
|
if (kstrtou8(buf, 10, &toolAction) != 0)
|
||||||
if (visorchannel_write(ControlVm_channel,
|
return -EINVAL;
|
||||||
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
|
|
||||||
ToolAction),
|
ret = visorchannel_write(ControlVm_channel,
|
||||||
&toolAction, sizeof(U8)) < 0)
|
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL, ToolAction),
|
||||||
return -EFAULT;
|
&toolAction, sizeof(u8));
|
||||||
else
|
|
||||||
return count;
|
if (ret)
|
||||||
} else
|
return ret;
|
||||||
return -EIO;
|
else
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t boottotool_show(struct device *dev, struct device_attribute *attr,
|
ssize_t boottotool_show(struct device *dev, struct device_attribute *attr,
|
||||||
|
@ -411,21 +413,23 @@ ssize_t boottotool_show(struct device *dev, struct device_attribute *attr,
|
||||||
ssize_t boottotool_store(struct device *dev, struct device_attribute *attr,
|
ssize_t boottotool_store(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
int val;
|
int val, ret;
|
||||||
ULTRA_EFI_SPAR_INDICATION efiSparIndication;
|
ULTRA_EFI_SPAR_INDICATION efiSparIndication;
|
||||||
|
|
||||||
if (sscanf(buf, "%u\n", &val) == 1) {
|
if (kstrtoint(buf, 10, &val) != 0)
|
||||||
efiSparIndication.BootToTool = val;
|
return -EINVAL;
|
||||||
if (visorchannel_write(ControlVm_channel,
|
|
||||||
|
efiSparIndication.BootToTool = val;
|
||||||
|
ret = visorchannel_write(ControlVm_channel,
|
||||||
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
|
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
|
||||||
EfiSparIndication),
|
EfiSparIndication),
|
||||||
&(efiSparIndication),
|
&(efiSparIndication),
|
||||||
sizeof(ULTRA_EFI_SPAR_INDICATION)) < 0)
|
sizeof(ULTRA_EFI_SPAR_INDICATION));
|
||||||
return -EFAULT;
|
|
||||||
else
|
if (ret)
|
||||||
return count;
|
return ret;
|
||||||
} else
|
else
|
||||||
return -EIO;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t error_show(struct device *dev, struct device_attribute *attr,
|
static ssize_t error_show(struct device *dev, struct device_attribute *attr,
|
||||||
|
@ -443,16 +447,19 @@ static ssize_t error_store(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
u32 error;
|
u32 error;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (sscanf(buf, "%i\n", &error) == 1) {
|
if (kstrtou32(buf, 10, &error) != 0)
|
||||||
if (visorchannel_write(ControlVm_channel,
|
return -EINVAL;
|
||||||
|
|
||||||
|
ret = visorchannel_write(ControlVm_channel,
|
||||||
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
|
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
|
||||||
InstallationError),
|
InstallationError),
|
||||||
&error, sizeof(u32)) == 1) {
|
&error, sizeof(u32));
|
||||||
return count;
|
if (ret)
|
||||||
}
|
return ret;
|
||||||
}
|
else
|
||||||
return -EIO;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
|
static ssize_t textid_show(struct device *dev, struct device_attribute *attr,
|
||||||
|
@ -470,16 +477,19 @@ static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
u32 textId;
|
u32 textId;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (sscanf(buf, "%i\n", &textId) == 1) {
|
if (kstrtou32(buf, 10, &textId) != 0)
|
||||||
if (visorchannel_write(ControlVm_channel,
|
return -EINVAL;
|
||||||
|
|
||||||
|
ret = visorchannel_write(ControlVm_channel,
|
||||||
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
|
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
|
||||||
InstallationTextId),
|
InstallationTextId),
|
||||||
&textId, sizeof(u32)) == 1) {
|
&textId, sizeof(u32));
|
||||||
return count;
|
if (ret)
|
||||||
}
|
return ret;
|
||||||
}
|
else
|
||||||
return -EIO;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -500,16 +510,19 @@ static ssize_t remaining_steps_store(struct device *dev,
|
||||||
struct device_attribute *attr, const char *buf, size_t count)
|
struct device_attribute *attr, const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
u16 remainingSteps;
|
u16 remainingSteps;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (sscanf(buf, "%hu\n", &remainingSteps) == 1) {
|
if (kstrtou16(buf, 10, &remainingSteps) != 0)
|
||||||
if (visorchannel_write(ControlVm_channel,
|
return -EINVAL;
|
||||||
|
|
||||||
|
ret = visorchannel_write(ControlVm_channel,
|
||||||
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
|
offsetof(ULTRA_CONTROLVM_CHANNEL_PROTOCOL,
|
||||||
InstallationRemainingSteps),
|
InstallationRemainingSteps),
|
||||||
&remainingSteps, sizeof(u16)) == 1) {
|
&remainingSteps, sizeof(u16));
|
||||||
return count;
|
if (ret)
|
||||||
}
|
return ret;
|
||||||
}
|
else
|
||||||
return -EIO;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -2383,17 +2396,17 @@ static ssize_t chipsetready_store(struct device *dev,
|
||||||
{
|
{
|
||||||
char msgtype[64];
|
char msgtype[64];
|
||||||
|
|
||||||
if (sscanf(buf, "%63s", msgtype) == 1) {
|
if (sscanf(buf, "%63s", msgtype) != 1)
|
||||||
if (strcmp(msgtype, "CALLHOMEDISK_MOUNTED") == 0)
|
return -EINVAL;
|
||||||
chipset_events[0] = 1;
|
|
||||||
else if (strcmp(msgtype, "MODULES_LOADED") == 0)
|
if (strcmp(msgtype, "CALLHOMEDISK_MOUNTED") == 0) {
|
||||||
chipset_events[1] = 1;
|
chipset_events[0] = 1;
|
||||||
else
|
return count;
|
||||||
return -EINVAL;
|
} else if (strcmp(msgtype, "MODULES_LOADED") == 0) {
|
||||||
} else {
|
chipset_events[1] = 1;
|
||||||
|
return count;
|
||||||
|
} else
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
|
|
|
@ -184,7 +184,7 @@ memregion_readwrite(BOOL is_write,
|
||||||
{
|
{
|
||||||
if (offset + nbytes > memregion->nbytes) {
|
if (offset + nbytes > memregion->nbytes) {
|
||||||
ERRDRV("memregion_readwrite offset out of range!!");
|
ERRDRV("memregion_readwrite offset out of range!!");
|
||||||
return -EFAULT;
|
return -EIO;
|
||||||
}
|
}
|
||||||
if (is_write)
|
if (is_write)
|
||||||
memcpy_toio(memregion->mapped + offset, local, nbytes);
|
memcpy_toio(memregion->mapped + offset, local, nbytes);
|
||||||
|
|
Loading…
Reference in New Issue