¿Es necesario implementar el controlador i2c como cualquier otro controlador de dispositivo de caracteres?

Soy un novato con los controladores de dispositivos Linux, así que tengan paciencia conmigo. Estoy tratando de implementar un controlador i2c (cliente). Es en el punto donde puedoinsmod, .probe recibe una llamada (debido a las entradas del árbol de dispositivos) y en el .probe puedo leer / escribir en el dispositivo. Excelente.

Sin embargo, necesito poder iniciar lecturas / escrituras desde el espacio de usuario al controlador. Para hacer esto, ¿debe un controlador i2c tener la forma de cualquier otro controlador de dispositivo char? Significado tener unfile_operations estructura para que el espacio de usuario puedaopen, close, read, writeyioctls?

Lo pregunto porque en todos los ejemplos de clientes i2c que he visto, nadie ha implementado estas cosas que he mencionado. Me pregunto cómo diablos iniciaron llamadas desde el espacio de usuario sin elfile_operations estructura configurada. Tal vez fue tan obvio que nadie lo mencionó, no lo sé ... Me pregunto si es porque i2c se conoce como un controlador de dispositivo de plataforma, ¿no necesita esto? Si alguien puede confirmar eso, me ayudaría a dudar de mí mismo.

Si entiendes lo que te pido, ignora el resto. Si está confundido acerca de mi pregunta aquí hay una explicación más concreta de lo que estoy preguntando:

Lo que tengo ahora:

static int device_probe(struct i2c_client           *client,
                        const struct i2c_device_id  *id)
{
    struct device      *dev = &client->dev;
    struct device_data *data;

    /* Check the functionality of the i2c-adapter for smbus byte read/write */
    if (!i2c_check_functionality(client->adapter,
                                 I2C_FUNC_SMBUS_BYTE_DATA))
    {
        printk(KERN_ALERT "%s %d: device required i2c functionality is not supported\n", __func__, __LINE__);
        return -ENODEV;
    }

    /* Allocate memory to hold the device data
     * Using devm_kzalloc so do not have to worry about kfree */
    data = devm_kzalloc(dev, sizeof(struct device_data), GFP_KERNEL);
    if (dev == NULL)
    {
        printk(KERN_ALERT "%s %d: no memory\n", __func__, __LINE__);
        return -ENOMEM;
    }

    /* Record the pointer to current client */
    data->device_i2c_client = client;

    /* Set the client's data field to point to device-specific data struct */
    i2c_set_clientdata(client, data);

    /* Add the device-specific data struct to our collection of device client devices */
    device_data_tbl[id->driver_data] = data;

    /* Do a read, test the access */
    device_read();

    return 0;
}

static int device_remove(struct i2c_client *client)
{
    return 0;
}


int device_read(uint8_t             device_device_id,
                uint16_t const      dev_reg_addr,
                uint8_t *const      read_val)
{
    /* some read access */
}

static struct i2c_device_id device_idtable[] = {
    { "si5342",   0 },
    { },
};
MODULE_DEVICE_TABLE(i2c, device_idtable);

static struct i2c_driver device_driver = {
  .driver = {
    .name = device_DRIVER_NAME,
        .owner  = THIS_MODULE
  },
  .id_table = device_idtable,
    .probe      = device_probe,
    .remove     = device_remove,
};

static int __init device_driver_init(void)
{
    return i2c_add_driver(&device_driver);
}
module_init(device_driver_init);


static void __exit device_driver_exit(void)
{
    return i2c_del_driver(&device_driver);
}
module_exit(device_driver_exit);

Preguntándose si los siguientes elementos deben agregarse en

static struct file_operations oxdrv_fops =
{
    .owner   = THIS_MODULE,
    .release = device_release,
    .open    = device_open,
    .unlocked_ioctl = device_ioctl
};

/* Associated function definitions: device_open, device_ioctl, etc */

alloc_chrdev_region();
cdev_init();

Respuestas a la pregunta(1)

Su respuesta a la pregunta