pvpanic: move pvpanic to misc as common driver
authorPeng Hao <peng.hao2@zte.com.cn>
Tue, 6 Nov 2018 14:57:12 +0000 (22:57 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 7 Nov 2018 12:53:03 +0000 (13:53 +0100)
Move pvpanic.c from drivers/platform/x86 to drivers/misc.
Following patches will use pvpanic device in arm64.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/pvpanic.c [new file with mode: 0644]
drivers/platform/x86/Kconfig
drivers/platform/x86/Makefile
drivers/platform/x86/pvpanic.c [deleted file]

index 3726eacdf65de2470ba83c6a91dc3351f69ea713..64c898aec3b25310fb37a802b7234b7ba6ec7964 100644 (file)
@@ -513,6 +513,14 @@ config MISC_RTSX
        tristate
        default MISC_RTSX_PCI || MISC_RTSX_USB
 
+config PVPANIC
+       tristate "pvpanic device support"
+       depends on ACPI
+       help
+         This driver provides support for the pvpanic device.  pvpanic is
+         a paravirtualized device provided by QEMU; it lets a virtual machine
+         (guest) communicate panic events to the host.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
index af22bbc3d00cbcd248c4e10247b87bbb46ecab3f..b76d611c87de12dbcc6d27e802b45a41c5df6f00 100644 (file)
@@ -58,3 +58,4 @@ obj-$(CONFIG_ASPEED_LPC_SNOOP)        += aspeed-lpc-snoop.o
 obj-$(CONFIG_PCI_ENDPOINT_TEST)        += pci_endpoint_test.o
 obj-$(CONFIG_OCXL)             += ocxl/
 obj-$(CONFIG_MISC_RTSX)                += cardreader/
+obj-$(CONFIG_PVPANIC)          += pvpanic.o
diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c
new file mode 100644 (file)
index 0000000..fd86dab
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ *  pvpanic.c - pvpanic Device Support
+ *
+ *  Copyright (C) 2013 Fujitsu.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/types.h>
+#include <linux/acpi.h>
+
+MODULE_AUTHOR("Hu Tao <hutao@cn.fujitsu.com>");
+MODULE_DESCRIPTION("pvpanic device driver");
+MODULE_LICENSE("GPL");
+
+static int pvpanic_add(struct acpi_device *device);
+static int pvpanic_remove(struct acpi_device *device);
+
+static const struct acpi_device_id pvpanic_device_ids[] = {
+       { "QEMU0001", 0 },
+       { "", 0 },
+};
+MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids);
+
+#define PVPANIC_PANICKED       (1 << 0)
+
+static u16 port;
+
+static struct acpi_driver pvpanic_driver = {
+       .name =         "pvpanic",
+       .class =        "QEMU",
+       .ids =          pvpanic_device_ids,
+       .ops =          {
+                               .add =          pvpanic_add,
+                               .remove =       pvpanic_remove,
+                       },
+       .owner =        THIS_MODULE,
+};
+
+static void
+pvpanic_send_event(unsigned int event)
+{
+       outb(event, port);
+}
+
+static int
+pvpanic_panic_notify(struct notifier_block *nb, unsigned long code,
+                    void *unused)
+{
+       pvpanic_send_event(PVPANIC_PANICKED);
+       return NOTIFY_DONE;
+}
+
+static struct notifier_block pvpanic_panic_nb = {
+       .notifier_call = pvpanic_panic_notify,
+       .priority = 1, /* let this called before broken drm_fb_helper */
+};
+
+
+static acpi_status
+pvpanic_walk_resources(struct acpi_resource *res, void *context)
+{
+       switch (res->type) {
+       case ACPI_RESOURCE_TYPE_END_TAG:
+               return AE_OK;
+
+       case ACPI_RESOURCE_TYPE_IO:
+               port = res->data.io.minimum;
+               return AE_OK;
+
+       default:
+               return AE_ERROR;
+       }
+}
+
+static int pvpanic_add(struct acpi_device *device)
+{
+       int ret;
+
+       ret = acpi_bus_get_status(device);
+       if (ret < 0)
+               return ret;
+
+       if (!device->status.enabled || !device->status.functional)
+               return -ENODEV;
+
+       acpi_walk_resources(device->handle, METHOD_NAME__CRS,
+                           pvpanic_walk_resources, NULL);
+
+       if (!port)
+               return -ENODEV;
+
+       atomic_notifier_chain_register(&panic_notifier_list,
+                                      &pvpanic_panic_nb);
+
+       return 0;
+}
+
+static int pvpanic_remove(struct acpi_device *device)
+{
+
+       atomic_notifier_chain_unregister(&panic_notifier_list,
+                                        &pvpanic_panic_nb);
+       return 0;
+}
+
+module_acpi_driver(pvpanic_driver);
index 54f6a40c75c69c667ac3d4591dde89fd99bac3be..5d5ee4fa1e6e9983077a4684e7ca25bbf11fdefd 100644 (file)
@@ -1168,14 +1168,6 @@ config INTEL_SMARTCONNECT
          This driver checks to determine whether the device has Intel Smart
          Connect enabled, and if so disables it.
 
