blob: 3e05ce7b89e5d8c63a2e6ba64c05e5ae087c8c40 [file] [log] [blame]
Ondrej Zary68046d52019-05-14 19:23:08 +02001// SPDX-License-Identifier: GPL-2.0
2
3#include <linux/module.h>
4#include <linux/pci.h>
5#include "fdomain.h"
6
7static 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
33release_region:
34 pci_release_regions(pdev);
35disable_device:
36 pci_disable_device(pdev);
37fail:
38 return err;
39}
40
41static 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
50static struct pci_device_id fdomain_pci_table[] = {
51 { PCI_DEVICE(PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70) },
52 {}
53};
54MODULE_DEVICE_TABLE(pci, fdomain_pci_table);
55
56static 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
64module_pci_driver(fdomain_pci_driver);
65
66MODULE_AUTHOR("Ondrej Zary, Rickard E. Faith");
67MODULE_DESCRIPTION("Future Domain TMC-3260 PCI SCSI driver");
68MODULE_LICENSE("GPL");