[Suzaku-en:00153] Re: device driver read/write

Chris McHarg email@hidden
Wed Feb 22 16:21:39 JST 2006


Ford Sleeman wrote:
> I have written a simple device driver to access some software 
> addressable registers. The way the driver is set up now, I can only read 
> the driver sequentially into a single buffer. What I want is to access a 
> single byte in the memory mapped device. The problem is that the user 
> functions have this prototype:  ssize_t read(int /fildes/, void */buf/, 
> size_t nbyte) but the driver functions have the prototype: ssize_t 
> read(struct file *filp, char *buf, size_t count, loff_t *f_pos). This 
> works except there is no way to get the offset value into the driver. Is 
> there anyway to get these four parameters to the driver? I can treat the 
> count as an offset and get the byte addressing to work but I would 
> rather have access to all four parameter. Does anybody know how to do this?

Hi Ford,

You can use the lseek() system call or the stdio equivalent fseek() to 
set the offset position which is passed to the driver read and write 
methods.

Otherwise you could use the pread/pwrite system calls, in which you can 
specify the offset.

Chris





More information about the suzaku-en mailing list