-config PVPANIC
-       tristate "pvpanic device support"
-       depends on ACPI
-       ---help---
-         This driver provides support for the pvpanic device.  pvpanic is
-         a paravirtualized device provided by QEMU; it lets a virtual machine
-         (guest) communicate panic events to the host.
-
 config INTEL_PMC_IPC
        tristate "Intel PMC IPC Driver"
        depends on ACPI
index 39ae94135406b69bb7cef9bcb8d24242382afe35..d537d1753147973e2c3ae27cadf67d72aca37cd8 100644 (file)
@@ -78,7 +78,6 @@ obj-$(CONFIG_APPLE_GMUX)      += apple-gmux.o
 obj-$(CONFIG_INTEL_RST)                += intel-rst.o
 obj-$(CONFIG_INTEL_SMARTCONNECT)       += intel-smartconnect.o
 
-obj-$(CONFIG_PVPANIC)           += pvpanic.o
 obj-$(CONFIG_ALIENWARE_WMI)    += alienware-wmi.o
 obj-$(CONFIG_INTEL_PMC_IPC)    += intel_pmc_ipc.o
 obj-$(CONFIG_TOUCHSCREEN_DMI)  += touchscreen_dmi.o
diff --git a/drivers/platform/x86/pvpanic.c b/drivers/platform/x86/pvpanic.c
deleted file mode 100644 (file)
index fd86dab..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- *  pvpanic.c - pvpanic Device Support
- *
- *  Copyright (C) 2013 Fujitsu.
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/types.h>
-#include <linux/acpi.h>
-
-MODULE_AUTHOR("Hu Tao <hutao@cn.fujitsu.com>");
-MODULE_DESCRIPTION("pvpanic device driver");
-MODULE_LICENSE("GPL");
-
-static int pvpanic_add(struct acpi_device *device);
-static int pvpanic_remove(struct acpi_device *device);
-
-static const struct acpi_device_id pvpanic_device_ids[] = {
-       { "QEMU0001", 0 },
-       { "", 0 },
-};
-MODULE_DEVICE_TABLE(acpi, pvpanic_device_ids);
-
-#define PVPANIC_PANICKED       (1 << 0)
-
-static u16 port;
-
-static struct acpi_driver pvpanic_driver = {
-       .name =         "pvpanic",
-       .class =        "QEMU",
-       .ids =          pvpanic_device_ids,
-       .ops =          {
-                               .add =          pvpanic_add,
-                               .remove =       pvpanic_remove,
-                       },
-       .owner =        THIS_MODULE,
-};
-
-static void
-pvpanic_send_event(unsigned int event)
-{
-       outb(event, port);
-}
-
-static int
-pvpanic_panic_notify(struct notifier_block *nb, unsigned long code,
-                    void *unused)
-{
-       pvpanic_send_event(PVPANIC_PANICKED);
-       return NOTIFY_DONE;
-}
-
-static struct notifier_block pvpanic_panic_nb = {
-       .notifier_call = pvpanic_panic_notify,
-       .priority = 1, /* let this called before broken drm_fb_helper */
-};
-
-
-static acpi_status
-pvpanic_walk_resources(struct acpi_resource *res, void *context)
-{
-       switch (res->type) {
-       case ACPI_RESOURCE_TYPE_END_TAG:
-               return AE_OK;
-
-       case ACPI_RESOURCE_TYPE_IO:
-               port = res->data.io.minimum;
-               return AE_OK;
-
-       default:
-               return AE_ERROR;
-       }
-}
-
-static int pvpanic_add(struct acpi_device *device)
-{
-       int ret;
-
-       ret = acpi_bus_get_status(device);
-       if (ret < 0)
-               return ret;
-
-       if (!device->status.enabled || !device->status.functional)
-               return -ENODEV;
-
-       acpi_walk_resources(device->handle, METHOD_NAME__CRS,
-                           pvpanic_walk_resources, NULL);
-
-       if (!port)
-               return -ENODEV;
-
-       atomic_notifier_chain_register(&panic_notifier_list,
-                                      &pvpanic_panic_nb);
-
-       return 0;
-}
-
-static int pvpanic_remove(struct acpi_device *device)
-{
-
-       atomic_notifier_chain_unregister(&panic_notifier_list,
-                                        &pvpanic_panic_nb);
-       return 0;
-}
-
-module_acpi_driver(pvpanic_driver);