Return 0 for empty body register function normally.
Signed-off-by: Peng Hao <[email protected]>
---
drivers/misc/pvpanic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c
index 3150dc2..f84ed30 100644
--- a/drivers/misc/pvpanic.c
+++ b/drivers/misc/pvpanic.c
@@ -125,7 +125,7 @@ static void pvpanic_unregister_acpi_driver(void)
#else
static int pvpanic_register_acpi_driver(void)
{
- return -ENODEV;
+ return 0;
}
static void pvpanic_unregister_acpi_driver(void) {}
--
1.8.3.1
Add PCI dependency for pvpanic in Kconfig.
Signed-off-by: Peng Hao <[email protected]>
---
drivers/misc/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index f417b06..5ff8ca4 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -515,7 +515,7 @@ config MISC_RTSX
config PVPANIC
tristate "pvpanic device support"
- depends on HAS_IOMEM && (ACPI || OF)
+ depends on HAS_IOMEM && (ACPI || OF || PCI)
help
This driver provides support for the pvpanic device. pvpanic is
a paravirtualized device provided by QEMU; it lets a virtual machine
--
1.8.3.1
Support pvpanic as a pci device in guest kernel.
Signed-off-by: Peng Hao <[email protected]>
---
drivers/misc/pvpanic.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 65 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c
index f84ed30..1fae67e 100644
--- a/drivers/misc/pvpanic.c
+++ b/drivers/misc/pvpanic.c
@@ -13,11 +13,14 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_address.h>
+#include <linux/pci.h>
#include <linux/platform_device.h>
#include <linux/types.h>
static void __iomem *base;
+#define PCI_VENDOR_ID_REDHAT 0x1b36
+#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101
#define PVPANIC_PANICKED (1 << 0)
MODULE_AUTHOR("Hu Tao <[email protected]>");
@@ -172,12 +175,71 @@ static int pvpanic_mmio_remove(struct platform_device *pdev)
.remove = pvpanic_mmio_remove,
};
+#ifdef CONFIG_PCI
+static const struct pci_device_id pvpanic_pci_id_tbl[] = {
+ { PCI_DEVICE(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_PVPANIC),},
+ {}
+};
+
+static int pvpanic_pci_probe(struct pci_dev *pdev,
+ const struct pci_device_id *ent)
+{
+ int err;
+
+ err = pci_enable_device(pdev);
+ if (err)
+ return err;
+ if (pci_request_region(pdev, 0, "pvpanic-pci"))
+ goto disable;
+
+ base = pci_ioremap_bar(pdev, 0);
+ if (!base)
+ goto release;
+
+ atomic_notifier_chain_register(&panic_notifier_list,
+ &pvpanic_panic_nb);
+ return 0;
+
+release:
+ pci_release_region(pdev, 0);
+disable:
+ pci_disable_device(pdev);
+
+ return -ENODEV;
+}
+
+static void pvpanic_pci_remove(struct pci_dev *pdev)
+{
+ atomic_notifier_chain_unregister(&panic_notifier_list,
+ &pvpanic_panic_nb);
+ iounmap(base);
+ pci_release_region(pdev, 0);
+ pci_disable_device(pdev);
+}
+
+static struct pci_driver pvpanic_pci_driver = {
+ .name = "pvpanic-pci",
+ .id_table = pvpanic_pci_id_tbl,
+ .probe = pvpanic_pci_probe,
+ .remove = pvpanic_pci_remove,
+};
+
+#endif /* CONFIG_PCI */
+
static int __init pvpanic_mmio_init(void)
{
+ int r1, r2;
+
if (acpi_disabled)
- return platform_driver_register(&pvpanic_mmio_driver);
+ r1 = platform_driver_register(&pvpanic_mmio_driver);
+ else
+ r1 = pvpanic_register_acpi_driver();
+ r2 = pci_register_driver(&pvpanic_pci_driver);
+
+ if (r1 && r2) /* all drivers register failed */
+ return 1;
else
- return pvpanic_register_acpi_driver();
+ return 0;
}
static void __exit pvpanic_mmio_exit(void)
@@ -186,6 +248,7 @@ static void __exit pvpanic_mmio_exit(void)
platform_driver_unregister(&pvpanic_mmio_driver);
else
pvpanic_unregister_acpi_driver();
+ pci_unregister_driver(&pvpanic_pci_driver);
}
module_init(pvpanic_mmio_init);
--
1.8.3.1
Hi Peng,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on char-misc/char-misc-testing]
[also build test ERROR on next-20181214]
[cannot apply to v4.20-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Peng-Hao/misc-pvpanic-return-0-for-empty-body-register-function/20181216-140504
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=sh
All errors (new ones prefixed by >>):
drivers//misc/pvpanic.c: In function 'pvpanic_mmio_init':
>> drivers//misc/pvpanic.c:237:28: error: 'pvpanic_pci_driver' undeclared (first use in this function); did you mean 'pvpanic_mmio_driver'?
r2 = pci_register_driver(&pvpanic_pci_driver);
^~~~~~~~~~~~~~~~~~
pvpanic_mmio_driver
drivers//misc/pvpanic.c:237:28: note: each undeclared identifier is reported only once for each function it appears in
drivers//misc/pvpanic.c: In function 'pvpanic_mmio_exit':
drivers//misc/pvpanic.c:251:25: error: 'pvpanic_pci_driver' undeclared (first use in this function); did you mean 'pvpanic_mmio_driver'?
pci_unregister_driver(&pvpanic_pci_driver);
^~~~~~~~~~~~~~~~~~
pvpanic_mmio_driver
vim +237 drivers//misc/pvpanic.c
228
229 static int __init pvpanic_mmio_init(void)
230 {
231 int r1, r2;
232
233 if (acpi_disabled)
234 r1 = platform_driver_register(&pvpanic_mmio_driver);
235 else
236 r1 = pvpanic_register_acpi_driver();
> 237 r2 = pci_register_driver(&pvpanic_pci_driver);
238
239 if (r1 && r2) /* all drivers register failed */
240 return 1;
241 else
242 return 0;
243 }
244
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation