0
votes

in linux kernel 3.3, the drivers/mmc/host/dw-mmc.c file had this part.

static int __init dw_mci_init(void)
{
    return platform_driver_probe(&dw_mci_driver, dw_mci_probe);
}

static void __exit dw_mci_exit(void)
{
    platform_driver_unregister(&dw_mci_driver);
}

module_init(dw_mci_init);
module_exit(dw_mci_exit);

at some point during the kernel booting (actually in start_kernel(), in init_call loop), the dw_mci_init is called(because it's with __init tag) and the probe function probes the device and installs the driver. Some years ago I have modified this driver to implement our own SD card controller driver.

Now, when I look at linux kernel 5.4.21, above part of the same file has changed like this :

static int __init dw_mci_init(void)
{
    pr_info("Synopsys Designware Multimedia Card Interface Driver\n");
    return 0;
}

static void __exit dw_mci_exit(void)
{
}

module_init(dw_mci_init);
module_exit(dw_mci_exit);

The driver init function does nothing but a print. What happened? I guess somewhere in the kernel initialization, the kernel parses the "device tree" (flattend device tree, .dtb file) and the matching platform drivers are found and called to initialize the deivce and driver. Is this correct? and if so, where in the kernel source can I the device tree (flattend device tree) parsing and device driver installation operation?

1

1 Answers

1
votes

What happened?

The driver has been split into separate modules to handle devices from different bus types. The platform driver is in the "dw_mmc-pltfrm" module. (This also handles devices configured by device tree nodes.) There is also a PCI driver in the "dw_mmc-pci" module. The old "dw_mmc" module exports functions in common to the bus type-specific driver modules.

In "dw_mmc-pltfrm.c", the module init and exit functions are defined by the helper macro call:

module_platform_driver(dw_mci_pltfm_driver);