Lines Matching +full:partition +full:-
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Qualcomm SMEM NAND flash partition parser
28 * struct smem_flash_pentry - SMEM Flash partition entry
29 * @name: Name of the partition
31 * @length: Length of the partition in blocks
32 * @attr: Flags for this partition
42 * struct smem_flash_ptable - SMEM Flash partition table
43 * @magic1: Partition table Magic 1
44 * @magic2: Partition table Magic 2
45 * @version: Partition table version
47 * @pentry: Flash partition entries belonging to this ptable
69 && mtd->type == MTD_NORFLASH) { in parse_qcomsmem_part()
70 pr_err("%s: SMEM partition parser is incompatible with 4K sectors\n", in parse_qcomsmem_part()
71 mtd->name); in parse_qcomsmem_part()
72 return -EINVAL; in parse_qcomsmem_part()
75 pr_debug("Parsing partition table info from SMEM\n"); in parse_qcomsmem_part()
78 if (PTR_ERR(ptable) != -EPROBE_DEFER) in parse_qcomsmem_part()
79 pr_err("Error reading partition table header\n"); in parse_qcomsmem_part()
84 if (le32_to_cpu(ptable->magic1) != SMEM_FLASH_PART_MAGIC1 || in parse_qcomsmem_part()
85 le32_to_cpu(ptable->magic2) != SMEM_FLASH_PART_MAGIC2) { in parse_qcomsmem_part()
86 pr_err("Partition table magic verification failed\n"); in parse_qcomsmem_part()
87 return -EINVAL; in parse_qcomsmem_part()
91 tmpparts = le32_to_cpu(ptable->numparts); in parse_qcomsmem_part()
93 pr_err("Partition numbers exceed the max limit\n"); in parse_qcomsmem_part()
94 return -EINVAL; in parse_qcomsmem_part()
97 /* Find out length of partition data based on table version */ in parse_qcomsmem_part()
98 if (le32_to_cpu(ptable->version) <= SMEM_FLASH_PTABLE_V3) { in parse_qcomsmem_part()
101 } else if (le32_to_cpu(ptable->version) == SMEM_FLASH_PTABLE_V4) { in parse_qcomsmem_part()
105 pr_err("Unknown ptable version (%d)", le32_to_cpu(ptable->version)); in parse_qcomsmem_part()
106 return -EINVAL; in parse_qcomsmem_part()
110 * Now that the partition table header has been parsed, verified in parse_qcomsmem_part()
111 * and the length of the partition table calculated, read the in parse_qcomsmem_part()
112 * complete partition table in parse_qcomsmem_part()
116 pr_err("Error reading partition table\n"); in parse_qcomsmem_part()
121 pentry = &ptable->pentry[i]; in parse_qcomsmem_part()
122 if (pentry->name[0] != '\0') in parse_qcomsmem_part()
128 return -ENOMEM; in parse_qcomsmem_part()
131 pentry = &ptable->pentry[i]; in parse_qcomsmem_part()
132 if (pentry->name[0] == '\0') in parse_qcomsmem_part()
135 name = kstrdup(pentry->name, GFP_KERNEL); in parse_qcomsmem_part()
137 ret = -ENOMEM; in parse_qcomsmem_part()
146 parts[j].offset = le32_to_cpu(pentry->offset) * mtd->erasesize; in parse_qcomsmem_part()
147 parts[j].mask_flags = pentry->attr; in parse_qcomsmem_part()
148 parts[j].size = le32_to_cpu(pentry->length) * mtd->erasesize; in parse_qcomsmem_part()
150 i, pentry->name, le32_to_cpu(pentry->offset), in parse_qcomsmem_part()
151 le32_to_cpu(pentry->length), pentry->attr); in parse_qcomsmem_part()
155 pr_debug("SMEM partition table found: ver: %d len: %d\n", in parse_qcomsmem_part()
156 le32_to_cpu(ptable->version), tmpparts); in parse_qcomsmem_part()
162 while (--j >= 0) in parse_qcomsmem_part()
182 { .compatible = "qcom,smem-part" },
197 MODULE_DESCRIPTION("Qualcomm SMEM NAND flash partition parser");