I2C Write Acknowledge Polling in Linux Kernel

I2C write acknowledge polling in Linux Kernel

It doesn't seem too off the shelf, but

You probably will need to look at having a protocol modification flag like Flag I2C_M_NOSTART
only different, in your patches.
At least there is a way to do it (admittedly a messy way)

I hope for your sake you don't need to put a normal i2c device on the same bus.

Honestly, hardware vendors do stuff like this all the time. They consider the problem "solved" as long as it becomes yours.

I see lots of broken I2C out there and you could make life nicer for other people.

What are the consequences of calling write() with zero length?

Just for the sake of closure, I'm going with Warren Young's idea of updating the driver and publishing the patch (when I get a round tuit).

Linux I2C driver porting issue

Thanks for Dražen Grašovec and user2699113 's help.

I am porting a I2C device driver (chip, client) to Linux-4.9.
This chip accepts different I2C device address for different purpose.
My goal is to create only one I2C device on Linux device tree file (.dts)

I resolved my issue by using i2c_new_dummy().

In driver probe function,
I made two i2c_new_dummy() to create two additional i2c clients.

One(client#1) is for accessing of I2C address 0xAA, another(client#2) is for I2C address 0xA0.

So I can use client#1 to communicate with its SPI flash and use client#2 to access it EEPROM.

Linux Device Driver Program, where the program starts?

"Linux Device Driver" is a good book but it's old!

Basic example:

#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Name and e-mail");
MODULE_DESCRIPTION("my_first_driver");

static int __init insert_mod(void)
{
printk(KERN_INFO "Module constructor");
return 0;
}

static void __exit remove_mod(void)
{
printk(KERN_INFO "Module destructor");
}

module_init(insert_mod);
module_exit(remove_mod);

An up-to-date tutorial, really well written, is "Linux Device Drivers Series"

How can you flush a write using a file descriptor?

You have two choices:

  1. Use fileno() to obtain the file descriptor associated with the stdio stream pointer

  2. Don't use <stdio.h> at all, that way you don't need to worry about flush either - all writes will go to the device immediately, and for character devices the write() call won't even return until the lower-level IO has completed (in theory).

For device-level IO I'd say it's pretty unusual to use stdio. I'd strongly recommend using the lower-level open(), read() and write() functions instead (based on your later reply):

int fd = open("/dev/i2c", O_RDWR);
ioctl(fd, IOCTL_COMMAND, args);
write(fd, buf, length);


Related Topics



Leave a reply



Submit