i2c application

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

I am writing an i2c application.
The i2c chip which i want to communicate is an audio codec chip, which
has an ASoC audio
driver in the kernel.

But my ioctl()  is failing.
ioctl(file,I2C_SLAVE,addr), my addr is 0x18
which returns -EBUSY.
The reason is that there is already an i2c_client for this addr which
is created as a part of
audio driver.
So if i disable my ASoC driver, ioctl is working.

Only way i can make my application to work is to add dev interface in
my audio driver.
If Someone has got a better suggestion please let me know?


I am pasting my application code below.

int main()
{
        int file;
        int adapter_nr = 2; /* probably dynamically determined */
        unsigned long addr = 0x18; /* The I2C address */
        char filename[20] = {0};
        unsigned int size;
        char buf[5] = {0};
        int res;
        int reg = 0x10;
        int value,ret;

        sprintf(filename,"/dev/i2c-%d",adapter_nr);
        printf("Device File: %s\n",filename);
        printf("Device Address(I2C): 0x%x\n",addr);

        if ((file = open(filename,O_RDWR|O_SYNC)) < 0) {
                /* ERROR HANDLING; you can check errno to see what went wrong */
                printf("Error Occured while opening Device File.!!\n");
                exit(1);
        } else {
                printf("Device File Opened Successfully !!\n");
        }

        addr = (0x18);
        res = ioctl(file,I2C_SLAVE,addr);
        if (res < 0) {
                printf("Error Occrued inside IOCTL!! : res = %d\n\n",res);
                printf("error no= %d\n\n",errno);
                perror("Error Reason: ");
                /* ERROR HANDLING; you can check errno to see what went
wrong */
                exit(1);
        }


Regards,
Arun Ks

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux