xref: /linux/drivers/misc/pvpanic/pvpanic-pci.c (revision afeea2758b4f1210361ce2a91d8fa3e7df606ad2)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  *  Pvpanic PCI Device Support
4  *
5  *  Copyright (C) 2021 Oracle.
6  */
7 
8 #include <linux/errno.h>
9 #include <linux/module.h>
10 #include <linux/pci.h>
11 #include <linux/types.h>
12 
13 #include "pvpanic.h"
14 
15 #define PCI_DEVICE_ID_REDHAT_PVPANIC     0x0011
16 
17 MODULE_AUTHOR("Mihai Carabas <mihai.carabas@oracle.com>");
18 MODULE_DESCRIPTION("pvpanic device driver");
19 MODULE_LICENSE("GPL");
20 
21 static int pvpanic_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
22 {
23 	void __iomem *base;
24 	int ret;
25 
26 	ret = pcim_enable_device(pdev);
27 	if (ret < 0)
28 		return ret;
29 
30 	base = pcim_iomap(pdev, 0, 0);
31 	if (!base)
32 		return -ENOMEM;
33 
34 	return devm_pvpanic_probe(&pdev->dev, base);
35 }
36 
37 static const struct pci_device_id pvpanic_pci_id_tbl[]  = {
38 	{ PCI_DEVICE(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_PVPANIC)},
39 	{}
40 };
41 MODULE_DEVICE_TABLE(pci, pvpanic_pci_id_tbl);
42 
43 static struct pci_driver pvpanic_pci_driver = {
44 	.name =         "pvpanic-pci",
45 	.id_table =     pvpanic_pci_id_tbl,
46 	.probe =        pvpanic_pci_probe,
47 	.dev_groups =   pvpanic_dev_groups,
48 };
49 module_pci_driver(pvpanic_pci_driver);
50