Exact usage of MODULE_DEVICE_TABLE

466 views
Skip to first unread message

Amrit Pal Singh

unread,
Jan 18, 2017, 11:16:11 AM1/18/17
to Anil Kumar Pugalia, inside...@googlegroups.com
Dear all,

What is the exact usage of MODULE_DEVICE_TABLE???

static const struct i2c_device_id si470x_i2c_id[] = {
    /* Generic Entry */
    { "si470x", 0 },
    /* Terminating entry */
    { }
};
MODULE_DEVICE_TABLE(i2c, si470x_i2c_id);

static struct i2c_driver si470x_i2c_driver = {
    .driver = {
        .name       = "si470x", //this name should match 
        .owner      = THIS_MODULE,
    },
    .probe          = si470x_i2c_probe,
    .remove         = __devexit_p(si470x_i2c_remove),
    .suspend        = si470x_i2c_suspend,
    .resume         = si470x_i2c_resume,
    .id_table       = si470x_i2c_id,
};


module_init()
{
/* add the driver to the list of i2c drivers in the driver core */
/* When registration returns, the driver core
 * will have called probe() for all matching-but-unbound devices.
 */
return i2c_add_driver(&si470x_i2c_driver);
}

What will happen if I will not use MODULE_DEVICE_TABLE.

My probe wont happen or what???


Many Thanks,

Amrit.

Anil Kumar Pugalia

unread,
Jan 19, 2017, 4:30:59 AM1/19/17
to Inside Linux

This is mainly for auto-loading the driver, when the device is detected, like when you insert your pen drive, its driver is automatically loaded. In that case the driver should have a similar line with the first parameter as usb.

Regards
Anil
Passion: http://sysplay.in (Playing with Systems)

Amrit Pal Singh

unread,
Jan 19, 2017, 8:06:00 AM1/19/17
to inside...@googlegroups.com, Anil Kumar Pugalia
Hi Anil,

Thanks.
i.e what I read.

But we wont have any i2c hot pluggable devices. Would we?

So do we need to add MODULE_DEVICE_TABLE for i2c devices or for the devices which are part of the PCB like audio codecs?

Many Regards,
Amrit Pal Singh.

--
You received this message because you are subscribed to the Google Groups "SysPlay's Inside Linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inside_linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anil Kumar Pugalia

unread,
Jan 20, 2017, 6:26:34 AM1/20/17
to inside...@googlegroups.com

It need not be hot pluggable. The device is either there or not there. If there, the driver would get autoloaded (on detection through DTB), otherwise not get loaded.

Regards
Anil
Passion: http://sysplay.in (Playing with Systems)
Reply all
Reply to author
Forward
0 new messages