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>
67 * Parse one partition definition for an MTD. Since there can be many
83 char *name; in newpart() local
90 if (*s == '-') { in newpart()
98 return ERR_PTR(-EINVAL); in newpart()
102 /* fetch partition name and flags */ in newpart()
113 /* now look for name */ in newpart()
120 name = ++s; in newpart()
121 p = strchr(name, delim); in newpart()
123 pr_err("no closing %c found in partition name\n", delim); in newpart()
124 return ERR_PTR(-EINVAL); in newpart()
126 name_len = p - name; in newpart()
129 name = NULL; in newpart()
133 /* record name length for memory allocation later */ in newpart()
142 /* if lk is found do NOT unlock the MTD partition*/ in newpart()
157 pr_err("no partitions allowed after a fill-up partition\n"); in newpart()
158 return ERR_PTR(-EINVAL); in newpart()
175 return ERR_PTR(-ENOMEM); in newpart()
187 if (name) in newpart()
188 strscpy(extra_mem, name, name_len + 1); in newpart()
191 parts[this_part].name = extra_mem; in newpart()
194 pr_debug("partition %d: name <%s>, offset %llx, size %llx, mask flags %x\n", in newpart()
195 this_part, parts[this_part].name, parts[this_part].offset, in newpart()
232 * make sure that part-names with ":" will not be handled as in mtdpart_setup_real()
233 * part of the mtd-id with an ":" in mtdpart_setup_real()
242 * fetch <mtd-id>. We use strrchr to ignore all ':' that could in mtdpart_setup_real()
243 * be present in the MTD name, only the last one is interpreted in mtdpart_setup_real()
244 * as an <mtd-id>/<part-definition> separator. in mtdpart_setup_real()
257 pr_err("no mtd-id\n"); in mtdpart_setup_real()
258 return -EINVAL; in mtdpart_setup_real()
260 mtd_id_len = p - mtd_id; in mtdpart_setup_real()
265 * parse one mtd. have it reserve memory for the in mtdpart_setup_real()
266 * struct cmdline_mtd_partition and the mtd-id string. in mtdpart_setup_real()
274 sizeof(void*)-1 /*alignment*/); in mtdpart_setup_real()
280 * Either way, this mtd is hosed and we're in mtdpart_setup_real()
290 this_mtd->parts = parts; in mtdpart_setup_real()
291 this_mtd->num_parts = num_parts; in mtdpart_setup_real()
292 this_mtd->mtd_id = (char*)(this_mtd + 1); in mtdpart_setup_real()
293 strscpy(this_mtd->mtd_id, mtd_id, mtd_id_len + 1); in mtdpart_setup_real()
296 this_mtd->next = partitions; in mtdpart_setup_real()
300 this_mtd->mtd_id, this_mtd->num_parts); in mtdpart_setup_real()
303 /* EOS - we're done */ in mtdpart_setup_real()
310 return -EINVAL; in mtdpart_setup_real()
319 * Main function to be called from the MTD mapping driver/device to
322 * information. It returns partitions for the requested mtd device, or
332 const char *mtd_id = master->name; in parse_cmdline_partitions()
342 * Search for the partition definition matching master->name. in parse_cmdline_partitions()
343 * If master->name is not set, stop at first partition definition. in parse_cmdline_partitions()
345 for (part = partitions; part; part = part->next) { in parse_cmdline_partitions()
346 if ((!mtd_id) || (!strcmp(part->mtd_id, mtd_id))) in parse_cmdline_partitions()
353 for (i = 0, offset = 0; i < part->num_parts; i++) { in parse_cmdline_partitions()
354 if (part->parts[i].offset == OFFSET_CONTINUOUS) in parse_cmdline_partitions()
355 part->parts[i].offset = offset; in parse_cmdline_partitions()
357 offset = part->parts[i].offset; in parse_cmdline_partitions()
359 if (part->parts[i].size == SIZE_REMAINING) in parse_cmdline_partitions()
360 part->parts[i].size = master->size - offset; in parse_cmdline_partitions()
362 if (offset + part->parts[i].size > master->size) { in parse_cmdline_partitions()
364 part->mtd_id); in parse_cmdline_partitions()
365 part->parts[i].size = master->size - offset; in parse_cmdline_partitions()
367 offset += part->parts[i].size; in parse_cmdline_partitions()
369 if (part->parts[i].size == 0) { in parse_cmdline_partitions()
371 part->mtd_id); in parse_cmdline_partitions()
372 part->num_parts--; in parse_cmdline_partitions()
373 memmove(&part->parts[i], &part->parts[i + 1], in parse_cmdline_partitions()
374 sizeof(*part->parts) * (part->num_parts - i)); in parse_cmdline_partitions()
375 i--; in parse_cmdline_partitions()
379 *pparts = kmemdup(part->parts, sizeof(*part->parts) * part->num_parts, in parse_cmdline_partitions()
382 return -ENOMEM; in parse_cmdline_partitions()
384 return part->num_parts; in parse_cmdline_partitions()
405 .name = "cmdlinepart",
429 MODULE_DESCRIPTION("Command line configuration of MTD partitions");