1

The PCI-IFIFD CAN implementation (drivers/net/can) of the linux mainline kernel (link) is using the platform_driver structure instead of the pci_driver structure.
I have some trouble differentiating between those two structures. Therefor I informed myself:
- platform driver vs normal device driver
- platform_driver
- pci_driver

According to the first source:

Unlike PCI or USB devices, I2C devices are not enumerated at the hardware level (at run time). Instead, the software must know (at compile time) which devices are connected on each I2C bus segment. So USB and PCI are not platform devices.

If this is the case, why is the PCI ififd implementation using the platform_driver struct?
Additionally how can someone use this driver for pci-cards using ififd?

xMutzelx
  • 566
  • 8
  • 22
  • Maybe the CAN bus is not enumerable so a platform_driver has to pop up soon or later. I don't know exactly how Linux PnP works, maybe the PCI bus driver found a CAN controller, assigned it a pci_device and loaded the right module. This module in turn has to use platform_driver. – Margaret Bloom Oct 04 '18 at 14:24

1 Answers1

2

You have to differentiate platform_driver, which is bus (controller) driver and pci_driver which is PCI device driver (client on the bus).

This is CAN Bus driver CAN bus driver for IFI CANFD controller

Bus controlers (adapters) are registered to kernel as platform_devices

PCI driver provides hooks (callbacks) and structures to register PCI device to kernel PCI layer and bind it to device.

pci_register_driver() is used to register pci_driver structure for a existing PCI device on the PCI bus defined in struct pci_device_id xxx_pci_tbl[] table with Class, Vendor and Device ID to match against a device.

struct pci_driver xxx_driver = {
    .name           = DRV_NAME,
    .probe          = xxx_pci_probe,
    .remove         = xxx_pci_remove,
    .id_table       = xxx_pci_tbl

/Documentation/PCI/pci.txt

Dražen G.
  • 358
  • 3
  • 10