1 // SPDX-License-Identifier: GPL-2.0+
2 // Copyright 2019 IBM Corp.
3 #include <linux/module.h>
4 #include "ocxl_internal.h"
7 * Any opencapi device which wants to use this 'generic' driver should
8 * use the 0x062B device ID. Vendors should define the subsystem
9 * vendor/device ID to help differentiate devices.
11 static const struct pci_device_id ocxl_pci_tbl
[] = {
12 { PCI_DEVICE(PCI_VENDOR_ID_IBM
, 0x062B), },
15 MODULE_DEVICE_TABLE(pci
, ocxl_pci_tbl
);
17 static int ocxl_probe(struct pci_dev
*dev
, const struct pci_device_id
*id
)
20 struct ocxl_afu
*afu
, *tmp
;
22 struct list_head
*afu_list
;
24 fn
= ocxl_function_open(dev
);
28 pci_set_drvdata(dev
, fn
);
30 afu_list
= ocxl_function_afu_list(fn
);
32 list_for_each_entry_safe(afu
, tmp
, afu_list
, list
) {
33 // Cleanup handled within ocxl_file_register_afu()
34 rc
= ocxl_file_register_afu(afu
);
36 dev_err(&dev
->dev
, "Failed to register AFU '%s' index %d",
37 afu
->config
.name
, afu
->config
.idx
);
44 static void ocxl_remove(struct pci_dev
*dev
)
48 struct list_head
*afu_list
;
50 fn
= pci_get_drvdata(dev
);
51 afu_list
= ocxl_function_afu_list(fn
);
53 list_for_each_entry(afu
, afu_list
, list
) {
54 ocxl_file_unregister_afu(afu
);
57 ocxl_function_close(fn
);
60 struct pci_driver ocxl_pci_driver
= {
62 .id_table
= ocxl_pci_tbl
,
64 .remove
= ocxl_remove
,
65 .shutdown
= ocxl_remove
,