state: backend_raw: remove hard coded limit of two copies
Although there is the define RAW_BACKEND_COPIES, the state_backend_raw_save() function silently assumes exactly two copies. This patch removes that assumtion by looping over all copies, but saving the one we're read from at the end. Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
a8a3c2de5b
commit
633d92e709
|
@ -1167,7 +1167,7 @@ static int state_backend_raw_save(struct state_backend *backend,
|
||||||
{
|
{
|
||||||
struct state_backend_raw *backend_raw = container_of(backend,
|
struct state_backend_raw *backend_raw = container_of(backend,
|
||||||
struct state_backend_raw, backend);
|
struct state_backend_raw, backend);
|
||||||
int ret = 0, size, fd;
|
int ret = 0, size, fd, i;
|
||||||
void *buf, *data;
|
void *buf, *data;
|
||||||
struct backend_raw_header *header;
|
struct backend_raw_header *header;
|
||||||
struct state_variable *sv;
|
struct state_variable *sv;
|
||||||
|
@ -1192,10 +1192,17 @@ static int state_backend_raw_save(struct state_backend *backend,
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
|
|
||||||
ret = backend_raw_write_one(backend_raw, state, fd,
|
/* save other slots first */
|
||||||
!backend_raw->num_copy_read, buf, size);
|
for (i = 0; i < RAW_BACKEND_COPIES; i++) {
|
||||||
if (ret)
|
if (i == backend_raw->num_copy_read)
|
||||||
goto out_close;
|
continue;
|
||||||
|
|
||||||
|
ret = backend_raw_write_one(backend_raw, state, fd,
|
||||||
|
i, buf, size);
|
||||||
|
if (ret)
|
||||||
|
goto out_close;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ret = backend_raw_write_one(backend_raw, state, fd,
|
ret = backend_raw_write_one(backend_raw, state, fd,
|
||||||
backend_raw->num_copy_read, buf, size);
|
backend_raw->num_copy_read, buf, size);
|
||||||
|
|
Loading…
Reference in New Issue