LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (https://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   How Probe will bind driver and device in below driver snippet (https://www.linuxquestions.org/questions/linux-kernel-70/how-probe-will-bind-driver-and-device-in-below-driver-snippet-4175630298/)

mrigendra 05-23-2018 09:53 AM

How Probe will bind driver and device in below driver snippet
 
How Probe will bind driver and device in below driver snippet. I was trying to understand i2c_device_id and platform_device_id.For platform_device_id I see these type of drivers and device declarations. The names in id table are different than driver.driver.name How they will be matched later ? file

/drivers/media/tuners/it913x.c

Code:

static const struct platform_device_id it913x_id_table[] = {
    {"it9133ax-tuner", 1},
    {"it9133bx-tuner", 2},
    {},
};
MODULE_DEVICE_TABLE(platform, it913x_id_table);

static struct platform_driver it913x_driver = {
    .driver = {
        .name  = "it913x",
        .suppress_bind_attrs    = true,
    },
    .probe      = it913x_probe,
    .remove    = it913x_remove,
    .id_table  = it913x_id_table,
};

At first I thought that these names should be in arch directory as board file entries. So of the drivers i can find board entries (such as /drivers/crypto/marvell/cesa.c) but for some I can't.

I referred this

https://lwn.net/Articles/448499/

"If an ID table is present, the platform bus code will scan through it every time it has to find a driver for a new platform device. If the device's name matches the name in an ID table entry, the device will be given to the driver for management a pointer to the matching ID table entry will be made available to the driver as well."

the bold line I thought should be if the driver's name and device name in the ID table matches then the device will be given to the driver for management.

Am I correct ?

How does platform_device_id helps in binding the device and driver?

AwesomeMachine 05-26-2018 12:13 AM

I think one is for legacy applications and hardware. So, just to make sure, you should use both.


All times are GMT -5. The time now is 05:44 AM.