LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 05-16-2012, 01:04 PM   #1
gsmith
LQ Newbie
 
Registered: May 2012
Posts: 1

Rep: Reputation: Disabled
linux kernel at24 device driver


This question is regarding understanding linux kernel driver at24 that handles most I2C EEPROM devices (located at kernel/drivers/misc/eeprom/at24.c).

1. I am not able to figure out who calls the read/write routines within the at24 driver. I don't see a file operations (fops) structure being initialized with a .read or .write entry within the driver

Initially I thought the I2C bus driver must be invoking them in response to user I2C operations. To find this I added debug statements within those routines and invoked a test program from user space which reads and writes to the eeprom. The reads and writes are successful but none of the debug prints get printed from the at24 device driver read or write routines.

2. Another related question is about the platform data. There is no good documentation except for some comments about what should go in the fields byte_len and page_size. Is byte_len which is defined as /* size (sum of all address) */ for say a 2K eeprom equal to 2Kbits/8 (bits per byte) = 256.

Is Page size the bytes within a single page = 8 bytes ?

I tried all possible values but the kernel prints errors in response at init time and so asking here.
 
Old 05-17-2012, 04:45 AM   #2
emntech
LQ Newbie
 
Registered: May 2012
Posts: 8

Rep: Reputation: Disabled
For your first question, the interface to the driver is not through char or block, it is through the sysfs. A file will be created in the sysfs and when you access this file the read and write functions will be called. read/write functions are registered with the sysfs like this:

sysfs_bin_attr_init(&at24->bin);
at24->bin.attr.name = "eeprom";
at24->bin.attr.mode = chip.flags & AT24_FLAG_IRUGO ? S_IRUGO : S_IRUSR;
at24->bin.read = at24_bin_read;
at24->bin.size = chip.byte_len;

at24->bin.write = at24_bin_write;
at24->bin.attr.mode |= S_IWUSR;
err = sysfs_create_bin_file(&client->dev.kobj, &at24->bin);

A file with name 'eeprom' will be created in the sysfs.

byte_len will be size of eeprom in bytes and page_size will be page size in bytes for writes.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
device driver for zigbee for the linux kernel 2.6.20 or 2.6.24??? alsexy Linux - Newbie 4 01-24-2013 08:43 AM
Writing device driver and Linux Kernel MarkoSan Linux - General 17 02-23-2012 12:25 AM
How to compile device driver code for linux kernel 2.4.21 shrikantpwr245 Programming 1 06-04-2006 06:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 08:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration