LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-23-2008, 08:21 AM   #1
ineya
Member
 
Registered: Jul 2007
Posts: 39

Rep: Reputation: 16
Easiest way to read from device inside another kernel driver


I have some data available in /dev/mtd/0ro. I have no problem to get this data from userspace by opening this device and reading from it. But I need to get this data also within one kernel driver.

What is the easiest way I can do this?
What should I watch for?

Thank you.
 
Old 06-25-2008, 07:05 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Device drivers manage their own data; unless there is a standard kernel-callable API for a given class of driver, your out of luck. It would be very bad for one device driver to go poking around the data of another device driver.

This can be done from userspace, because the driver provides data via ioctl, or other well-known interface.

What exactly are you trying to get or accomplish ?
 
Old 06-26-2008, 10:15 AM   #3
ineya
Member
 
Registered: Jul 2007
Posts: 39

Original Poster
Rep: Reputation: 16
So far I googled, that my best choice is to rely on EXPORT_SYMBOL and use some of the functionality from mtd driver.

I'm working on project dealing with embedded devices, and I need to change one kernel driver behavior based on hardware type. The hardware type is written on flash of the device, so I need to read it and based on this information I'll make some processing in another kernel driver.
 
Old 06-26-2008, 11:54 AM   #4
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
Again, its hard to give you a direct answer to a general question. If that is your only option, then you can certainly go munging around the dirty data structures of some driver's data. Use whatever acceptable means you can, and then only as a last resort do the reverse engineering. But you'll have to live with the consequences.

EXPORT_SYMBOL won't help you with a private data structure inside a driver; if it has no intention of making that data public, all bets are off.
 
Old 06-26-2008, 01:32 PM   #5
dave201
LQ Newbie
 
Registered: Oct 2005
Location: Camelot
Distribution: cent, RH core, slax, slackware... *buntu...
Posts: 28

Rep: Reputation: 15
how about pipemill? sh script a wrapper around the /dev's and then do some while loops with |
 
Old 06-27-2008, 01:07 AM   #6
ineya
Member
 
Registered: Jul 2007
Posts: 39

Original Poster
Rep: Reputation: 16
I think, that my last post wasn't so general, but OK, I can try to make it more concrete.
The driver for st7529 (32 Gray Scale Dot Matrix LCD Controller/Driver
) needs to set resolution, startLine, endLine,.. for frame buffer in st7529_init(). But these settings depends on hardware type. And to get this information I need to access flash memory.

Also I got suggestion to use filp_open, what do you think about this?
Code:
struct file *f = filp_open("/dev/mtd/0ro", O_RDONLY, 0444);
 
/* seek to the beginning, not sure if this is really needed. */
vfs_llseek(f, 0, 0);
 
/* read some data */
vfs_read(f, buffer, buffer_size, &f->f_pos);
 
/* do something with the data ... */
 
/* close the file pointed to by f. */
filp_close(f, 0);
 
Old 06-27-2008, 06:30 AM   #7
ineya
Member
 
Registered: Jul 2007
Posts: 39

Original Poster
Rep: Reputation: 16
Supposing this works, it could be easy way to read from that device:
http://linux.derkeiler.com/Mailing-L...3-10/3671.html
 
Old 09-06-2008, 06:22 AM   #8
jayacharan
LQ Newbie
 
Registered: Sep 2008
Posts: 11

Rep: Reputation: 0
linux device drivers

Quote:
Originally Posted by Mr. C. View Post
Device drivers manage their own data; unless there is a standard kernel-callable API for a given class of driver, your out of luck. It would be very bad for one device driver to go poking around the data of another device driver.

This can be done from userspace, because the driver provides data via ioctl, or other well-known interface.

What exactly are you trying to get or accomplish ?
hi,

i'm new to linux device drivers i would like to read the book

"Essential Linux Device Drivers by Robbins " pdf

If u hav this book plz send it to my mail id:

jayacharan.rampog@gmail.com


and any suggestions to write dd.


thanks in advance,

Jayacharan.
 
Old 09-06-2008, 10:34 AM   #9
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
You are asking in a public for for someone to send you an un-purchased copy of an ebook? Have you no scruples?

You can purchase it here: http://safari.oreilly.com/9780132396554
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How to write a character device driver to read the processor's GDT kiranshadow Linux - General 1 05-10-2008 11:28 AM
Problem in compiling a char device driver formerly for kernel 2.4 on kernel 2.6 payretep Linux - Newbie 6 09-24-2007 05:43 AM
Custom kernel device driver isalmbio Linux - Kernel 0 06-30-2007 10:50 AM
All Newbies Must Read... Easiest Linux Guide Ever (geared towards SuSE) EclipseAgent SUSE / openSUSE 21 10-05-2006 09:05 PM
New Kernel -> Can't read device /dev/hda flamesrock Linux - Software 2 02-07-2005 04:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:15 AM.

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