discover/platform: Add finalise_config_hook
authorJeremy Kerr <jk@ozlabs.org>
Mon, 29 Sep 2014 23:23:22 +0000 (09:23 +1000)
committerSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>
Tue, 30 Sep 2014 01:10:48 +0000 (11:10 +1000)
Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
discover/device-handler.c
discover/platform-powerpc.c
discover/platform.c
discover/platform.h

index 120f11f52aa819639ece6a1bffaa49d0772921ae..7cf52636e56766db936d3bdb70ff104b17dd7797 100644 (file)
@@ -786,6 +786,9 @@ void device_handler_boot(struct device_handler *handler,
 
        if (handler->pending_boot)
                boot_cancel(handler->pending_boot);
+
+       platform_finalise_config();
+
        handler->pending_boot = boot(handler, opt, cmd, handler->dry_run,
                        boot_status, handler);
        handler->pending_boot_is_default = false;
index 1f6f7250df8c4104b5e5f2f6a95e4f0feee53647..7c34939f14197ae4dd84052b8f155f7ecf8829d1 100644 (file)
@@ -693,12 +693,8 @@ static void parse_opal_sysparams(struct config *config)
        if (!next_valid && !default_valid)
                return;
 
-       if (next_valid) {
-               /* invalidate next-boot-device setting */
-               write_bootdev_sysparam("next-boot-device", 0xff);
-       } else {
+       if (!next_valid)
                next_bootdev = default_bootdev;
-       }
 
        switch (next_bootdev) {
        case IPMI_BOOTDEV_NONE:
@@ -753,6 +749,12 @@ static int save_config(struct platform *p, struct config *config)
        return rc;
 }
 
+static void finalise_config(struct platform *platform __attribute__((unused)))
+{
+       /* invalidate next-boot-device setting */
+       write_bootdev_sysparam("next-boot-device", 0xff);
+}
+
 static int get_sysinfo(struct platform *p, struct system_info *sysinfo)
 {
        struct platform_powerpc *platform = p->platform_data;
@@ -797,12 +799,13 @@ static bool probe(struct platform *p, void *ctx)
 
 
 static struct platform platform_powerpc = {
-       .name           = "powerpc",
-       .dhcp_arch_id   = 0x000e,
-       .probe          = probe,
-       .load_config    = load_config,
-       .save_config    = save_config,
-       .get_sysinfo    = get_sysinfo,
+       .name                   = "powerpc",
+       .dhcp_arch_id           = 0x000e,
+       .probe                  = probe,
+       .load_config            = load_config,
+       .save_config            = save_config,
+       .finalise_config        = finalise_config,
+       .get_sysinfo            = get_sysinfo,
 };
 
 register_platform(platform_powerpc);
index 4d5009c4e1dcac2a87f819db730cba820840beaf..0a221e295bb87a67992a6ccede556fe3e49271c2 100644 (file)
@@ -173,6 +173,12 @@ const struct platform *platform_get(void)
        return platform;
 }
 
+void platform_finalise_config(void)
+{
+       if (platform && platform->finalise_config)
+               platform->finalise_config(platform);
+}
+
 int platform_get_sysinfo(struct system_info *info)
 {
        if (platform && platform->get_sysinfo)
index 0a1aa5e3015920cfb17e3c632b203467e82d05d1..5601b61bbd2165e3d544bdf66606e3e33721c9bd 100644 (file)
@@ -8,6 +8,7 @@ struct platform {
        bool            (*probe)(struct platform *, void *);
        int             (*load_config)(struct platform *, struct config *);
        int             (*save_config)(struct platform *, struct config *);
+       void            (*finalise_config)(struct platform *);
        int             (*get_sysinfo)(struct platform *, struct system_info *);
        uint16_t        dhcp_arch_id;
        void            *platform_data;
@@ -17,6 +18,7 @@ int platform_init(void *ctx);
 int platform_fini(void);
 const struct platform *platform_get(void);
 int platform_get_sysinfo(struct system_info *info);
+void platform_finalise_config(void);
 
 /* configuration interface */
 const struct config *config_get(void);