Accessing an MTD device from kernel space

Thomas Gleixner tglx at
Wed May 26 17:26:29 EDT 2004

On Wednesday 26 May 2004 23:21, Eisenhut, Daniel (MED) wrote:
> To list,
> I've successfully setup MTD devices for our NOR flash chips and
> everything is working great from userspace.  But I have a need to access
> the NOR flash from within kernelspace, such as in a /proc entry.
> What is the best way to access the flash from within the kernel?  The
> only way I've be able to so far is to just dereference a pointer
> pointing to the flash address.  But this creates two issues (that I know
> about):
> 1. A race condition between my proc entry that reads the flash and
> another process using the MTD device.
> 2. The MTD device does not always leave the flash chip in read mode.
> Is there anything setup in the current MTD code to allow access from
> within the kernel?

Just use the mtd API which is used from fs drivers and anything else which 
accessed the mtd devices from kernel space

mtd->read(....), mtd->erase(...) 

Steve Ballmer quotes the statistic that IT pros spend 70 percent of their 
time managing existing systems. That couldn’t have anything to do with 
the fact that 99 percent of these systems run Windows, could it?
linutronix - competence in embedded & realtime linux
mail: tglx at

More information about the linux-mtd mailing list