From 55c67dcaac7891887ad0a077c28b709be2abcb49 Mon Sep 17 00:00:00 2001 From: Prarit Bhargava Date: Tue, 5 May 2015 18:37:02 -0400 Subject: [PATCH] staging: unisys: add acpi pnp driver According to Unisys, another OS detects the PNP0A07 as the auto load device. We can also do this in the linux kernel by simply converting the driver over to the ACPI driver model. Notes: This changes the usage of __init and it had to be removed from some functions to avoid a !__init function calling an __init function. Additionally I also cleaned up the headers in visorchipset.c since I was adding a header file. Signed-off-by: Prarit Bhargava Signed-off-by: Benjamin Romer Signed-off-by: Greg Kroah-Hartman --- .../staging/unisys/visorbus/visorbus_main.c | 2 +- .../unisys/visorbus/visorbus_private.h | 2 +- .../staging/unisys/visorbus/visorchipset.c | 77 ++++++++++++++----- 3 files changed, 58 insertions(+), 23 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index f7976ca76f17..b522ea4d2c2d 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -2034,7 +2034,7 @@ struct channel_size_info { unsigned long max_size; }; -int __init +int visorbus_init(void) { int rc = 0; diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h index f9a5e015e21d..1153c99e813f 100644 --- a/drivers/staging/unisys/visorbus/visorbus_private.h +++ b/drivers/staging/unisys/visorbus/visorbus_private.h @@ -155,6 +155,6 @@ bool visorchipset_get_device_info(u32 bus_no, u32 dev_no, bool visorchipset_set_bus_context(u32 bus_no, void *context); /* visorbus init and exit functions */ -int __init visorbus_init(void); +int visorbus_init(void); void visorbus_exit(void); #endif diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 76923bf45de1..fde89938cee5 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -15,16 +15,7 @@ * details. */ -#include "controlvmchannel.h" -#include "version.h" -#include "procobjecttree.h" -#include "visorbus.h" -#include "periodic_work.h" -#include "uisutils.h" -#include "controlvmcompletionstatus.h" -#include "guestlinuxdebug.h" -#include "visorbus_private.h" - +#include #include #include #include @@ -34,6 +25,16 @@ #include #include +#include "controlvmchannel.h" +#include "controlvmcompletionstatus.h" +#include "guestlinuxdebug.h" +#include "periodic_work.h" +#include "procobjecttree.h" +#include "uisutils.h" +#include "version.h" +#include "visorbus.h" +#include "visorbus_private.h" + #define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c #define MAX_NAME_SIZE 128 @@ -2637,17 +2638,12 @@ visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel) return 0; } - - -static int __init -visorchipset_init(void) +static int +visorchipset_init(struct acpi_device *acpi_device) { int rc = 0; HOSTADDRESS addr; - if (!unisys_spar_platform) - return -ENODEV; - memset(&busdev_notifiers, 0, sizeof(busdev_notifiers)); memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info)); memset(&livedump_info, 0, sizeof(livedump_info)); @@ -2733,8 +2729,8 @@ visorchipset_file_cleanup(dev_t major_dev) unregister_chrdev_region(major_dev, 1); } -static void -visorchipset_exit(void) +static int +visorchipset_exit(struct acpi_device *acpi_device) { POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO); @@ -2754,6 +2750,45 @@ visorchipset_exit(void) visorchipset_file_cleanup(visorchipset_platform_device.dev.devt); POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO); + + return 0; +} + +static const struct acpi_device_id unisys_device_ids[] = { + {"PNP0A07", 0}, + {"", 0}, +}; +MODULE_DEVICE_TABLE(acpi, unisys_device_ids); + +static struct acpi_driver unisys_acpi_driver = { + .name = "unisys_acpi", + .class = "unisys_acpi_class", + .owner = THIS_MODULE, + .ids = unisys_device_ids, + .ops = { + .add = visorchipset_init, + .remove = visorchipset_exit, + }, +}; + +static int init_unisys(void) +{ + int result; + + if (!unisys_spar_platform) + return -ENODEV; + + result = acpi_bus_register_driver(&unisys_acpi_driver); + if (result) + return -ENODEV; + + pr_info("Unisys Visorchipset Driver Loaded.\n"); + return 0; +}; + +static void exit_unisys(void) +{ + acpi_bus_unregister_driver(&unisys_acpi_driver); } module_param_named(major, visorchipset_major, int, S_IRUGO); @@ -2767,8 +2802,8 @@ module_param_named(holdchipsetready, visorchipset_holdchipsetready, MODULE_PARM_DESC(visorchipset_holdchipsetready, "1 to hold response to CHIPSET_READY"); -module_init(visorchipset_init); -module_exit(visorchipset_exit); +module_init(init_unisys); +module_exit(exit_unisys); MODULE_AUTHOR("Unisys"); MODULE_LICENSE("GPL"); -- 2.20.1