From 7289a8dd2b258d267e5405f656d7f27c82fba014 Mon Sep 17 00:00:00 2001 From: David Binder Date: Wed, 1 Feb 2017 17:38:56 -0500 Subject: [PATCH] staging: unisys: visorbus: Consolidate kobject functions Simplifies kobject usage in visorchipset.c by combining pairs of functions that are better expressed combined. Signed-off-by: David Binder Signed-off-by: David Kershner Reported-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorchipset.c | 76 ++++++++----------- 1 file changed, 31 insertions(+), 45 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index df2dfeb14027..c90ea6a770ce 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -1435,22 +1435,33 @@ parahotplug_process_message(struct controlvm_message *inmsg) } } -/** - * visorchipset_chipset_ready() - sends chipset_ready action +/* + * chipset_ready_uevent() - sends chipset_ready action * * Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset. * - * Return: CONTROLVM_RESP_SUCCESS + * Return: 0 on success, negative on failure */ static int -visorchipset_chipset_ready(void) +chipset_ready_uevent(struct controlvm_message_header *msg_hdr) { kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_ONLINE); - return CONTROLVM_RESP_SUCCESS; + + if (msg_hdr->flags.response_expected) + return controlvm_respond(msg_hdr, CONTROLVM_RESP_SUCCESS); + + return 0; } +/* + * chipset_selftest_uevent() - sends chipset_selftest action + * + * Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset. + * + * Return: 0 on success, negative on failure + */ static int -visorchipset_chipset_selftest(void) +chipset_selftest_uevent(struct controlvm_message_header *msg_hdr) { char env_selftest[20]; char *envp[] = { env_selftest, NULL }; @@ -1458,54 +1469,29 @@ visorchipset_chipset_selftest(void) sprintf(env_selftest, "SPARSP_SELFTEST=%d", 1); kobject_uevent_env(&visorchipset_platform_device.dev.kobj, KOBJ_CHANGE, envp); - return CONTROLVM_RESP_SUCCESS; + + if (msg_hdr->flags.response_expected) + return controlvm_respond(msg_hdr, CONTROLVM_RESP_SUCCESS); + + return 0; } -/** - * visorchipset_chipset_notready() - sends chipset_notready action +/* + * chipset_notready_uevent() - sends chipset_notready action * * Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset. * - * Return: CONTROLVM_RESP_SUCCESS + * Return: 0 on success, negative on failure */ static int -visorchipset_chipset_notready(void) +chipset_notready_uevent(struct controlvm_message_header *msg_hdr) { kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE); - return CONTROLVM_RESP_SUCCESS; -} - -static void -chipset_ready(struct controlvm_message_header *msg_hdr) -{ - int rc = visorchipset_chipset_ready(); - - if (rc != CONTROLVM_RESP_SUCCESS) - rc = -rc; - if (msg_hdr->flags.response_expected) - controlvm_respond(msg_hdr, rc); -} -static void -chipset_selftest(struct controlvm_message_header *msg_hdr) -{ - int rc = visorchipset_chipset_selftest(); - - if (rc != CONTROLVM_RESP_SUCCESS) - rc = -rc; if (msg_hdr->flags.response_expected) - controlvm_respond(msg_hdr, rc); -} + return controlvm_respond(msg_hdr, CONTROLVM_RESP_SUCCESS); -static void -chipset_notready(struct controlvm_message_header *msg_hdr) -{ - int rc = visorchipset_chipset_notready(); - - if (rc != CONTROLVM_RESP_SUCCESS) - rc = -rc; - if (msg_hdr->flags.response_expected) - controlvm_respond(msg_hdr, rc); + return 0; } static inline unsigned int @@ -1967,13 +1953,13 @@ handle_command(struct controlvm_message inmsg, u64 channel_addr) controlvm_respond(&inmsg.hdr, CONTROLVM_RESP_SUCCESS); break; case CONTROLVM_CHIPSET_READY: - chipset_ready(&inmsg.hdr); + chipset_ready_uevent(&inmsg.hdr); break; case CONTROLVM_CHIPSET_SELFTEST: - chipset_selftest(&inmsg.hdr); + chipset_selftest_uevent(&inmsg.hdr); break; case CONTROLVM_CHIPSET_STOP: - chipset_notready(&inmsg.hdr); + chipset_notready_uevent(&inmsg.hdr); break; default: if (inmsg.hdr.flags.response_expected) -- 2.20.1