MTD: export more NAND-related informations to syfs
Subsystems (2)
RFC 1/1 MTD: export more NAND-related informations to syfs
From: Florian Fainelli <[email protected]>
This patch exports the following NAND specific informations through sysfs:
- NAND type
- NAND manufacturer
- NAND onfi version (if set, otherwise, 0)
---
drivers/mtd/mtdcore.c +30 -0
@@ -250,6 +250,33 @@ static ssize_t mtd_name_show(struct device *dev, } static DEVICE_ATTR(name, S_IRUGO, mtd_name_show, NULL); +static ssize_t mtd_nand_type_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct mtd_info *mtd =dev_to_mtd (dev); + +return snprintf (buf,PAGE_SIZE ,"%s\n" , mtd->nand_type); +} +static DEVICE_ATTR(nand_type, S_IRUGO, mtd_nand_type_show, NULL); + +static ssize_t mtd_nand_manufacturer_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct mtd_info *mtd =dev_to_mtd (dev); + +return snprintf (buf,PAGE_SIZE ,"%s\n" , mtd->nand_manufacturer); +} +static DEVICE_ATTR(nand_manufacturer, S_IRUGO, mtd_nand_manufacturer_show, NULL); + +static ssize_t mtd_nand_onfi_version_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct mtd_info *mtd =dev_to_mtd (dev); + +return snprintf (buf,PAGE_SIZE ,"%s\n" , mtd->onfi_version); +} +static DEVICE_ATTR(onfi_version, S_IRUGO, mtd_nand_onfi_version_show, NULL); +static struct attribute *mtd_attrs[] = { &dev_attr_type.attr, &dev_attr_flags.attr,
@@ -260,6 +287,9 @@ static struct attribute *mtd_attrs[] = { &dev_attr_oobsize.attr, &dev_attr_numeraseregions.attr, &dev_attr_name.attr, + &dev_attr_nand_type.attr, + &dev_attr_nand_manufacturer.attr, + &dev_attr_onfi_version, NULL, };
drivers/mtd/mtdpart.c +3 -0
@@ -405,6 +405,9 @@ static struct mtd_part *allocate_partition(struct mtd_info *master, slave->mtd.oobsize = master->oobsize; slave->mtd.oobavail = master->oobavail; slave->mtd.subpage_sft = master->subpage_sft; + slave->mtd.nand_type = master->nand_type; + slave->mtd.nand_manufacturer = master->nand_manufacturer; + slave->mtd.onfi_version = master->onfi_version; slave->mtd.name = name; slave->mtd.owner = master->owner;
drivers/mtd/nand/nand_base.c +48 -1
86 lines not on this page · raw message
include/linux/mtd/mtd.h +5 -0
@@ -168,6 +168,11 @@ struct mtd_info {unsigned int erasesize_mask;unsigned int writesize_mask; +/* NAND related attributes */ +const char *nand_type; +const char *nand_manufacturer; +const char *onfi_version; +// Kernel-only stuff starts here. const char *name;int index;
Signature · 1 line
1.7.4.1
include/linux/mtd/mtd.h struct mtd_info { · line 173
Quoted 3 lines · Florian Fainelli
include/linux/mtd/mtd.h +3
-0+/* NAND related attributes */ +const char *nand_type; +const char *nand_manufacturer;
Why other flashes cannot have type and manufacturer ?
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Hello Artem,
Quoted 6 lines · On Friday 06 May 2011 20:39:33 Artem Bityutskiy wrote:
include/linux/mtd/mtd.h struct mtd_info { · line 173
Quoted 3 lines · Florian Fainelli
include/linux/mtd/mtd.h +3
-0+/* NAND related attributes */ +const char *nand_type; +const char *nand_manufacturer;Why other flashes cannot have type and manufacturer ?
You are right, I will add this for NOR and SPI Flashes. My RFC was more about whether it is granted to add new members to struct mtd_info to get informations
Alternatively, would not it be better to have something like this:
/sys/class/mtd/...
nand0/
manufacturer
type
onfi/
version
jedec_id
...
nor0/
cfi/
manufacturer
idThis would allow us not to abuse the sysfs directory of a MTD partition to contain chip specific informations.
--
Florian
Quoted 8 lines · Florian Fainelli
Hello Artem,
Quoted 5 lines · On Friday 06 May 2011 20:39:33 Artem Bityutskiy wrote:
Quoted 3 lines · Florian Fainelli
include/linux/mtd/mtd.h +3
-0+/* NAND related attributes */ +const char *nand_type; +const char *nand_manufacturer;
Quoted 5 lines
Quoted 1 line
Why other flashes cannot have type and manufacturer ?
You are right, I will add this for NOR and SPI Flashes. My RFC was more about whether it is granted to add new members to struct
mtd_infoto get informations
struct mtd_info describes an mtd device. Things, which are common for all mtd devices should be there, I think.
Quoted 15 lines
Alternatively, would not it be better to have something like this:
/sys/class/mtd/...
nand0/manufacturer type onfi/ version jedec_id ... nor0/ cfi/ manufacturer id
Quoted 2 lines
This would allow us not to abuse the sysfs directory of a MTD partition to contain chip specific informations.
Why do you call it "abuse" and why is it better to "abuse" the directory common to all MTD devices comparing to the directory of the specific MTD device? :-)
I think that everything related to mtdX has to be in the mtdX subdirectory.
Signature · 2 lines
Best Regards, Artem Bityutskiy (Артём Битюцкий)
Quoted 34 lines · Artem Bityutskiy
Quoted 13 lines · Florian Fainelli
Hello Artem,
Quoted 6 lines · On Friday 06 May 2011 20:39:33 Artem Bityutskiy wrote:
include/linux/mtd/mtd.h struct mtd_info { · line 173
Quoted 3 lines · Florian Fainelli
include/linux/mtd/mtd.h +3
-0+/* NAND related attributes */ +const char *nand_type; +const char *nand_manufacturer;Why other flashes cannot have type and manufacturer ?
You are right, I will add this for NOR and SPI Flashes. My RFC was more about whether it is granted to add new members to struct
mtd_infoto get informationsstruct
mtd_infodescribes an mtd device. Things, which are common for all mtd devices should be there, I think.Quoted 15 lines
Alternatively, would not it be better to have something like this:
/sys/class/mtd/...
nand0/manufacturer type onfi/ version jedec_id ... nor0/ cfi/ manufacturer id
Quoted 8 lines
Quoted 1 line
This would allow us not to abuse the sysfs directory of a MTD partition to contain chip specific informations.
Why do you call it "abuse" and why is it better to "abuse" the directory common to all MTD devices comparing to the directory of the specific MTD device? :-)
I think that everything related to mtdX has to be in the mtdX subdirectory.
Couldn't one have a link to some form of chip directory structure, that seems to be a common way of dealing with multiple sys subdirectories that have something else in common than the directory path.
/Ricard
Signature · 3 lines
Ricard Wolf Wanderlöf ricardw(at)axis.com Axis Communications AB, Lund, Sweden www.axis.com Phone +46 46 272 2016 Fax +46 46 13 61 30