Lines Matching +full:slot +full:- +full:size

1 // SPDX-License-Identifier: GPL-2.0
9 static int validate_of_partition(struct device_node *np, int slot) in validate_of_partition() argument
11 u64 offset, size; in validate_of_partition() local
18 /* Make sure reg len match the expected addr and size cells */ in validate_of_partition()
20 return -EINVAL; in validate_of_partition()
25 return -EINVAL; in validate_of_partition()
27 /* Validate size conversion from bytes to sectors */ in validate_of_partition()
28 size = of_read_number(reg + a_cells, s_cells); in validate_of_partition()
29 if (!size || size % SECTOR_SIZE) in validate_of_partition()
30 return -EINVAL; in validate_of_partition()
35 static void add_of_partition(struct parsed_partitions *state, int slot, in add_of_partition() argument
39 char tmp[sizeof(info->volname) + 4]; in add_of_partition()
47 /* Convert bytes to sector size */ in add_of_partition()
49 u64 size = of_read_number(reg + a_cells, s_cells) / SECTOR_SIZE; in add_of_partition() local
51 put_partition(state, slot, offset, size); in add_of_partition()
53 if (of_property_read_bool(np, "read-only")) in add_of_partition()
54 state->parts[slot].flags |= ADDPART_FLAG_READONLY; in add_of_partition()
60 info = &state->parts[slot].info; in add_of_partition()
64 strscpy(info->volname, partname, sizeof(info->volname)); in add_of_partition()
66 snprintf(tmp, sizeof(tmp), "(%s)", info->volname); in add_of_partition()
67 strlcat(state->pp_buf, tmp, PAGE_SIZE); in add_of_partition()
72 struct device *ddev = disk_to_dev(state->disk); in of_partition()
74 int slot; in of_partition() local
76 struct device_node *partitions_np = of_node_get(ddev->of_node); in of_partition()
79 !of_device_is_compatible(partitions_np, "fixed-partitions")) in of_partition()
82 slot = 1; in of_partition()
83 /* Validate parition offset and size */ in of_partition()
85 if (validate_of_partition(np, slot)) { in of_partition()
89 return -1; in of_partition()
92 slot++; in of_partition()
95 slot = 1; in of_partition()
97 if (slot >= state->limit) { in of_partition()
102 add_of_partition(state, slot, np); in of_partition()
104 slot++; in of_partition()
107 strlcat(state->pp_buf, "\n", PAGE_SIZE); in of_partition()