xref: /openbmc/linux/drivers/scsi/fdomain_pci.c (revision 6c33a6f4)
1 // SPDX-License-Identifier: GPL-2.0
2 
3 #include <linux/module.h>
4 #include <linux/pci.h>
5 #include "fdomain.h"
6 
7 static int fdomain_pci_probe(struct pci_dev *pdev,
8 			     const struct pci_device_id *d)
9 {
10 	int err;
11 	struct Scsi_Host *sh;
12 
13 	err = pci_enable_device(pdev);
14 	if (err)
15 		goto fail;
16 
17 	err = pci_request_regions(pdev, "fdomain_pci");
18 	if (err)
19 		goto disable_device;
20 
21 	err = -ENODEV;
22 	if (pci_resource_len(pdev, 0) == 0)
23 		goto release_region;
24 
25 	sh = fdomain_create(pci_resource_start(pdev, 0), pdev->irq, 7,
26 			    &pdev->dev);
27 	if (!sh)
28 		goto release_region;
29 
30 	pci_set_drvdata(pdev, sh);
31 	return 0;
32 
33 release_region:
34 	pci_release_regions(pdev);
35 disable_device:
36 	pci_disable_device(pdev);
37 fail:
38 	return err;
39 }
40 
41 static void fdomain_pci_remove(struct pci_dev *pdev)
42 {
43 	struct Scsi_Host *sh = pci_get_drvdata(pdev);
44 
45 	fdomain_destroy(sh);
46 	pci_release_regions(pdev);
47 	pci_disable_device(pdev);
48 }
49 
50 static struct pci_device_id fdomain_pci_table[] = {
51 	{ PCI_DEVICE(PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70) },
52 	{}
53 };
54 MODULE_DEVICE_TABLE(pci, fdomain_pci_table);
55 
56 static struct pci_driver fdomain_pci_driver = {
57 	.name		= "fdomain_pci",
58 	.id_table	= fdomain_pci_table,
59 	.probe		= fdomain_pci_probe,
60 	.remove		= fdomain_pci_remove,
61 	.driver.pm	= FDOMAIN_PM_OPS,
62 };
63 
64 module_pci_driver(fdomain_pci_driver);
65 
66 MODULE_AUTHOR("Ondrej Zary, Rickard E. Faith");
67 MODULE_DESCRIPTION("Future Domain TMC-3260 PCI SCSI driver");
68 MODULE_LICENSE("GPL");
69