mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-20 11:13:58 +08:00
staging: unisys: visorbus: visorchipset_init clean up gotos
Several error paths were not logging a message to s-Par during failure. Error paths in visorchipset_init() were corrected so that they now all do proper clean-ups. This made it necessary to move the function visorchipset_file_cleanup() above visorchipset_init so it can be referenced. Signed-off-by: David Kershner <david.kershner@unisys.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2b9bcf81d3
commit
1366a3db3d
@ -2290,16 +2290,25 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
visorchipset_file_cleanup(dev_t major_dev)
|
||||||
|
{
|
||||||
|
if (file_cdev.ops)
|
||||||
|
cdev_del(&file_cdev);
|
||||||
|
file_cdev.ops = NULL;
|
||||||
|
unregister_chrdev_region(major_dev, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
visorchipset_init(struct acpi_device *acpi_device)
|
visorchipset_init(struct acpi_device *acpi_device)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int err = -ENODEV;
|
||||||
u64 addr;
|
u64 addr;
|
||||||
uuid_le uuid = SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID;
|
uuid_le uuid = SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID;
|
||||||
|
|
||||||
addr = controlvm_get_channel_address();
|
addr = controlvm_get_channel_address();
|
||||||
if (!addr)
|
if (!addr)
|
||||||
return -ENODEV;
|
goto error;
|
||||||
|
|
||||||
memset(&busdev_notifiers, 0, sizeof(busdev_notifiers));
|
memset(&busdev_notifiers, 0, sizeof(busdev_notifiers));
|
||||||
memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
|
memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
|
||||||
@ -2307,22 +2316,19 @@ visorchipset_init(struct acpi_device *acpi_device)
|
|||||||
controlvm_channel = visorchannel_create_with_lock(addr, 0,
|
controlvm_channel = visorchannel_create_with_lock(addr, 0,
|
||||||
GFP_KERNEL, uuid);
|
GFP_KERNEL, uuid);
|
||||||
if (!controlvm_channel)
|
if (!controlvm_channel)
|
||||||
return -ENODEV;
|
goto error;
|
||||||
|
|
||||||
if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
|
if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
|
||||||
visorchannel_get_header(controlvm_channel))) {
|
visorchannel_get_header(controlvm_channel))) {
|
||||||
initialize_controlvm_payload();
|
initialize_controlvm_payload();
|
||||||
} else {
|
} else {
|
||||||
visorchannel_destroy(controlvm_channel);
|
goto error_destroy_channel;
|
||||||
controlvm_channel = NULL;
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
major_dev = MKDEV(visorchipset_major, 0);
|
major_dev = MKDEV(visorchipset_major, 0);
|
||||||
rc = visorchipset_file_init(major_dev, &controlvm_channel);
|
err = visorchipset_file_init(major_dev, &controlvm_channel);
|
||||||
if (rc < 0) {
|
if (err < 0)
|
||||||
POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR);
|
goto error_destroy_payload;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
|
memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
|
||||||
|
|
||||||
@ -2341,27 +2347,33 @@ visorchipset_init(struct acpi_device *acpi_device)
|
|||||||
visorchipset_platform_device.dev.devt = major_dev;
|
visorchipset_platform_device.dev.devt = major_dev;
|
||||||
if (platform_device_register(&visorchipset_platform_device) < 0) {
|
if (platform_device_register(&visorchipset_platform_device) < 0) {
|
||||||
POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC, DIAG_SEVERITY_ERR);
|
POSTCODE_LINUX_2(DEVICE_REGISTER_FAILURE_PC, DIAG_SEVERITY_ERR);
|
||||||
rc = -ENODEV;
|
err = -ENODEV;
|
||||||
goto cleanup;
|
goto error_cancel_work;
|
||||||
}
|
}
|
||||||
POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO);
|
POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO);
|
||||||
|
|
||||||
rc = visorbus_init();
|
err = visorbus_init();
|
||||||
cleanup:
|
if (err < 0)
|
||||||
if (rc) {
|
goto error_unregister;
|
||||||
POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc,
|
|
||||||
POSTCODE_SEVERITY_ERR);
|
|
||||||
}
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
return 0;
|
||||||
visorchipset_file_cleanup(dev_t major_dev)
|
|
||||||
{
|
error_unregister:
|
||||||
if (file_cdev.ops)
|
platform_device_unregister(&visorchipset_platform_device);
|
||||||
cdev_del(&file_cdev);
|
|
||||||
file_cdev.ops = NULL;
|
error_cancel_work:
|
||||||
unregister_chrdev_region(major_dev, 1);
|
cancel_delayed_work_sync(&periodic_controlvm_work);
|
||||||
|
visorchipset_file_cleanup(major_dev);
|
||||||
|
|
||||||
|
error_destroy_payload:
|
||||||
|
destroy_controlvm_payload_info(&controlvm_payload_info);
|
||||||
|
|
||||||
|
error_destroy_channel:
|
||||||
|
visorchannel_destroy(controlvm_channel);
|
||||||
|
|
||||||
|
error:
|
||||||
|
POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, err, POSTCODE_SEVERITY_ERR);
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user