Home | History | Annotate | Download | only in oslib

Lines Matching refs:mtd

20  * This file  is part of the MTD library. Implements pre-2.6.30 kernels support,
21 * where MTD did not have sysfs interface. The main limitation of the old
26 /* Imported from mtd-utils by dehrenberg */
36 #include <mtd/mtd-user.h>
42 #define MTD_PROC_FILE "/proc/mtd"
43 #define MTD_DEV_PATT "/dev/mtd%d"
49 #define PROC_MTD_PATT "mtd%d: %llx %x"
52 * struct proc_parse_info - /proc/mtd parsing information.
53 * @mtd_num: MTD device number
57 * @buf: contents of /proc/mtd
139 return errmsg("too long mtd%d device name", pi->mtd_num);
153 * This function is just checks that MTD is present in the system. Returns
155 * errno contains zero if MTD is not present in the system, or contains the
176 * @info: the MTD device information is returned here
178 * When the kernel does not provide sysfs files for the MTD subsystem,
179 * fall-back to parsing the /proc/mtd file to determine whether an mtd device
201 * @info: the MTD device information is returned here
228 * @node: name of the MTD device node
229 * @mtd: the MTD device information is returned here
234 int legacy_get_dev_info(const char *node, struct mtd_dev_info *mtd)
245 normsg("MTD subsystem is old and does not support "
246 "sysfs, so MTD character device nodes have "
255 memset(mtd, '\0', sizeof(struct mtd_dev_info));
256 mtd->major = major(st.st_rdev);
257 mtd->minor = minor(st.st_rdev);
259 if (mtd->major != MTD_DEV_MAJOR) {
261 return errmsg("\"%s\" has major number %d, MTD devices have "
262 "major %d", node, mtd->major, MTD_DEV_MAJOR);
265 mtd->mtd_num = mtd->minor / 2;
283 mtd->bb_allowed = 0;
285 mtd->bb_allowed = 1;
287 mtd->type = ui.type;
288 mtd->size = ui.size;
289 mtd->eb_size = ui.erasesize;
290 mtd->min_io_size = ui.writesize;
291 mtd->oob_size = ui.oobsize;
293 if (mtd->min_io_size <= 0) {
294 errmsg("mtd%d (%s) has insane min. I/O unit size %d",
295 mtd->mtd_num, node, mtd->min_io_size);
298 if (mtd->eb_size <= 0 || mtd->eb_size < mtd->min_io_size) {
299 errmsg("mtd%d (%s) has insane eraseblock size %d",
300 mtd->mtd_num, node, mtd->eb_size);
303 if (mtd->size <= 0 || mtd->size < mtd->eb_size) {
304 errmsg("mtd%d (%s) has insane size %lld",
305 mtd->mtd_num, node, mtd->size);
308 mtd->eb_cnt = mtd->size / mtd->eb_size;
310 switch(mtd->type) {
312 errmsg("mtd%d (%s) is removable and is not present",
313 mtd->mtd_num, node);
316 strcpy((char *)mtd->type_str, "ram");
319 strcpy((char *)mtd->type_str, "rom");
322 strcpy((char *)mtd->type_str, "nor");
325 strcpy((char *)mtd->type_str, "nand");
328 strcpy((char *)mtd->type_str, "mlc-nand");
331 strcpy((char *)mtd->type_str, "dataflash");
334 strcpy((char *)mtd->type_str, "ubi");
341 mtd->writable = 1;
342 mtd->subpage_size = mtd->min_io_size;
348 * we have to parse /proc/mtd to get it.
355 if (pi.mtd_num == mtd->mtd_num) {
356 strcpy((char *)mtd->name, pi.name);
361 errmsg("mtd%d not found in \"%s\"", mtd->mtd_num, MTD_PROC_FILE);
372 * @node: name of the MTD device node
373 * @mtd: the MTD device information is returned here
378 int legacy_get_dev_info1(int mtd_num, struct mtd_dev_info *mtd)
383 return legacy_get_dev_info(node, mtd);