Lines Matching refs:slot

23 #define HEADER_SIZE offsetof(struct slot, slot.fwid)
31 static struct slot { struct
33 struct bt_mesh_dfu_slot slot; argument
48 static bool slot_eq(const struct bt_mesh_dfu_slot *slot, in slot_eq() argument
51 return (slot->fwid_len == fwid_len) && in slot_eq()
52 !memcmp(fwid, slot->fwid, fwid_len); in slot_eq()
55 static bool is_slot_committed(struct slot *slot_to_check) in is_slot_committed()
57 struct slot *s; in is_slot_committed()
68 static int slot_store(const struct slot *slot_to_store) in slot_store()
81 slot_to_store->slot.fwid, slot_to_store->slot.fwid_len); in slot_store()
88 slot_to_store->slot.metadata, slot_to_store->slot.metadata_len); in slot_store()
93 static void slot_erase(struct slot *slot_to_erase) in slot_erase()
106 struct slot *s; in slot_index_defrag()
128 struct slot *slot = NULL; in bt_mesh_dfu_slot_reserve() local
132 slot = &slots[i]; in bt_mesh_dfu_slot_reserve()
137 if (!slot) { in bt_mesh_dfu_slot_reserve()
146 slot->slot.fwid_len = 0; in bt_mesh_dfu_slot_reserve()
147 slot->slot.metadata_len = 0; in bt_mesh_dfu_slot_reserve()
148 slot->slot.size = 0; in bt_mesh_dfu_slot_reserve()
149 slot->idx = ++slot_index; in bt_mesh_dfu_slot_reserve()
151 LOG_DBG("Reserved slot #%u", slot - &slots[0]); in bt_mesh_dfu_slot_reserve()
153 return &slot->slot; in bt_mesh_dfu_slot_reserve()
159 struct slot *slot = CONTAINER_OF(dfu_slot, struct slot, slot); in bt_mesh_dfu_slot_info_set() local
165 if (slot->idx == 0 || is_slot_committed(slot)) { in bt_mesh_dfu_slot_info_set()
169 slot->slot.size = size; in bt_mesh_dfu_slot_info_set()
170 slot->slot.metadata_len = metadata_len; in bt_mesh_dfu_slot_info_set()
171 memcpy(slot->slot.metadata, metadata, metadata_len); in bt_mesh_dfu_slot_info_set()
178 struct slot *slot = CONTAINER_OF(dfu_slot, struct slot, slot); in bt_mesh_dfu_slot_fwid_set() local
184 if (slot->idx == 0 || is_slot_committed(slot)) { in bt_mesh_dfu_slot_fwid_set()
190 slot_eq(&slots[i].slot, fwid, fwid_len)) { in bt_mesh_dfu_slot_fwid_set()
196 slot->slot.fwid_len = fwid_len; in bt_mesh_dfu_slot_fwid_set()
197 memcpy(slot->slot.fwid, fwid, fwid_len); in bt_mesh_dfu_slot_fwid_set()
204 struct slot *slot = CONTAINER_OF(dfu_slot, struct slot, slot); in bt_mesh_dfu_slot_commit() local
206 if (slot->idx == 0 || in bt_mesh_dfu_slot_commit()
207 slot->slot.fwid_len == 0 || in bt_mesh_dfu_slot_commit()
208 slot->slot.size == 0 || in bt_mesh_dfu_slot_commit()
209 is_slot_committed(slot)) { in bt_mesh_dfu_slot_commit()
213 err = slot_store(slot); in bt_mesh_dfu_slot_commit()
219 sys_slist_append(&list, &slot->n); in bt_mesh_dfu_slot_commit()
221 LOG_DBG("Stored slot #%u: %s", ARRAY_INDEX(slots, slot), in bt_mesh_dfu_slot_commit()
222 bt_hex(slot->slot.fwid, slot->slot.fwid_len)); in bt_mesh_dfu_slot_commit()
228 struct slot *slot = CONTAINER_OF(dfu_slot, struct slot, slot); in bt_mesh_dfu_slot_release() local
230 if (is_slot_committed(slot)) { in bt_mesh_dfu_slot_release()
234 slot->idx = 0; in bt_mesh_dfu_slot_release()
239 struct slot *slot = CONTAINER_OF(dfu_slot, struct slot, slot); in bt_mesh_dfu_slot_del() local
241 if (!sys_slist_find_and_remove(&list, &slot->n)) { in bt_mesh_dfu_slot_del()
245 int idx = ARRAY_INDEX(slots, slot); in bt_mesh_dfu_slot_del()
249 slot_erase(slot); in bt_mesh_dfu_slot_del()
250 slot->idx = 0; in bt_mesh_dfu_slot_del()
257 struct slot *s; in bt_mesh_dfu_slot_del_all()
268 struct slot *s; in bt_mesh_dfu_slot_at()
272 return &s->slot; in bt_mesh_dfu_slot_at()
279 int bt_mesh_dfu_slot_get(const uint8_t *fwid, size_t fwid_len, struct bt_mesh_dfu_slot **slot) in bt_mesh_dfu_slot_get() argument
281 struct slot *s; in bt_mesh_dfu_slot_get()
285 if (slot_eq(&s->slot, fwid, fwid_len)) { in bt_mesh_dfu_slot_get()
286 if (slot) { in bt_mesh_dfu_slot_get()
287 *slot = &s->slot; in bt_mesh_dfu_slot_get()
299 struct slot *s; in bt_mesh_dfu_slot_img_idx_get()
303 if (&s->slot == dfu_slot) { in bt_mesh_dfu_slot_img_idx_get()
316 struct slot *s; in bt_mesh_dfu_slot_foreach()
325 iter = cb(&s->slot, user_data); in bt_mesh_dfu_slot_foreach()
351 struct slot *s, *prev = NULL; in slot_data_load()
375 if (read_cb(cb_arg, &slots[idx].slot.fwid, in slot_data_load()
376 sizeof(slots[idx].slot.fwid)) < 0) { in slot_data_load()
382 slots[idx].slot.fwid_len = len_rd; in slot_data_load()
387 if (read_cb(cb_arg, &slots[idx].slot.metadata, in slot_data_load()
388 sizeof(slots[idx].slot.metadata)) < 0) { in slot_data_load()
394 slots[idx].slot.metadata_len = len_rd; in slot_data_load()