sysfs support for mtd
Hi,
I have added a sysfs support for mtd. There was an earlier discussion some time back
(http://lists.infradead.org/pipermail/linux-mtd/2006-December/016952.html)
about adding sysfs support for mtd.
Here's the design:
o Each mtd partition appears as a directory under /sys/devices/mtd/
o The following fields from struct mtd_info are exported as files - eccsize, ecctype, erasesize, numeraseregions, oobsize, size, type, writesize.
--------------
Eg:
# ls -l /sys/devices/mtd drwxr-xr-x 2 root root 0 Jan 1 00:00 mtd0 drwxr-xr-x 2 root root 0 Jan 1 00:00 mtd1 drwxr-xr-x 2 root root 0 Jan 1 00:00 mtd2 drwxr-xr-x 2 root root 0 Jan 1 00:00 mtd3 # ls -l /sys/devices/mtd/mtd0/ -r--r--r-- 1 root root 4096 Jan 1 00:00 bbt -r--r--r-- 1 root root 4096 Jan 1 00:00 eccsize -r--r--r-- 1 root root 4096 Jan 1 00:00 ecctype -r--r--r-- 1 root root 4096 Jan 1 00:00 erasesize -r--r--r-- 1 root root 4096 Jan 1 00:00 numeraseregions -r--r--r-- 1 root root 4096 Jan 1 00:00 oobsize -r--r--r-- 1 root root 4096 Jan 1 00:00 size -r--r--r-- 1 root root 4096 Jan 1 00:00 type -r--r--r-- 1 root root 4096 Jan 1 00:00 writesize # cat /sys/devices/mtd/mtd0/oobsize 64 -----------
I would like to get some suggestions from the group before sending out a patch:
o Currently the fields type, ecctype are integers. Should these be converted into appropriate strings as per #defines from mtd-abi.h
Eg: cat /sys/devices/mtd/mtd0/type
shows 4. Should this show MTD_NANDFLASH instead ?
o I am not sure where an additional link from bus to mtd should be added in the sysfs hierarchy. Should it be /sys/bus/platform/devices -> ../../../devices/mtd -OR-/sys/bus/platform/ -> ../../devices/mtd
o Any other comments/suggestions.
thanks,
-sid
____________________________________________________________________________________
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
http://new.toolbar.yahoo.com/toolbar/features/mail/index.php
Quoted 6 lines · Siddharth Choudhuri
Here's the design:
o Each mtd partition appears as a directory under/sys/devices/mtd/
o The following fields from structmtd_infoare exported as files - eccsize, ecctype, erasesize, numeraseregions, oobsize, size, type, writesize.
I doubt OOB-related stuff has to be exposed. We see many new flash controllers which do not let you access OOB. It is better to avoid OOB usage altogether, so I would not even exposed that stuff in sysfs.
Quoted 7 lines
I would like to get some suggestions from the group before sending out a patch:
o Currently the fields type, ecctype are integers. Should these be converted into appropriate strings as per #defines frommtd-abi.h
Eg: cat/sys/devices/mtd/mtd0/type
shows 4. Should this showMTD_NANDFLASHinstead ?
I think yes, it should be something like "NAND", "OneNAND", "NOR", "DataFlash", etc.
Quoted 5 lines
o I am not sure where an additional link from bus to mtd should be added in the sysfs hierarchy. Should it be
/sys/bus/platform/devices-> ../../../devices/mtd -OR-/sys/bus/platform/-> ../../devices/mtd
No idea, but I've always thought sysfs core automatically puts these links. All you have to do is to define your bus object which is "platform" bus, and the stuff will appear. Although I am not sure.
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)
Quoted 7 lines
Quoted 2 lines
o I am not sure where an additional link from bus
to
Quoted 1 line
mtd should be added in the sysfs hierarchy. Should
it
Quoted 1 line
be
/sys/bus/platform/devices->../../../devices/mtd
Quoted 9 lines
Quoted 2 lines
-OR-
/sys/bus/platform/-> ../../devices/mtdNo idea, but I've always thought sysfs core automatically puts these
links. All you have to do is to define your bus object which is
"platform" bus, and the stuff will appear. Although I am not sure.
Thanks for the suggestions. I added a link from /sys/bus/platform/devices/mtd -> /sys/devices/mtd. Link can be created in sysfs using a call to sysfs_create_link() function.
I will send a patch after coding the suggestions and running a few more tests.
-sid
____________________________________________________________________________________
Need a vacation? Get great deals
to amazing places on Yahoo! Travel.
http://travel.yahoo.com/