|
@@ -49,6 +49,7 @@
|
|
|
#include <linux/string.h>
|
|
|
|
|
|
#include "pci_hw.h"
|
|
|
+#include "pci.h"
|
|
|
#include "core.h"
|
|
|
#include "cmd.h"
|
|
|
#include "port.h"
|
|
@@ -56,26 +57,8 @@
|
|
|
|
|
|
static const char mlxsw_pci_driver_name[] = "mlxsw_pci";
|
|
|
|
|
|
-static const struct pci_device_id mlxsw_pci_id_table[] = {
|
|
|
- {PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_SWITCHX2), 0},
|
|
|
- {PCI_VDEVICE(MELLANOX, PCI_DEVICE_ID_MELLANOX_SPECTRUM), 0},
|
|
|
- {0, }
|
|
|
-};
|
|
|
-
|
|
|
static struct dentry *mlxsw_pci_dbg_root;
|
|
|
|
|
|
-static const char *mlxsw_pci_device_kind_get(const struct pci_device_id *id)
|
|
|
-{
|
|
|
- switch (id->device) {
|
|
|
- case PCI_DEVICE_ID_MELLANOX_SWITCHX2:
|
|
|
- return MLXSW_DEVICE_KIND_SWITCHX2;
|
|
|
- case PCI_DEVICE_ID_MELLANOX_SPECTRUM:
|
|
|
- return MLXSW_DEVICE_KIND_SPECTRUM;
|
|
|
- default:
|
|
|
- BUG();
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
#define mlxsw_pci_write32(mlxsw_pci, reg, val) \
|
|
|
iowrite32be(val, (mlxsw_pci)->hw_addr + (MLXSW_PCI_ ## reg))
|
|
|
#define mlxsw_pci_read32(mlxsw_pci, reg) \
|
|
@@ -1553,7 +1536,7 @@ static int mlxsw_pci_init(void *bus_priv, struct mlxsw_core *mlxsw_core,
|
|
|
|
|
|
err = request_irq(mlxsw_pci->msix_entry.vector,
|
|
|
mlxsw_pci_eq_irq_handler, 0,
|
|
|
- mlxsw_pci_driver_name, mlxsw_pci);
|
|
|
+ mlxsw_pci->bus_info.device_kind, mlxsw_pci);
|
|
|
if (err) {
|
|
|
dev_err(&pdev->dev, "IRQ request failed\n");
|
|
|
goto err_request_eq_irq;
|
|
@@ -1793,6 +1776,7 @@ static int mlxsw_pci_sw_reset(struct mlxsw_pci *mlxsw_pci)
|
|
|
|
|
|
static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|
|
{
|
|
|
+ const char *driver_name = pdev->driver->name;
|
|
|
struct mlxsw_pci *mlxsw_pci;
|
|
|
int err;
|
|
|
|
|
@@ -1806,7 +1790,7 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|
|
goto err_pci_enable_device;
|
|
|
}
|
|
|
|
|
|
- err = pci_request_regions(pdev, mlxsw_pci_driver_name);
|
|
|
+ err = pci_request_regions(pdev, driver_name);
|
|
|
if (err) {
|
|
|
dev_err(&pdev->dev, "pci_request_regions failed\n");
|
|
|
goto err_pci_request_regions;
|
|
@@ -1857,7 +1841,7 @@ static int mlxsw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
|
|
goto err_msix_init;
|
|
|
}
|
|
|
|
|
|
- mlxsw_pci->bus_info.device_kind = mlxsw_pci_device_kind_get(id);
|
|
|
+ mlxsw_pci->bus_info.device_kind = driver_name;
|
|
|
mlxsw_pci->bus_info.device_name = pci_name(mlxsw_pci->pdev);
|
|
|
mlxsw_pci->bus_info.dev = &pdev->dev;
|
|
|
|
|
@@ -1909,33 +1893,30 @@ static void mlxsw_pci_remove(struct pci_dev *pdev)
|
|
|
kfree(mlxsw_pci);
|
|
|
}
|
|
|
|
|
|
-static struct pci_driver mlxsw_pci_driver = {
|
|
|
- .name = mlxsw_pci_driver_name,
|
|
|
- .id_table = mlxsw_pci_id_table,
|
|
|
- .probe = mlxsw_pci_probe,
|
|
|
- .remove = mlxsw_pci_remove,
|
|
|
-};
|
|
|
+int mlxsw_pci_driver_register(struct pci_driver *pci_driver)
|
|
|
+{
|
|
|
+ pci_driver->probe = mlxsw_pci_probe;
|
|
|
+ pci_driver->remove = mlxsw_pci_remove;
|
|
|
+ return pci_register_driver(pci_driver);
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(mlxsw_pci_driver_register);
|
|
|
|
|
|
-static int __init mlxsw_pci_module_init(void)
|
|
|
+void mlxsw_pci_driver_unregister(struct pci_driver *pci_driver)
|
|
|
{
|
|
|
- int err;
|
|
|
+ pci_unregister_driver(pci_driver);
|
|
|
+}
|
|
|
+EXPORT_SYMBOL(mlxsw_pci_driver_unregister);
|
|
|
|
|
|
+static int __init mlxsw_pci_module_init(void)
|
|
|
+{
|
|
|
mlxsw_pci_dbg_root = debugfs_create_dir(mlxsw_pci_driver_name, NULL);
|
|
|
if (!mlxsw_pci_dbg_root)
|
|
|
return -ENOMEM;
|
|
|
- err = pci_register_driver(&mlxsw_pci_driver);
|
|
|
- if (err)
|
|
|
- goto err_register_driver;
|
|
|
return 0;
|
|
|
-
|
|
|
-err_register_driver:
|
|
|
- debugfs_remove_recursive(mlxsw_pci_dbg_root);
|
|
|
- return err;
|
|
|
}
|
|
|
|
|
|
static void __exit mlxsw_pci_module_exit(void)
|
|
|
{
|
|
|
- pci_unregister_driver(&mlxsw_pci_driver);
|
|
|
debugfs_remove_recursive(mlxsw_pci_dbg_root);
|
|
|
}
|
|
|
|
|
@@ -1945,4 +1926,3 @@ module_exit(mlxsw_pci_module_exit);
|
|
|
MODULE_LICENSE("Dual BSD/GPL");
|
|
|
MODULE_AUTHOR("Jiri Pirko <jiri@mellanox.com>");
|
|
|
MODULE_DESCRIPTION("Mellanox switch PCI interface driver");
|
|
|
-MODULE_DEVICE_TABLE(pci, mlxsw_pci_id_table);
|