Lines Matching +full:block +full:- +full:offset
1 // SPDX-License-Identifier: GPL-2.0-only
25 * Amount of bytes we read when analyzing each block of flash memory.
51 uint32_t offset[3]; member
55 u64 offset, uint32_t mask_flags) in bcm47xxpart_add_part() argument
57 part->name = name; in bcm47xxpart_add_part()
58 part->offset = offset; in bcm47xxpart_add_part()
59 part->mask_flags = mask_flags; in bcm47xxpart_add_part()
63 * bcm47xxpart_bootpartition - gets index of TRX partition used by bootloader
94 uint32_t offset; in bcm47xxpart_parse() local
95 uint32_t blocksize = master->erasesize; in bcm47xxpart_parse()
102 * Some really old flashes (like AT45DB*) had smaller erasesize-s, but in bcm47xxpart_parse()
112 return -ENOMEM; in bcm47xxpart_parse()
117 return -ENOMEM; in bcm47xxpart_parse()
120 /* Parse block by block looking for magics */ in bcm47xxpart_parse()
121 for (offset = 0; offset <= master->size - blocksize; in bcm47xxpart_parse()
122 offset += blocksize) { in bcm47xxpart_parse()
124 if (IS_ENABLED(CONFIG_BCM47XX) && offset >= 0x2000000) in bcm47xxpart_parse()
132 /* Read beginning of the block */ in bcm47xxpart_parse()
133 err = mtd_read(master, offset, BCM47XXPART_BYTES_TO_READ, in bcm47xxpart_parse()
136 pr_err("mtd_read error while parsing (offset: 0x%X): %d\n", in bcm47xxpart_parse()
137 offset, err); in bcm47xxpart_parse()
145 offset, MTD_WRITEABLE); in bcm47xxpart_parse()
155 offset, MTD_WRITEABLE); in bcm47xxpart_parse()
162 offset, MTD_WRITEABLE); in bcm47xxpart_parse()
169 bcm47xxpart_add_part(&parts[curr_part++], "POT", offset, in bcm47xxpart_parse()
177 bcm47xxpart_add_part(&parts[curr_part++], "ML", offset, in bcm47xxpart_parse()
190 offset); in bcm47xxpart_parse()
194 offset, 0); in bcm47xxpart_parse()
200 * can't cover e.g. ever-changing rootfs partition. in bcm47xxpart_parse()
204 last_subpart = max3(trx->offset[0], trx->offset[1], in bcm47xxpart_parse()
205 trx->offset[2]); in bcm47xxpart_parse()
206 trx_size = max(trx->length, last_subpart + blocksize); in bcm47xxpart_parse()
209 * Skip the TRX data. Decrease offset by block size as in bcm47xxpart_parse()
212 offset += roundup(trx_size, blocksize) - blocksize; in bcm47xxpart_parse()
220 offset, 0); in bcm47xxpart_parse()
225 * New (ARM?) devices may have NVRAM in some middle block. Last in bcm47xxpart_parse()
226 * block will be checked later, so skip it. in bcm47xxpart_parse()
228 if (offset != master->size - blocksize && in bcm47xxpart_parse()
231 offset, 0); in bcm47xxpart_parse()
235 /* Read middle of the block */ in bcm47xxpart_parse()
236 err = mtd_read(master, offset + (blocksize / 2), 0x4, &bytes_read, in bcm47xxpart_parse()
239 pr_err("mtd_read error while parsing (offset: 0x%X): %d\n", in bcm47xxpart_parse()
240 offset + (blocksize / 2), err); in bcm47xxpart_parse()
247 offset, MTD_WRITEABLE); in bcm47xxpart_parse()
252 /* Look for NVRAM at the end of the last block. */ in bcm47xxpart_parse()
259 offset = master->size - possible_nvram_sizes[i]; in bcm47xxpart_parse()
260 err = mtd_read(master, offset, 0x4, &bytes_read, in bcm47xxpart_parse()
263 pr_err("mtd_read error while reading (offset 0x%X): %d\n", in bcm47xxpart_parse()
264 offset, err); in bcm47xxpart_parse()
271 master->size - blocksize, 0); in bcm47xxpart_parse()
283 u64 next_part_offset = (i < curr_part - 1) ? in bcm47xxpart_parse()
284 parts[i + 1].offset : master->size; in bcm47xxpart_parse()
286 parts[i].size = next_part_offset - parts[i].offset; in bcm47xxpart_parse()
294 trx->types = trx_types; in bcm47xxpart_parse()
296 trx->name = "failsafe"; in bcm47xxpart_parse()
304 { .compatible = "brcm,bcm947xx-cfe-partitions" },