Linux kernel driver same device on different buses? -


is there example of same device using different buses, example spi , i2c (simultaneously, depending on choice)?

i interested in device have common routines, uses different read/write functions.

for example adc has common function calibration or triggering (never seen in kernel adc drivers, why not?), different functions read samples different sources.

how such driver can realized? should in module? :

static struct i2c_driver my_i2c_driver = {          .driver = {                  .name = "my-i2c-driver",          },          .probe = my_i2c_driver_probe,          .remove = my_i2c_driver_remove, };  static struct spi_driver my_spi_driver = {          .driver = {                  .name   = "my-spi-driver",          },          .probe = my_spi_driver_probe,          .remove = my_spi_driver_remove,          };  etc... read/write, ops 

i'm interested in theory, if "no need", "no 1 that."

actually in 3.10.25 kernel there such example,

a st magnetometer lis3mdl wich has indeed 2 interface i2c/spi, controlled via gpio input.

with drivers included in kernel official tree, located in drivers/iio/magnetometer.

with 2 separate driver modules located in st_magn_i2c.c , st_magn_spi.c

st_magn_i2c.c:

static struct spi_driver st_magn_driver = {         .driver = {                 .owner = this_module,                 .name = "st-magn-spi",         },         .probe = st_magn_spi_probe,         .remove = st_magn_spi_remove,         .id_table = st_magn_id_table, }; 

st_magn_spi.c:

static struct i2c_driver st_magn_driver = {         .driver = {                 .owner = this_module,                 .name = "st-magn-i2c",         },         .probe = st_magn_i2c_probe,         .remove = st_magn_i2c_remove,         .id_table = st_magn_id_table, }; 

such devices times happens - example pca2129t rtc.

so in assume example looking for, though wanted more trickier (like usb , else) or basic lead.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -