Module: xenomai-3
Branch: next
Commit: 669d592a3131554cbebb77936dd506da9dbf480d
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=669d592a3131554cbebb77936dd506da9dbf480d

Author: Philippe Gerum <r...@xenomai.org>
Date:   Thu Feb 19 12:42:58 2015 +0100

cobalt/kernel: add back sysfs exposure to parameters

---

 kernel/cobalt/arch/x86/smi.c |   66 ++++++++++++++++++++++--------------------
 kernel/cobalt/init.c         |   16 +++++-----
 2 files changed, 43 insertions(+), 39 deletions(-)

diff --git a/kernel/cobalt/arch/x86/smi.c b/kernel/cobalt/arch/x86/smi.c
index 5573e7b..6caedef 100644
--- a/kernel/cobalt/arch/x86/smi.c
+++ b/kernel/cobalt/arch/x86/smi.c
@@ -39,6 +39,8 @@
 #define SMI_CTRL_ADDR  0x30
 
 static int smi_state;
+static char smi_state_arg[16] = "detect";
+module_param_string(smi, smi_state_arg, sizeof(smi_state_arg), 0444);
 
 static unsigned int smi_masked_bits = 1; /* Global disable bit */
 module_param_named(smi_mask, smi_masked_bits, int, 0400);
@@ -102,10 +104,42 @@ static unsigned short get_smi_en_addr(struct pci_dev *dev)
        return SMI_CTRL_ADDR + (((byte1 << 1) | (byte0 >> 7)) << 7);    // bits 
7-15
 }
 
+
+static const char *smi_state_labels[] = {
+       "disabled",
+       "detect",
+       "enabled",
+};
+       
+static void setup_smi_state(void)
+{
+       static char warn_bad_state[] =
+               XENO_WARNING "invalid SMI state '%s'\n";
+       char *p;
+       int n;
+
+       /* Backward compat with legacy state specifiers. */
+       n = simple_strtol(smi_state_arg, &p, 10);
+       if (*p == '\0') {
+               smi_state = n;
+               return;
+       }
+
+       for (n = 0; n < ARRAY_SIZE(smi_state_labels); n++)
+               if (strcmp(smi_state_labels[n], smi_state_arg) == 0) {
+                       smi_state = n - 1;
+                       return;
+               }
+
+       printk(warn_bad_state, smi_state_arg);
+}
+
 void mach_x86_smi_init(void)
 {
        struct pci_dev *dev = NULL;
 
+       setup_smi_state();
+
        if (smi_state < 0)
                return;
 
@@ -133,35 +167,3 @@ void mach_x86_smi_init(void)
 
        pci_dev_put(dev);
 }
-
-static const char *smi_state_labels[] = {
-       "disabled",
-       "detect",
-       "enabled",
-};
-       
-static int setup_smi_state(char *s)
-{
-       static char warn_bad_state[] =
-               XENO_WARNING "invalid SMI state '%s'\n";
-       char *p;
-       int n;
-
-       /* Backward compat with legacy state specifiers. */
-       n = simple_strtol(s, &p, 10);
-       if (*p == '\0') {
-               smi_state = n;
-               return 1;
-       }
-
-       for (n = 0; n < ARRAY_SIZE(smi_state_labels); n++)
-               if (strcmp(smi_state_labels[n], s) == 0) {
-                       smi_state = n - 1;
-                       return 1;
-               }
-
-       printk(warn_bad_state, s);
-       
-       return 0;
-}
-__setup("xenomai.smi=", setup_smi_state);
diff --git a/kernel/cobalt/init.c b/kernel/cobalt/init.c
index bfa63a2..25d49b6 100644
--- a/kernel/cobalt/init.c
+++ b/kernel/cobalt/init.c
@@ -61,6 +61,9 @@ module_param_named(supported_cpus, supported_cpus_arg, ulong, 
0444);
 static unsigned long sysheap_size_arg;
 module_param_named(sysheap_size, sysheap_size_arg, ulong, 0444);
 
+static char init_state_arg[16] = "enabled";
+module_param_string(state, init_state_arg, sizeof(init_state_arg), 0444);
+
 static BLOCKING_NOTIFIER_HEAD(state_notifier_list);
 
 struct cobalt_pipeline cobalt_pipeline;
@@ -255,23 +258,20 @@ static struct {
        { "enabled", COBALT_STATE_WARMUP },
 };
        
-static int __init setup_init_state(char *s)
+static void __init setup_init_state(void)
 {
        static char warn_bad_state[] __initdata =
                XENO_WARNING "invalid init state '%s'\n";
        int n;
 
        for (n = 0; n < ARRAY_SIZE(init_states); n++)
-               if (strcmp(init_states[n].label, s) == 0) {
+               if (strcmp(init_states[n].label, init_state_arg) == 0) {
                        set_realtime_core_state(init_states[n].state);
-                       return 1;
+                       return;
                }
 
-       printk(warn_bad_state, s);
-       
-       return 0;
+       printk(warn_bad_state, init_state_arg);
 }
-__setup("xenomai.state=", setup_init_state);
 
 static __init int sys_init(void)
 {
@@ -323,6 +323,8 @@ static int __init xenomai_init(void)
 {
        int ret, __maybe_unused cpu;
 
+       setup_init_state();
+
        if (!realtime_core_enabled()) {
                printk(XENO_WARNING "disabled on kernel command line\n");
                return 0;


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to