]> git.ozlabs.org Git - petitboot/commitdiff
lib/pb-config: Implement save method for test storage
authorJeremy Kerr <jk@ozlabs.org>
Fri, 18 Oct 2013 00:15:19 +0000 (08:15 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Wed, 13 Nov 2013 09:25:39 +0000 (17:25 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
lib/pb-config/storage-test.c

index e4a0e5acce3c041534138ad06326fa9fe909507e..48cb238bd383bcaabb1efc2e571d3033d1c749d4 100644 (file)
@@ -40,22 +40,34 @@ struct test_storage {
        struct config_storage   storage;
        struct param            *params;
        int                     n_params;
+       struct config           *config;
 };
 
-static int load(struct config_storage *st __attribute__((unused)),
-               struct config *config)
+#define to_test_storage(st) container_of(st, struct test_storage, storage)
+
+static int load(struct config_storage *st, struct config *config)
+{
+       struct test_storage *ts = to_test_storage(st);
+       memcpy(config, ts->config, sizeof(test_config));
+       return 0;
+}
+
+static int save(struct config_storage *st, struct config *newconfig)
 {
-       memcpy(config, &test_config, sizeof(test_config));
+       struct test_storage *ts = to_test_storage(st);
+       ts->config = newconfig;
        return 0;
 }
 
 static struct test_storage st = {
        .storage = {
                .load  = load,
+               .save = save,
        },
 };
 
 struct config_storage *create_test_storage(void *ctx __attribute__((unused)))
 {
+       st.config = &test_config;
        return &st.storage;
 }