Lines Matching +full:mtd +full:- +full:name

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright © 2002 SYSGO Real-Time Solutions GmbH
6 * Copyright © 2002-2010 David Woodhouse <dwmw2@infradead.org>
11 * <mtddef> := <mtd-id>:<partdef>[,<partdef>]
12 * <partdef> := <size>[@<offset>][<name>][ro][lk][slc]
13 * <mtd-id> := unique name used in mapping driver/device (mtd->name)
14 * <size> := standard linux memsize OR "-" to denote all remaining space
20 * <name> := '(' NAME ')'
21 * NAME will appear in /proc/mtd
26 * The parts are assigned MTD numbers in the order they are specified in the
32 * edb7312-nor:-
35 * edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
38 #define pr_fmt(fmt) "mtd: " fmt
42 #include <linux/mtd/mtd.h>
43 #include <linux/mtd/partitions.h>
49 #define dbg(x) do { printk("DEBUG-CMDLINE-PART: "); printk x; } while(0)
75 * Parse one partition definition for an MTD. Since there can be many
91 char *name; in newpart() local
98 if (*s == '-') { in newpart()
106 return ERR_PTR(-EINVAL); in newpart()
110 /* fetch partition name and flags */ in newpart()
121 /* now look for name */ in newpart()
128 name = ++s; in newpart()
129 p = strchr(name, delim); in newpart()
131 pr_err("no closing %c found in partition name\n", delim); in newpart()
132 return ERR_PTR(-EINVAL); in newpart()
134 name_len = p - name; in newpart()
137 name = NULL; in newpart()
141 /* record name length for memory allocation later */ in newpart()
150 /* if lk is found do NOT unlock the MTD partition*/ in newpart()
165 pr_err("no partitions allowed after a fill-up partition\n"); in newpart()
166 return ERR_PTR(-EINVAL); in newpart()
183 return ERR_PTR(-ENOMEM); in newpart()
195 if (name) in newpart()
196 strscpy(extra_mem, name, name_len + 1); in newpart()
199 parts[this_part].name = extra_mem; in newpart()
202 dbg(("partition %d: name <%s>, offset %llx, size %llx, mask flags %x\n", in newpart()
203 this_part, parts[this_part].name, parts[this_part].offset, in newpart()
240 * make sure that part-names with ":" will not be handled as in mtdpart_setup_real()
241 * part of the mtd-id with an ":" in mtdpart_setup_real()
250 * fetch <mtd-id>. We use strrchr to ignore all ':' that could in mtdpart_setup_real()
251 * be present in the MTD name, only the last one is interpreted in mtdpart_setup_real()
252 * as an <mtd-id>/<part-definition> separator. in mtdpart_setup_real()
265 pr_err("no mtd-id\n"); in mtdpart_setup_real()
266 return -EINVAL; in mtdpart_setup_real()
268 mtd_id_len = p - mtd_id; in mtdpart_setup_real()
273 * parse one mtd. have it reserve memory for the in mtdpart_setup_real()
274 * struct cmdline_mtd_partition and the mtd-id string. in mtdpart_setup_real()
282 sizeof(void*)-1 /*alignment*/); in mtdpart_setup_real()
288 * Either way, this mtd is hosed and we're in mtdpart_setup_real()
298 this_mtd->parts = parts; in mtdpart_setup_real()
299 this_mtd->num_parts = num_parts; in mtdpart_setup_real()
300 this_mtd->mtd_id = (char*)(this_mtd + 1); in mtdpart_setup_real()
301 strscpy(this_mtd->mtd_id, mtd_id, mtd_id_len + 1); in mtdpart_setup_real()
304 this_mtd->next = partitions; in mtdpart_setup_real()
308 this_mtd->mtd_id, this_mtd->num_parts)); in mtdpart_setup_real()
311 /* EOS - we're done */ in mtdpart_setup_real()
318 return -EINVAL; in mtdpart_setup_real()
327 * Main function to be called from the MTD mapping driver/device to
330 * information. It returns partitions for the requested mtd device, or
340 const char *mtd_id = master->name; in parse_cmdline_partitions()
350 * Search for the partition definition matching master->name. in parse_cmdline_partitions()
351 * If master->name is not set, stop at first partition definition. in parse_cmdline_partitions()
353 for (part = partitions; part; part = part->next) { in parse_cmdline_partitions()
354 if ((!mtd_id) || (!strcmp(part->mtd_id, mtd_id))) in parse_cmdline_partitions()
361 for (i = 0, offset = 0; i < part->num_parts; i++) { in parse_cmdline_partitions()
362 if (part->parts[i].offset == OFFSET_CONTINUOUS) in parse_cmdline_partitions()
363 part->parts[i].offset = offset; in parse_cmdline_partitions()
365 offset = part->parts[i].offset; in parse_cmdline_partitions()
367 if (part->parts[i].size == SIZE_REMAINING) in parse_cmdline_partitions()
368 part->parts[i].size = master->size - offset; in parse_cmdline_partitions()
370 if (offset + part->parts[i].size > master->size) { in parse_cmdline_partitions()
372 part->mtd_id); in parse_cmdline_partitions()
373 part->parts[i].size = master->size - offset; in parse_cmdline_partitions()
375 offset += part->parts[i].size; in parse_cmdline_partitions()
377 if (part->parts[i].size == 0) { in parse_cmdline_partitions()
379 part->mtd_id); in parse_cmdline_partitions()
380 part->num_parts--; in parse_cmdline_partitions()
381 memmove(&part->parts[i], &part->parts[i + 1], in parse_cmdline_partitions()
382 sizeof(*part->parts) * (part->num_parts - i)); in parse_cmdline_partitions()
383 i--; in parse_cmdline_partitions()
387 *pparts = kmemdup(part->parts, sizeof(*part->parts) * part->num_parts, in parse_cmdline_partitions()
390 return -ENOMEM; in parse_cmdline_partitions()
392 return part->num_parts; in parse_cmdline_partitions()
413 .name = "cmdlinepart",
437 MODULE_DESCRIPTION("Command line configuration of MTD partitions");