@@ -61,6 +61,7 @@ static int settings_zms_dst(struct settings_zms *cf)
61
61
return 0 ;
62
62
}
63
63
64
+ #ifndef CONFIG_SETTINGS_ZMS_NO_LL_DELETE
64
65
static int settings_zms_unlink_ll_node (struct settings_zms * cf , uint32_t name_hash )
65
66
{
66
67
int rc = 0 ;
@@ -119,6 +120,7 @@ static int settings_zms_unlink_ll_node(struct settings_zms *cf, uint32_t name_ha
119
120
120
121
return rc ;
121
122
}
123
+ #endif /* CONFIG_SETTINGS_ZMS_NO_LL_DELETE */
122
124
123
125
static int settings_zms_delete (struct settings_zms * cf , uint32_t name_hash )
124
126
{
@@ -132,6 +134,7 @@ static int settings_zms_delete(struct settings_zms *cf, uint32_t name_hash)
132
134
return rc ;
133
135
}
134
136
137
+ #ifndef CONFIG_SETTINGS_ZMS_NO_LL_DELETE
135
138
rc = settings_zms_unlink_ll_node (cf , name_hash );
136
139
if (rc < 0 ) {
137
140
return rc ;
@@ -143,6 +146,7 @@ static int settings_zms_delete(struct settings_zms *cf, uint32_t name_hash)
143
146
return rc ;
144
147
}
145
148
149
+ #endif /* CONFIG_SETTINGS_ZMS_NO_LL_DELETE */
146
150
return rc ;
147
151
}
148
152
@@ -177,15 +181,27 @@ static int settings_zms_load(struct settings_store *cs, const struct settings_lo
177
181
ZMS_DATA_ID_OFFSET );
178
182
179
183
if ((rc1 <= 0 ) || (rc2 <= 0 )) {
180
- /* Settings item is not stored correctly in the ZMS.
181
- * ZMS entry for its name or value is either missing
182
- * or deleted. Clean dirty entries to make space for
183
- * future settings item.
184
+ /* In case we are not updating the linked list, this is an empty mode
185
+ * Just continue
186
+ */
187
+ #ifndef CONFIG_SETTINGS_ZMS_NO_LL_DELETE
188
+ /* Otherwise, Settings item is not stored correctly in the ZMS.
189
+ * ZMS entry's name or value is either missing or deleted.
190
+ * Clean dirty entries to make space for future settings items.
184
191
*/
185
192
ret = settings_zms_delete (cf , ZMS_NAME_ID_FROM_LL_NODE (ll_hash_id ));
186
193
if (ret < 0 ) {
187
194
return ret ;
188
195
}
196
+ #endif /* CONFIG_SETTINGS_ZMS_NO_LL_DELETE */
197
+
198
+ ret = zms_read (& cf -> cf_zms , ll_hash_id , & settings_element ,
199
+ sizeof (struct settings_hash_linked_list ));
200
+ if (ret < 0 ) {
201
+ return ret ;
202
+ }
203
+ /* update next ll_hash_id */
204
+ ll_hash_id = settings_element .next_hash ;
189
205
continue ;
190
206
}
191
207
@@ -313,6 +329,17 @@ static int settings_zms_save(struct settings_store *cs, const char *name, const
313
329
if (rc < 0 ) {
314
330
return rc ;
315
331
}
332
+ #ifdef CONFIG_SETTINGS_ZMS_NO_LL_DELETE
333
+ /* verify that the ll_node doesn't exist otherwise do not update it */
334
+ rc = zms_read (& cf -> cf_zms , name_hash | 1 , & settings_element ,
335
+ sizeof (struct settings_hash_linked_list ));
336
+ if (rc >= 0 ) {
337
+ goto no_ll_update ;
338
+ } else if (rc != - ENOENT ) {
339
+ return rc ;
340
+ }
341
+ /* else the LL node doesn't exist let's update it */
342
+ #endif /* CONFIG_SETTINGS_ZMS_NO_LL_DELETE */
316
343
/* write linked list structure element */
317
344
settings_element .next_hash = 0 ;
318
345
/* Verify first that the linked list last element is not broken.
@@ -342,7 +369,9 @@ static int settings_zms_save(struct settings_store *cs, const char *name, const
342
369
cf -> second_to_last_hash_id = cf -> last_hash_id ;
343
370
cf -> last_hash_id = name_hash | 1 ;
344
371
}
345
-
372
+ #ifdef CONFIG_SETTINGS_ZMS_NO_LL_DELETE
373
+ no_ll_update :
374
+ #endif /* CONFIG_SETTINGS_ZMS_NO_LL_DELETE */
346
375
return 0 ;
347
376
}
348
377
0 commit comments