]> Devoid-pointer.net GitWeb - omnibook.git/commitdiff
* Lindent run
authorMathieu Bérard <mathieu.berard@crans.org>
Thu, 14 Sep 2006 14:29:27 +0000 (14:29 +0000)
committerMathieu Bérard <mathieu.berard@crans.org>
Thu, 14 Sep 2006 14:29:27 +0000 (14:29 +0000)
* Check all struct omnibook_operations created on the stack:
  -Remove those who are clearly avoidable
  -Correctly init the others
* Yet another nbsmi asm implementation:
  -use spinlock_irqsave/restore to save/load eflags
  -don't pusha/popa but put all registers in clobber list
  Should be more stack friendly
  Has been runtime checked by replacing smi call by
  "lets clobber the registers" asm instructions.
* Yet more fix by Holger Nelson.

23 files changed:
ac.c
acpi.c
apmemu.c
battery.c
blank.c
bluetooth.c
compal.c
display.c
dock.c
dump.c
ec.c
ec.h
fan.c
fan_policy.c
hotkeys.c
info.c
init.c
lcd.c
muteled.c
nbsmi.c
temperature.c
touchpad.c
wireless.c

diff --git a/ac.c b/ac.c
index cc3d0aec89f0c0f65155673cf3c2cbfdf6b5affa..3b2ce968b5c45bf6d9f848aea72337853295864a 100644 (file)
--- a/ac.c
+++ b/ac.c
@@ -24,12 +24,12 @@ int omnibook_get_ac(struct omnibook_operation *io_op)
        int retval;
 
        retval = io_op->backend->byte_read(io_op, &ac);
-       if(!retval)
+       if (!retval)
                retval = !!ac;
        return retval;
 }
 
-static int omnibook_ac_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_ac_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
        int ac;
@@ -44,12 +44,12 @@ static int omnibook_ac_read(char *buffer,struct omnibook_operation *io_op)
 }
 
 static struct omnibook_tbl ac_table[] __initdata = {
-       { XE3GF|TSP10|TSM30X,                   SIMPLE_BYTE(EC,XE3GF_ADP,XE3GF_ADP_MASK)},
-       { XE3GC|AMILOD,                         SIMPLE_BYTE(EC,XE3GC_STA1,XE3GC_ADP_MASK)},
-       { OB500|OB510|OB6000|OB6100|XE4500,     SIMPLE_BYTE(EC,OB500_STA2,OB500_ADP_MASK)},
-       { OB4150,                               SIMPLE_BYTE(EC,OB4150_ADP,OB4150_ADP_MASK)},
-       { XE2,                                  SIMPLE_BYTE(EC,XE2_STA1,XE2_ADP_MASK)},
-       { 0,}
+       {XE3GF | TSP10 | TSM30X, SIMPLE_BYTE(EC, XE3GF_ADP, XE3GF_ADP_MASK)},
+       {XE3GC | AMILOD, SIMPLE_BYTE(EC, XE3GC_STA1, XE3GC_ADP_MASK)},
+       {OB500 | OB510 | OB6000 | OB6100 | XE4500, SIMPLE_BYTE(EC, OB500_STA2, OB500_ADP_MASK)},
+       {OB4150, SIMPLE_BYTE(EC, OB4150_ADP, OB4150_ADP_MASK)},
+       {XE2, SIMPLE_BYTE(EC, XE2_STA1, XE2_ADP_MASK)},
+       {0,}
 };
 
 struct omnibook_feature __declared_feature ac_driver = {
@@ -60,7 +60,7 @@ struct omnibook_feature __declared_feature ac_driver = {
        .enabled = 0,
 #endif
        .read = omnibook_ac_read,
-       .ectypes = XE3GF|XE3GC|OB500|OB510|OB6000|OB6100|XE4500|OB4150|XE2|AMILOD|TSP10|TSM30X,
+       .ectypes = XE3GF | XE3GC | OB500 | OB510 | OB6000 | OB6100 | XE4500 | OB4150 | XE2 | AMILOD | TSP10 | TSM30X,
        .tbl = ac_table,
 };
 
diff --git a/acpi.c b/acpi.c
index f8caf23d13856578b679e7548eb268f53959ec60..93897238ef81d93deb6f7a1d576d7271e8921bb8 100644 (file)
--- a/acpi.c
+++ b/acpi.c
@@ -14,8 +14,6 @@
  * Written by Mathieu Bérard <mathieu.berard@crans.org>, 2006
  *
  */
-
 
 #include "omnibook.h"
 #include "ec.h"
@@ -46,7 +44,6 @@
 #define        CRT_CSTE        0x2
 #define        TVO_CSTE        0x4
 
-
 static char ec_dev_list[][20] = {
        "\\_SB.PCI0.LPCB.EC0",
        "\\_SB.PCI0.LPC0.EC0",
@@ -58,28 +55,28 @@ static char ec_dev_list[][20] = {
  */
 static int omnibook_acpi_probe(const struct omnibook_operation *io_op)
 {
-       acpi_handle dev_handle; 
+       acpi_handle dev_handle;
        int i;
-       
-       if(acpi_disabled) {
+
+       if (acpi_disabled) {
                printk(O_ERR "ACPI is disabled: feature unavailable.\n");
                return -ENODEV;
        }
 
-       for(i = 0; i < ARRAY_SIZE(ec_dev_list); i++) {
-               if(acpi_get_handle(NULL, ec_dev_list[i], &dev_handle) == AE_OK) {
+       for (i = 0; i < ARRAY_SIZE(ec_dev_list); i++) {
+               if (acpi_get_handle(NULL, ec_dev_list[i], &dev_handle) == AE_OK) {
                        acpi_backend.data = dev_handle;
                        dprintk("ACPI probing was successfull\n");
                        return 0;
                }
        }
 
-       printk(O_ERR "Can't get handle on ACPI EC device.\n");  
+       printk(O_ERR "Can't get handle on ACPI EC device.\n");
        return -ENODEV;
 }
 
 /*
- * Execute an ACPI method which return either integer or nothing
+ * Execute an ACPI method which return either an integer or nothing
  * (acpi_evaluate_object wrapper)
  */
 static int omnibook_acpi_execute(char *method, const int *param, int *result)
@@ -89,31 +86,31 @@ static int omnibook_acpi_execute(char *method, const int *param, int *result)
        struct acpi_buffer buff;
        union acpi_object arg, out_objs[1];
 
-       if(!(acpi_backend.data)) {
-               dprintk("no handle on EC ACPI device"); 
+       if (!(acpi_backend.data)) {
+               dprintk("no handle on EC ACPI device");
                return -ENODEV;
        }
-       
-       if(param) {
+
+       if (param) {
                args_list.count = 1;
                args_list.pointer = &arg;
                arg.type = ACPI_TYPE_INTEGER;
                arg.integer.value = *param;
        } else
                args_list.count = 0;
-       
+
        buff.length = sizeof(out_objs);
-        buff.pointer = out_objs;
-       
-       if(acpi_evaluate_object(acpi_backend.data, method, &args_list, &buff) != AE_OK) {
+       buff.pointer = out_objs;
+
+       if (acpi_evaluate_object(acpi_backend.data, method, &args_list, &buff) != AE_OK) {
                printk(O_ERR "ACPI method execution failed\n");
                return -EIO;
        }
-       
-       if(!result) /* We don't care what the method returned here */
+
+       if (!result)            /* We don't care what the method returned here */
                return 0;
-       
-       if(out_objs[0].type != ACPI_TYPE_INTEGER) {
+
+       if (out_objs[0].type != ACPI_TYPE_INTEGER) {
                printk(O_ERR "ACPI method result is not a number\n");
                return -EINVAL;
        }
@@ -126,18 +123,18 @@ static int omnibook_acpi_get_wireless(const struct omnibook_operation *io_op, un
 {
        int retval = 0;
        int raw_state;
-       
-       if ((retval = omnibook_acpi_execute(GET_WIRELESS_METHOD,0,&raw_state)))
+
+       if ((retval = omnibook_acpi_execute(GET_WIRELESS_METHOD, 0, &raw_state)))
                return retval;
 
        dprintk("get_wireless raw_state: %x\n", raw_state);
 
-       *state = ( raw_state & WLEX_MASK ) ? WIFI_EX : 0;
-       *state |= ( raw_state & WLAT_MASK ) ? WIFI_STA : 0;
-       *state |= ( raw_state & KLSW_MASK ) ? KILLSWITCH : 0;
-       *state |= ( raw_state & BTEX_MASK ) ? BT_EX : 0;
-       *state |= ( raw_state & BTAT_MASK ) ? BT_STA : 0;
-       
+       *state = (raw_state & WLEX_MASK) ? WIFI_EX : 0;
+       *state |= (raw_state & WLAT_MASK) ? WIFI_STA : 0;
+       *state |= (raw_state & KLSW_MASK) ? KILLSWITCH : 0;
+       *state |= (raw_state & BTEX_MASK) ? BT_EX : 0;
+       *state |= (raw_state & BTAT_MASK) ? BT_STA : 0;
+
        return retval;
 }
 
@@ -145,15 +142,15 @@ static int omnibook_acpi_set_wireless(const struct omnibook_operation *io_op, un
 {
        int retval = 0;
        int raw_state;
-       
-       raw_state = state & WIFI_STA; /* bit 0 */
-       raw_state |= (state & BT_STA) << 0x1; /* bit 1 */
+
+       raw_state = state & WIFI_STA;   /* bit 0 */
+       raw_state |= (state & BT_STA) << 0x1;   /* bit 1 */
 
        dprintk("set_wireless raw_state: %x\n", raw_state);
 
-       if ((retval = omnibook_acpi_execute(SET_WIRELESS_METHOD,&raw_state,NULL)))
+       if ((retval = omnibook_acpi_execute(SET_WIRELESS_METHOD, &raw_state, NULL)))
                return retval;
-       
+
        return retval;
 }
 
@@ -162,32 +159,31 @@ static int omnibook_acpi_get_display(const struct omnibook_operation *io_op, uns
        int retval = 0;
        int raw_state = 0;
 
-       retval = omnibook_acpi_execute(GET_DISPLAY_METHOD, 0 , &raw_state);
-       if(retval < 0)
+       retval = omnibook_acpi_execute(GET_DISPLAY_METHOD, 0, &raw_state);
+       if (retval < 0)
                return retval;
 
        /* Backend specific to backend-neutral conversion */
-       *state =  ( raw_state & LCD_CSTE) ? DISPLAY_LCD_ON : 0; 
-       *state |= ( raw_state & CRT_CSTE) ? DISPLAY_CRT_ON : 0;
-       *state |= ( raw_state & TVO_CSTE) ? DISPLAY_TVO_ON : 0; 
+       *state = (raw_state & LCD_CSTE) ? DISPLAY_LCD_ON : 0;
+       *state |= (raw_state & CRT_CSTE) ? DISPLAY_CRT_ON : 0;
+       *state |= (raw_state & TVO_CSTE) ? DISPLAY_TVO_ON : 0;
 
-       *state |= ( raw_state & LCD_CADL) ? DISPLAY_LCD_DET : 0;
-       *state |= ( raw_state & CRT_CADL) ? DISPLAY_CRT_DET : 0;
-       *state |= ( raw_state & TVO_CADL) ? DISPLAY_TVO_DET : 0;
-       
+       *state |= (raw_state & LCD_CADL) ? DISPLAY_LCD_DET : 0;
+       *state |= (raw_state & CRT_CADL) ? DISPLAY_CRT_DET : 0;
+       *state |= (raw_state & TVO_CADL) ? DISPLAY_TVO_DET : 0;
 
-       return DISPLAY_LCD_ON|DISPLAY_CRT_ON|DISPLAY_TVO_ON|
-               DISPLAY_LCD_DET|DISPLAY_CRT_DET|DISPLAY_TVO_DET;
+       return DISPLAY_LCD_ON | DISPLAY_CRT_ON | DISPLAY_TVO_ON | DISPLAY_LCD_DET | DISPLAY_CRT_DET
+           DISPLAY_TVO_DET;
 }
 
 static const unsigned int acpi_display_mode_list[] = {
        DISPLAY_LCD_ON,
        DISPLAY_CRT_ON,
-       DISPLAY_LCD_ON|DISPLAY_CRT_ON,
+       DISPLAY_LCD_ON | DISPLAY_CRT_ON,
        DISPLAY_TVO_ON,
-       DISPLAY_LCD_ON|DISPLAY_TVO_ON,
-       DISPLAY_CRT_ON|DISPLAY_TVO_ON,
-       DISPLAY_LCD_ON|DISPLAY_CRT_ON|DISPLAY_TVO_ON,
+       DISPLAY_LCD_ON | DISPLAY_TVO_ON,
+       DISPLAY_CRT_ON | DISPLAY_TVO_ON,
+       DISPLAY_LCD_ON | DISPLAY_CRT_ON | DISPLAY_TVO_ON,
 };
 
 static int omnibook_acpi_set_display(const struct omnibook_operation *io_op, unsigned int state)
@@ -195,22 +191,22 @@ static int omnibook_acpi_set_display(const struct omnibook_operation *io_op, uns
        int retval = 0;
        int i, matched;
 
-       for(i = 0; i < ARRAY_SIZE(acpi_display_mode_list); i++) {
-               if(acpi_display_mode_list[i] == state) {
-                       matched = i + 1; /* raw state is array row number + 1 */
+       for (i = 0; i < ARRAY_SIZE(acpi_display_mode_list); i++) {
+               if (acpi_display_mode_list[i] == state) {
+                       matched = i + 1;        /* raw state is array row number + 1 */
                        break;
-               }       
+               }
        }
-       if(!matched) {
+       if (!matched) {
                printk("Display mode %x is unsupported.\n", state);
                return -EINVAL;
        }
-       
-       retval = omnibook_acpi_execute(SET_DISPLAY_METHOD, &matched, NULL );
-       if(retval < 0)
+
+       retval = omnibook_acpi_execute(SET_DISPLAY_METHOD, &matched, NULL);
+       if (retval < 0)
                return retval;
 
-       return DISPLAY_LCD_ON|DISPLAY_CRT_ON|DISPLAY_TVO_ON;
+       return DISPLAY_LCD_ON | DISPLAY_CRT_ON | DISPLAY_TVO_ON;
 }
 
 struct omnibook_backend acpi_backend = {
@@ -222,7 +218,7 @@ struct omnibook_backend acpi_backend = {
        .display_set = omnibook_acpi_set_display,
 };
 
-#else /* CONFIG_ACPI */
+#else                          /* CONFIG_ACPI */
 
 /* dummy backend for non-ACPI systems */
 static int _fail_probe(const struct omnibook_operation *io_op)
@@ -231,8 +227,8 @@ static int _fail_probe(const struct omnibook_operation *io_op)
 }
 
 struct omnibook_backend acpi_backend = {
-        .name = "acpi",
-        .init = _fail_probe,
+       .name = "acpi",
+       .init = _fail_probe,
 };
 
-#endif /* CONFIG_ACPI */
+#endif                         /* CONFIG_ACPI */
index 832959bb5b9221429296bbbe2f75d79addda389e..7c9a57e88433528156229c0beb4990cee704efb7 100644 (file)
--- a/apmemu.c
+++ b/apmemu.c
@@ -72,9 +72,9 @@ static int omnibook_apmemu_read(char *buffer, struct omnibook_operation *io_op)
        int retval;
        int len = 0;
        int ac;
-       
+
        struct omnibook_battery_state battstat;
-       
+
        struct apm_features {
                char *drvver;
                char *apmver;
@@ -125,16 +125,8 @@ static int omnibook_apmemu_read(char *buffer, struct omnibook_operation *io_op)
        }
 
        len += sprintf(buffer + len, "%s %s 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
-                       apm.drvver,
-                       apm.apmver,
-                       apm.apmflags,
-                       apm.ac,
-                       apm.battstat,
-                       apm.battflags,
-                       apm.gauge,
-                       apm.time,
-                       apm.units
-       );
+                      apm.drvver, apm.apmver, apm.apmflags, apm.ac, apm.battstat, apm.battflags,
+                      apm.gauge, apm.time, apm.units);
 
        return len;
 }
@@ -151,17 +143,16 @@ static int __init omnibook_apmemu_init(struct omnibook_operation *io_op)
 }
 
 static struct omnibook_feature __declared_feature apmemu_driver = {
-        .name = "apmemu",
-        .proc_entry = "apm", /* create /proc/apm */
-         .enabled = 1,
-        .read = omnibook_apmemu_read,
-        .init = omnibook_apmemu_init,
-        .ectypes = XE3GF|XE3GC|TSP10,
+       .name = "apmemu",
+       .proc_entry = "apm",    /* create /proc/apm */
+       .enabled = 0,           /* This feature is broken */
+       .read = omnibook_apmemu_read,
+       .init = omnibook_apmemu_init,
+       .ectypes = XE3GF | XE3GC | TSP10,
 };
 
-
 module_param_named(apmemu, apmemu_driver.enabled, int, S_IRUGO);
 MODULE_PARM_DESC(apmemu, "Use 0 to disable, 1 to enable /proc/apm emulation");
 
-#endif /* CONFIG_OMNIBOOK_LEGACY */
+#endif                         /* CONFIG_OMNIBOOK_LEGACY */
 /* End of file */
index f9eb553969c6d03b142364f047f92af3d1f14f56..77e1e8a79a860ed6a14c77117838acaa60bacaec 100644 (file)
--- a/battery.c
+++ b/battery.c
@@ -41,13 +41,13 @@ static int omnibook_battery_present(int num)
        int i;
        u8 bat;
        u8 mask = 0;
-       
+
        /*
         * XE3GF
         * TSP10
         * TSM30X
         */
-       if (omnibook_ectype & (XE3GF|TSP10|TSM30X) ) {
+       if (omnibook_ectype & (XE3GF | TSP10 | TSM30X)) {
 
                if (num >= 2)
                        return -EINVAL;
@@ -56,11 +56,11 @@ static int omnibook_battery_present(int num)
                mask = XE3GF_BAL0_MASK;
                for (i = 0; i < num; i++)
                        mask = mask << 1;
-       /*
-        * XE3GC
-        * AMILOD
-        */
-       } else if (omnibook_ectype & (XE3GC|AMILOD) ) {
+               /*
+                * XE3GC
+                * AMILOD
+                */
+       } else if (omnibook_ectype & (XE3GC | AMILOD)) {
                if (num >= 2)
                        return -EINVAL;
                if ((retval = legacy_ec_read(XE3GC_BAT, &bat)))
@@ -82,8 +82,7 @@ static int omnibook_battery_present(int num)
  *    1 - Battery is not present
  *    2 - Not supported
  */
-static int omnibook_get_battery_info(int num,
-                                    struct omnibook_battery_info *battinfo)
+static int omnibook_get_battery_info(int num, struct omnibook_battery_info *battinfo)
 {
        int retval;
        u32 offset;
@@ -93,93 +92,73 @@ static int omnibook_get_battery_info(int num,
         * TSP10
         * TSM30X
         */
-       if (omnibook_ectype & (XE3GF|TSP10|TSM30X) ) {
+       if (omnibook_ectype & (XE3GF | TSP10 | TSM30X)) {
                offset = 0x10;
                retval = omnibook_battery_present(num);
                if (retval < 0)
                        return retval;
                if (retval) {
                        if ((retval =
-                            legacy_ec_read(XE3GF_BTY0 + (offset * num),
-                                    &(*battinfo).type)))
+                            legacy_ec_read(XE3GF_BTY0 + (offset * num), &(*battinfo).type)))
                                return retval;
-                       if ((retval =
-                            ec_read16(XE3GF_BSN0 + (offset * num),
-                                      &(*battinfo).sn)))
+                       if ((retval = ec_read16(XE3GF_BSN0 + (offset * num), &(*battinfo).sn)))
                                return retval;
-                       if ((retval =
-                            ec_read16(XE3GF_BDV0 + (offset * num),
-                                      &(*battinfo).dv)))
+                       if ((retval = ec_read16(XE3GF_BDV0 + (offset * num), &(*battinfo).dv)))
                                return retval;
-                       if ((retval =
-                            ec_read16(XE3GF_BDC0 + (offset * num),
-                                      &(*battinfo).dc)))
+                       if ((retval = ec_read16(XE3GF_BDC0 + (offset * num), &(*battinfo).dc)))
                                return retval;
 
-                       (*battinfo).type =
-                           ((*battinfo).type & XE3GF_BTY_MASK) ? 1 : 0;
+                       (*battinfo).type = ((*battinfo).type & XE3GF_BTY_MASK) ? 1 : 0;
                } else
                        return 1;
-       /*
-        * XE3GC
-        */
-       } else if (omnibook_ectype & (XE3GC) ) {
+               /*
+                * XE3GC
+                */
+       } else if (omnibook_ectype & (XE3GC)) {
                offset = 0x10;
                retval = omnibook_battery_present(num);
                if (retval < 0)
                        return retval;
                if (retval) {
-                       if ((retval =
-                            ec_read16(XE3GC_BDV0 + (offset * num),
-                                      &(*battinfo).dv)))
+                       if ((retval = ec_read16(XE3GC_BDV0 + (offset * num), &(*battinfo).dv)))
                                return retval;
-                       if ((retval =
-                            ec_read16(XE3GC_BDC0 + (offset * num),
-                                      &(*battinfo).dc)))
+                       if ((retval = ec_read16(XE3GC_BDC0 + (offset * num), &(*battinfo).dc)))
                                return retval;
                        if ((retval =
-                            legacy_ec_read(XE3GC_BTY0 + (offset * num),
-                                    &(*battinfo).type)))
+                            legacy_ec_read(XE3GC_BTY0 + (offset * num), &(*battinfo).type)))
                                return retval;
 
-                       (*battinfo).type =
-                           ((*battinfo).type & XE3GC_BTY_MASK) ? 1 : 0;
+                       (*battinfo).type = ((*battinfo).type & XE3GC_BTY_MASK) ? 1 : 0;
                        (*battinfo).sn = 0;     /* Unknown */
                } else
                        return 1;
-       /*
-        * AMILOD
-        */
-       } else if (omnibook_ectype & (AMILOD) ) {
+               /*
+                * AMILOD
+                */
+       } else if (omnibook_ectype & (AMILOD)) {
                offset = 0x10;
                retval = omnibook_battery_present(num);
                if (retval < 0)
                        return retval;
                if (retval) {
-                       if ((retval =
-                            ec_read16(AMILOD_BDV0 + (offset * num),
-                                      &(*battinfo).dv)))
+                       if ((retval = ec_read16(AMILOD_BDV0 + (offset * num), &(*battinfo).dv)))
                                return retval;
-                       if ((retval =
-                            ec_read16(AMILOD_BDC0 + (offset * num),
-                                      &(*battinfo).dc)))
+                       if ((retval = ec_read16(AMILOD_BDC0 + (offset * num), &(*battinfo).dc)))
                                return retval;
                        if ((retval =
-                            legacy_ec_read(AMILOD_BTY0 + (offset * num),
-                                    &(*battinfo).type)))
+                            legacy_ec_read(AMILOD_BTY0 + (offset * num), &(*battinfo).type)))
                                return retval;
 
-                       (*battinfo).type =
-                           ((*battinfo).type & AMILOD_BTY_MASK) ? 1 : 0;
+                       (*battinfo).type = ((*battinfo).type & AMILOD_BTY_MASK) ? 1 : 0;
                        (*battinfo).sn = 0;     /* Unknown */
                } else
                        return 1;
-       /*
-        * FIXME
-        * OB500
-        * OB510
-        */
-       } else if (omnibook_ectype & (OB500|OB510) ) {
+               /*
+                * FIXME
+                * OB500
+                * OB510
+                */
+       } else if (omnibook_ectype & (OB500 | OB510)) {
                switch (num) {
                case 0:
                        break;
@@ -190,12 +169,12 @@ static int omnibook_get_battery_info(int num,
                default:
                        return -EINVAL;
                }
-       /*
-        * OB6000
-        * OB6100
-        * XE4500
-        */
-       } else if (omnibook_ectype & (OB6000|OB6100|XE4500) ) {
+               /*
+                * OB6000
+                * OB6100
+                * XE4500
+                */
+       } else if (omnibook_ectype & (OB6000 | OB6100 | XE4500)) {
                switch (num) {
                case 0:
                        break;
@@ -218,8 +197,7 @@ static int omnibook_get_battery_info(int num,
  *    1 - Battery is not present
  *    2 - Not supported
  */
-int omnibook_get_battery_status(int num,
-                                      struct omnibook_battery_state *battstat)
+int omnibook_get_battery_status(int num, struct omnibook_battery_state *battstat)
 {
        int retval;
        u8 status;
@@ -232,30 +210,22 @@ int omnibook_get_battery_status(int num,
         * TSP10
         * TSM30X
         */
-       if (omnibook_ectype & (XE3GF|TSP10|TSM30X) ) {
+       if (omnibook_ectype & (XE3GF | TSP10 | TSM30X)) {
                offset = 0x10;
                retval = omnibook_battery_present(num);
                if (retval < 0)
                        return retval;
                if (retval) {
-                       if ((retval =
-                            legacy_ec_read(XE3GF_BST0 + (offset * num), &status)))
+                       if ((retval = legacy_ec_read(XE3GF_BST0 + (offset * num), &status)))
                                return retval;
-                       if ((retval =
-                            ec_read16(XE3GF_BRC0 + (offset * num),
-                                      &(*battstat).rc)))
+                       if ((retval = ec_read16(XE3GF_BRC0 + (offset * num), &(*battstat).rc)))
                                return retval;
-                       if ((retval =
-                            ec_read16(XE3GF_BPV0 + (offset * num),
-                                      &(*battstat).pv)))
+                       if ((retval = ec_read16(XE3GF_BPV0 + (offset * num), &(*battstat).pv)))
                                return retval;
-                       if ((retval =
-                            ec_read16(XE3GF_BFC0 + (offset * num),
-                                      &(*battstat).lc)))
+                       if ((retval = ec_read16(XE3GF_BFC0 + (offset * num), &(*battstat).lc)))
                                return retval;
                        if ((retval =
-                            legacy_ec_read(XE3GF_GAU0 + (offset * num),
-                                    &(*battstat).gauge)))
+                            legacy_ec_read(XE3GF_GAU0 + (offset * num), &(*battstat).gauge)))
                                return retval;
 
                        if (status & XE3GF_BST_MASK_CRT)
@@ -263,38 +233,30 @@ int omnibook_get_battery_status(int num,
                        else if (status & XE3GF_BST_MASK_CHR)
                                (*battstat).status = OMNIBOOK_BATTSTAT_CHARGING;
                        else if (status & XE3GF_BST_MASK_DSC)
-                               (*battstat).status =
-                                   OMNIBOOK_BATTSTAT_DISCHARGING;
-                       else if (status &
-                                (XE3GF_BST_MASK_CHR | XE3GF_BST_MASK_DSC))
+                               (*battstat).status = OMNIBOOK_BATTSTAT_DISCHARGING;
+                       else if (status & (XE3GF_BST_MASK_CHR | XE3GF_BST_MASK_DSC))
                                (*battstat).status = OMNIBOOK_BATTSTAT_UNKNOWN;
                        else {
                                (*battstat).status = OMNIBOOK_BATTSTAT_CHARGED;
                        }
                } else
                        return 1;
-       /*
-        * XE3GC
-        */
-       } else if (omnibook_ectype & (XE3GC) ) {
+               /*
+                * XE3GC
+                */
+       } else if (omnibook_ectype & (XE3GC)) {
                offset = 0x10;
                retval = omnibook_battery_present(num);
                if (retval < 0)
                        return retval;
                if (retval) {
-                       if ((retval =
-                            legacy_ec_read(XE3GC_BST0 + (offset * num), &status)))
+                       if ((retval = legacy_ec_read(XE3GC_BST0 + (offset * num), &status)))
                                return retval;
-                       if ((retval =
-                            ec_read16(XE3GC_BRC0 + (offset * num),
-                                      &(*battstat).rc)))
+                       if ((retval = ec_read16(XE3GC_BRC0 + (offset * num), &(*battstat).rc)))
                                return retval;
-                       if ((retval =
-                            ec_read16(XE3GC_BPV0 + (offset * num),
-                                      &(*battstat).pv)))
+                       if ((retval = ec_read16(XE3GC_BPV0 + (offset * num), &(*battstat).pv)))
                                return retval;
-                       if ((retval =
-                            ec_read16(XE3GC_BDC0 + (offset * num), &dc)))
+                       if ((retval = ec_read16(XE3GC_BDC0 + (offset * num), &dc)))
                                return retval;
 
                        if (status & XE3GC_BST_MASK_CRT)
@@ -302,10 +264,8 @@ int omnibook_get_battery_status(int num,
                        else if (status & XE3GC_BST_MASK_CHR)
                                (*battstat).status = OMNIBOOK_BATTSTAT_CHARGING;
                        else if (status & XE3GC_BST_MASK_DSC)
-                               (*battstat).status =
-                                   OMNIBOOK_BATTSTAT_DISCHARGING;
-                       else if (status &
-                                (XE3GC_BST_MASK_CHR | XE3GC_BST_MASK_DSC))
+                               (*battstat).status = OMNIBOOK_BATTSTAT_DISCHARGING;
+                       else if (status & (XE3GC_BST_MASK_CHR | XE3GC_BST_MASK_DSC))
                                (*battstat).status = OMNIBOOK_BATTSTAT_UNKNOWN;
                        else {
                                (*battstat).status = OMNIBOOK_BATTSTAT_CHARGED;
@@ -315,28 +275,22 @@ int omnibook_get_battery_status(int num,
                        (*battstat).lc = 0;     /* Unknown */
                } else
                        return 1;
-       /*
-        * AMILOD
-        */
-       } else if (omnibook_ectype & (AMILOD) ) {
+               /*
+                * AMILOD
+                */
+       } else if (omnibook_ectype & (AMILOD)) {
                offset = 0x10;
                retval = omnibook_battery_present(num);
                if (retval < 0)
                        return retval;
                if (retval) {
-                       if ((retval =
-                            legacy_ec_read(AMILOD_BST0 + (offset * num), &status)))
+                       if ((retval = legacy_ec_read(AMILOD_BST0 + (offset * num), &status)))
                                return retval;
-                       if ((retval =
-                            ec_read16(AMILOD_BRC0 + (offset * num),
-                                      &(*battstat).rc)))
+                       if ((retval = ec_read16(AMILOD_BRC0 + (offset * num), &(*battstat).rc)))
                                return retval;
-                       if ((retval =
-                            ec_read16(AMILOD_BPV0 + (offset * num),
-                                      &(*battstat).pv)))
+                       if ((retval = ec_read16(AMILOD_BPV0 + (offset * num), &(*battstat).pv)))
                                return retval;
-                       if ((retval =
-                            ec_read16(AMILOD_BDC0 + (offset * num), &dc)))
+                       if ((retval = ec_read16(AMILOD_BDC0 + (offset * num), &dc)))
                                return retval;
 
                        if (status & AMILOD_BST_MASK_CRT)
@@ -344,10 +298,8 @@ int omnibook_get_battery_status(int num,
                        else if (status & AMILOD_BST_MASK_CHR)
                                (*battstat).status = OMNIBOOK_BATTSTAT_CHARGING;
                        else if (status & AMILOD_BST_MASK_DSC)
-                               (*battstat).status =
-                                   OMNIBOOK_BATTSTAT_DISCHARGING;
-                       else if (status &
-                                (AMILOD_BST_MASK_CHR | AMILOD_BST_MASK_DSC))
+                               (*battstat).status = OMNIBOOK_BATTSTAT_DISCHARGING;
+                       else if (status & (AMILOD_BST_MASK_CHR | AMILOD_BST_MASK_DSC))
                                (*battstat).status = OMNIBOOK_BATTSTAT_UNKNOWN;
                        else {
                                (*battstat).status = OMNIBOOK_BATTSTAT_CHARGED;
@@ -357,11 +309,11 @@ int omnibook_get_battery_status(int num,
                        (*battstat).lc = 0;     /* Unknown */
                } else
                        return 1;
-       /*
-        * OB500
-        * OB510
-        */
-       } else if (omnibook_ectype & (OB500|OB510) ) {
+               /*
+                * OB500
+                * OB510
+                */
+       } else if (omnibook_ectype & (OB500 | OB510)) {
                switch (num) {
                case 0:
                        if ((retval = legacy_ec_read(OB500_BT1S, &status)))
@@ -401,12 +353,12 @@ int omnibook_get_battery_status(int num,
                else {
                        (*battstat).status = OMNIBOOK_BATTSTAT_CHARGED;
                }
-       /*
-        * OB6000
-        * OB6100
-        * XE4500
-        */
-       } else if (omnibook_ectype & (OB6000|OB6100|XE4500) ) {
+               /*
+                * OB6000
+                * OB6100
+                * XE4500
+                */
+       } else if (omnibook_ectype & (OB6000 | OB6100 | XE4500)) {
                switch (num) {
                case 0:
                        if ((retval = legacy_ec_read(OB500_BT1S, &status)))
@@ -444,7 +396,7 @@ int omnibook_get_battery_status(int num,
        return 0;
 }
 
-static int omnibook_battery_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_battery_read(char *buffer, struct omnibook_operation *io_op)
 {
        char *statustr;
        char *typestr;
@@ -464,18 +416,18 @@ static int omnibook_battery_read(char *buffer,struct omnibook_operation *io_op)
         * AMILOD
         * TSP10
         */
-       if (omnibook_ectype & (XE3GF|XE3GC|OB6000|OB6100|XE4500|AMILOD|TSP10) )
+       if (omnibook_ectype & (XE3GF | XE3GC | OB6000 | OB6100 | XE4500 | AMILOD | TSP10))
                max = 2;
        /*
         * OB500
         * 0B510
         */
-       else if (omnibook_ectype & (OB500|OB510) )
+       else if (omnibook_ectype & (OB500 | OB510))
                max = 3;
        /*
         * TSM30X
         */
-       else if (omnibook_ectype & (TSM30X) )
+       else if (omnibook_ectype & (TSM30X))
                max = 1;
 
        for (i = 0; i < max; i++) {
@@ -501,45 +453,23 @@ static int omnibook_battery_read(char *buffer,struct omnibook_operation *io_op)
                                statustr = "unknown";
                        }
 
-                       len +=
-                           sprintf(buffer + len, "Battery:            %11d\n",
-                                   i);
-                       len +=
-                           sprintf(buffer + len, "Type:               %11s\n",
-                                   typestr);
+                       len += sprintf(buffer + len, "Battery:            %11d\n", i);
+                       len += sprintf(buffer + len, "Type:               %11s\n", typestr);
                        if (battinfo.sn)
                                len +=
-                                   sprintf(buffer + len,
-                                           "Serial Number:      %11d\n",
+                                   sprintf(buffer + len, "Serial Number:      %11d\n",
                                            battinfo.sn);
-                       len +=
-                           sprintf(buffer + len,
-                                   "Present Voltage:    %11d mV\n",
-                                   battstat.pv);
-                       len +=
-                           sprintf(buffer + len,
-                                   "Design Voltage:     %11d mV\n",
-                                   battinfo.dv);
-                       len +=
-                           sprintf(buffer + len,
-                                   "Remaining Capacity: %11d mAh\n",
-                                   battstat.rc);
+                       len += sprintf(buffer + len, "Present Voltage:    %11d mV\n", battstat.pv);
+                       len += sprintf(buffer + len, "Design Voltage:     %11d mV\n", battinfo.dv);
+                       len += sprintf(buffer + len, "Remaining Capacity: %11d mAh\n", battstat.rc);
                        if (battstat.lc)
                                len +=
-                                   sprintf(buffer + len,
-                                           "Last Full Capacity: %11d mAh\n",
+                                   sprintf(buffer + len, "Last Full Capacity: %11d mAh\n",
                                            battstat.lc);
+                       len += sprintf(buffer + len, "Design Capacity:    %11d mAh\n", battinfo.dc);
                        len +=
-                           sprintf(buffer + len,
-                                   "Design Capacity:    %11d mAh\n",
-                                   battinfo.dc);
-                       len +=
-                           sprintf(buffer + len,
-                                   "Gauge:              %11d %%\n",
-                                   battstat.gauge);
-                       len +=
-                           sprintf(buffer + len, "Status:             %11s\n",
-                                   statustr);
+                           sprintf(buffer + len, "Gauge:              %11d %%\n", battstat.gauge);
+                       len += sprintf(buffer + len, "Status:             %11s\n", statustr);
                        len += sprintf(buffer + len, "\n");
                }
        }
@@ -550,17 +480,16 @@ static int omnibook_battery_read(char *buffer,struct omnibook_operation *io_op)
 }
 
 static struct omnibook_feature __declared_feature battery_driver = {
-        .name = "battery",
+       .name = "battery",
 #ifdef CONFIG_OMNIBOOK_LEGACY
-        .enabled = 1,
+       .enabled = 1,
 #else
-        .enabled = 0,
+       .enabled = 0,
 #endif
-        .read = omnibook_battery_read,
-        .ectypes = XE3GF|XE3GC|AMILOD|TSP10|TSM30X, /* FIXME: OB500|OB6000|OB6100|XE4500 */
+       .read = omnibook_battery_read,
+       .ectypes = XE3GF | XE3GC | AMILOD | TSP10 | TSM30X,     /* FIXME: OB500|OB6000|OB6100|XE4500 */
 };
 
-
 module_param_named(battery, battery_driver.enabled, int, S_IRUGO);
 MODULE_PARM_DESC(battery, "Use 0 to disable, 1 to enable battery status monitoring");
 /* End of file */
diff --git a/blank.c b/blank.c
index 274d3e67e7976b5f53241cc67322a8f1b2511ccb..a69c78e6818b8cf40320a12c9607b6c338471717 100644 (file)
--- a/blank.c
+++ b/blank.c
@@ -34,18 +34,15 @@ extern int (*console_blank_hook) (int);
 int omnibook_lcd_blank(int blank)
 {
        int retval = 0;
-       
-       if ( blank_driver.io_op->backend == PIO )
+
+       if (blank_driver.io_op->backend == PIO)
                omnibook_apply_write_mask(blank_driver.io_op, blank);
-       else if ( blank_driver.io_op->backend == KBC ||
-                 blank_driver.io_op->backend == CDI )
+       else if (blank_driver.io_op->backend == KBC || blank_driver.io_op->backend == CDI)
                omnibook_toggle(blank_driver.io_op, blank);
        else {
-               printk(O_WARN
-                      "LCD console blanking is unsupported on this machine.\n");
                retval = -ENODEV;
        }
-       
+
        return retval;
 }
 
@@ -54,13 +51,11 @@ static int console_blank_register_hook(void)
        if (omnibook_console_blank_enabled == 0) {
                if (console_blank_hook == NULL) {
                        console_blank_hook = omnibook_lcd_blank;
-                       printk(O_INFO
-                               "LCD backlight turn off at console blanking is enabled.\n");
+                       printk(O_INFO "LCD backlight turn off at console blanking is enabled.\n");
 
                        omnibook_console_blank_enabled = 1;
                } else {
-                       printk(O_INFO
-                               "There is a console blanking solution already registered.\n");
+                       printk(O_INFO "There is a console blanking solution already registered.\n");
                }
        }
        return 0;
@@ -82,18 +77,18 @@ static int console_blank_unregister_hook(void)
        return 0;
 }
 
-static int omnibook_console_blank_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_console_blank_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
 
        len +=
-           sprintf(buffer + len, "LCD console blanking is %s\n",
+           sprintf(buffer + len, "LCD console blanking hook is %s\n",
                    (omnibook_console_blank_enabled) ? "enabled" : "disabled");
 
        return len;
 }
 
-static int omnibook_console_blank_write(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_console_blank_write(char *buffer, struct omnibook_operation *io_op)
 {
        int retval;
 
@@ -123,23 +118,24 @@ static void __exit omnibook_console_blank_cleanup(struct omnibook_operation *io_
 }
 
 static struct omnibook_tbl blank_table[] __initdata = {
-       { TSM30X,       {CDI, 0, TSM100_BLANK_INDEX, 0, TSM100_LCD_OFF, TSM100_LCD_ON}}, 
-       { XE3GF|XE3GC|AMILOD|TSP10|TSM30X|TSM40, COMMAND(KBC,OMNIBOOK_KBC_CMD_LCD_OFF,OMNIBOOK_KBC_CMD_LCD_ON)},
-       { OB500|OB6000|XE2, { PIO, OB500_GPO1, OB500_GPO1, 0, -OB500_BKLT_MASK, OB500_BKLT_MASK}},
-       { OB510|OB6100,     { PIO, OB510_GPO2, OB510_GPO2, 0, -OB510_BKLT_MASK, OB510_BKLT_MASK}},
-       { 0,}
+       {TSM30X, {CDI, 0, TSM100_BLANK_INDEX, 0, TSM100_LCD_OFF, TSM100_LCD_ON}},
+       {XE3GF | XE3GC | AMILOD | TSP10 | TSM30X | TSM40,
+        COMMAND(KBC, OMNIBOOK_KBC_CMD_LCD_OFF, OMNIBOOK_KBC_CMD_LCD_ON)},
+       {OB500 | OB6000 | XE2, {PIO, OB500_GPO1, OB500_GPO1, 0, -OB500_BKLT_MASK, OB500_BKLT_MASK}},
+       {OB510 | OB6100, {PIO, OB510_GPO2, OB510_GPO2, 0, -OB510_BKLT_MASK, OB510_BKLT_MASK}},
+       {0,}
 };
 
-
 static struct omnibook_feature __declared_feature blank_driver = {
-        .name = "blank",
-        .enabled = 1,
-        .read = omnibook_console_blank_read,
-        .write = omnibook_console_blank_write,
-        .init = omnibook_console_blank_init,
-        .exit = omnibook_console_blank_cleanup,
-        .ectypes = XE3GF|XE3GC|OB500|OB510|OB6000|OB6100|XE2|AMILOD|TSP10|TSM30X|TSM40,
-        .tbl = blank_table,
+       .name = "blank",
+       .enabled = 1,
+       .read = omnibook_console_blank_read,
+       .write = omnibook_console_blank_write,
+       .init = omnibook_console_blank_init,
+       .exit = omnibook_console_blank_cleanup,
+       .ectypes =
+           XE3GF | XE3GC | OB500 | OB510 | OB6000 | OB6100 | XE2 | AMILOD | TSP10 | TSM30X | TSM40,
+       .tbl = blank_table,
 };
 
 module_param_named(blank, blank_driver.enabled, int, S_IRUGO);
index 66c8ea17a944ff6096137ce56317770d1dcef2a1..8e84afb6b08b6dfae6db502b38bc11b9752ffa2f 100644 (file)
  * Written by Mathieu Bérard <mathieu.berard@crans.org>, 2006
  *
  */
+
 #include "omnibook.h"
 #include "ec.h"
 
-static int omnibook_bt_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_bt_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
        int retval;
-       unsigned int state; 
-       
-       if((retval = io_op->backend->aerial_get(io_op, &state)))
+       unsigned int state;
+
+       if ((retval = io_op->backend->aerial_get(io_op, &state)))
                return retval;
-       
-       len += sprintf(buffer + len,"Bluetooth adapter is %s", (state & BT_EX) ? "present" : "absent");
+
+       len +=
+           sprintf(buffer + len, "Bluetooth adapter is %s",
+                   (state & BT_EX) ? "present" : "absent");
        if (state & BT_EX)
-               len += sprintf(buffer + len," and %s", (state & BT_STA) ? "enabled" : "disabled");
-       len += sprintf(buffer + len,".\n");     
+               len += sprintf(buffer + len, " and %s", (state & BT_STA) ? "enabled" : "disabled");
+       len += sprintf(buffer + len, ".\n");
        return len;
-       
+
 }
 
-static int omnibook_bt_write(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_bt_write(char *buffer, struct omnibook_operation *io_op)
 {
-       int retval = 0; 
+       int retval = 0;
        unsigned int state;
-       
-       if((retval = io_op->backend->aerial_get(io_op, &state)))
+
+       if ((retval = io_op->backend->aerial_get(io_op, &state)))
                return retval;
-       
-       if(*buffer == '0' )
+
+       if (*buffer == '0')
                state &= ~BT_STA;
-       else if (*buffer == '1' )
+       else if (*buffer == '1')
                state |= BT_STA;
        else
                return -EINVAL;
-       
-       if((retval = io_op->backend->aerial_set(io_op, state)))
+
+       if ((retval = io_op->backend->aerial_set(io_op, state)))
                return retval;
 
-       return retval;  
+       return retval;
 }
 
 static struct omnibook_feature bt_feature;
@@ -66,13 +68,13 @@ static int __init omnibook_bt_init(struct omnibook_operation *io_op)
 /*
  *  Refuse enabling/disabling a non-existent device
  */
-       
-       if((retval = io_op->backend->aerial_get(io_op, &state)))
+
+       if ((retval = io_op->backend->aerial_get(io_op, &state)))
                return retval;
-       
-       if(!(state & BT_EX))
-               bt_feature.write = NULL;        
-       
+
+       if (!(state & BT_EX))
+               bt_feature.write = NULL;
+
        return retval;
 }
 
@@ -87,7 +89,7 @@ static struct omnibook_feature __declared_feature bt_driver = {
        .read = omnibook_bt_read,
        .write = omnibook_bt_write,
        .init = omnibook_bt_init,
-       .ectypes = TSM30X|TSM40,
+       .ectypes = TSM30X | TSM40,
        .tbl = wireless_table,
 };
 
index 5e7ee289de1945f06517db51e15fd3b2ae1ccd91..277f2edb999af3bca9fd067d383a9272c8a69a4a 100644 (file)
--- a/compal.c
+++ b/compal.c
@@ -15,7 +15,6 @@
  *
  */
 
-
 #include "omnibook.h"
 
 #include <linux/delay.h>
@@ -66,12 +65,14 @@ static DEFINE_MUTEX(compal_lock);
 /*
  * Private data of this backend
  */
-static struct kref *refcount;          /* Reference counter of this backend */
-static struct pci_dev *lpc_bridge;     /* Southbridge chip ISA bridge/LPC interface PCI device */
-static u32     ioport_base;            /* PIO base adress */
-static union { u16 word; u32 dword;
-               } pci_reg_state;        /* Saved state of register in PCI config spave */
-static int already_failed = 0;         /* Backend init already failed at leat once */
+static struct kref *refcount;  /* Reference counter of this backend */
+static struct pci_dev *lpc_bridge;     /* Southbridge chip ISA bridge/LPC interface PCI device */
+static u32 ioport_base;                /* PIO base adress */
+static union {
+       u16 word;
+       u32 dword;
+} pci_reg_state;               /* Saved state of register in PCI config spave */
+static int already_failed = 0; /* Backend init already failed at leat once */
 
 /*
  * Possible list of supported southbridges
@@ -80,31 +81,28 @@ static int already_failed = 0;              /* Backend init already failed at leat once */
  * Shared with nbsmi backend
  */
 const struct pci_device_id lpc_bridge_table[] = {
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0,   PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_0,   PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0,   PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_10,  PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0,   PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12,  PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0,   PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12,  PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801E_0,    PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0,   PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1,       PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0,      PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1,      PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_2,      PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0,      PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1,      PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_30,     PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31,     PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SB400,           PCI_ANY_ID, PCI_ANY_ID, 0, 0, },
-       { 0, },         /* End of list */
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AA_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801AB_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801BA_10, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801E_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_2, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_30, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SB400, PCI_ANY_ID, PCI_ANY_ID, 0, 0,},
+       {0,},                   /* End of list */
 };
 
-
-
-
 /*
  * Low-level Read function:
  * Write a 2-bytes wide command to the COMMAND ports
@@ -113,8 +111,8 @@ const struct pci_device_id lpc_bridge_table[] = {
 static unsigned char lowlevel_read(u16 command)
 {
        unsigned char data;
-       outb((command & 0xff00) >> 8 ,ioport_base + PIO_PORT_COMMAND1);
-       outb(command & 0x00ff ,ioport_base + PIO_PORT_COMMAND2);
+       outb((command & 0xff00) >> 8ioport_base + PIO_PORT_COMMAND1);
+       outb(command & 0x00ffioport_base + PIO_PORT_COMMAND2);
        data = inb(ioport_base + PIO_PORT_DATA);
        return data;
 }
@@ -126,12 +124,11 @@ static unsigned char lowlevel_read(u16 command)
  */
 static void lowlevel_write(u16 command, u8 data)
 {
-       outb((command & 0xff00) >> 8 ,ioport_base + PIO_PORT_COMMAND1);
-       outb(command & 0x00ff,ioport_base + PIO_PORT_COMMAND2);
+       outb((command & 0xff00) >> 8ioport_base + PIO_PORT_COMMAND1);
+       outb(command & 0x00ff, ioport_base + PIO_PORT_COMMAND2);
        outb(data, ioport_base + PIO_PORT_DATA);
 }
 
-
 /*
  * Probe for a state of the PIO Command/Data/Index interface
  * Give some time for the controler to settle in the desired state
@@ -145,12 +142,12 @@ static int check_cdimode_flag(unsigned int mode)
        int retval;
 
        dprintk("Index mode:");
-       for (i=1; i <= 250; i++) {
+       for (i = 1; i <= 250; i++) {
                retval = lowlevel_read(0xfbfc);
                dprintk_simple(" [%i]", retval);
                if (retval == mode) {
-                       dprintk_simple(".\n");  
-                       dprintk("Index Mode Ok (%i) after %i iter\n",mode,i);
+                       dprintk_simple(".\n");
+                       dprintk("Index Mode Ok (%i) after %i iter\n", mode, i);
                        return 0;
                }
                udelay(100);
@@ -166,15 +163,15 @@ static int check_default_state(void)
 {
        int i;
 
-       for(i=1; i <= 250; i++) {
-               if( (inb(ioport_base + PIO_PORT_COMMAND1) == 0xf4) &&
-                   (inb(ioport_base + PIO_PORT_COMMAND2) == 0x32) )
+       for (i = 1; i <= 250; i++) {
+               if ((inb(ioport_base + PIO_PORT_COMMAND1) == 0xf4)
+                   && (inb(ioport_base + PIO_PORT_COMMAND2) == 0x32))
                        return 0;
                udelay(100);
        }
        printk(O_ERR "check_default_state timeout.\n");
        return -ETIME;
-}      
+}
 
 /*
  * Enable EC Command/Data/Index PIO Access and then check EC state.
@@ -188,12 +185,15 @@ static int check_default_state(void)
  */
 static int enable_cdimode(void)
 {
-       union { u16 word; u32 dword;} value;                    
+       union {
+               u16 word;
+               u32 dword;
+       } value;
 
        switch (lpc_bridge->vendor) {
        case PCI_VENDOR_ID_INTEL:
                switch (lpc_bridge->device) {
-               case PCI_DEVICE_ID_INTEL_ICH7_0: /* ICH7 */
+               case PCI_DEVICE_ID_INTEL_ICH7_0:        /* ICH7 */
                case PCI_DEVICE_ID_INTEL_ICH7_1:
                case PCI_DEVICE_ID_INTEL_ICH7_30:
                case PCI_DEVICE_ID_INTEL_ICH7_31:
@@ -201,8 +201,8 @@ static int enable_cdimode(void)
                        pci_reg_state.dword = value.dword;
                        value.dword = 0x3CFF21;
                        pci_write_config_dword(lpc_bridge, INTEL_LPC_GEN4_DEC, value.dword);
-                       break;          
-               default:        /* All other Intel chipset */           
+                       break;
+               default:        /* All other Intel chipset */
                        pci_read_config_word(lpc_bridge, INTEL_LPC_GEN1_DEC, &(value.word));
                        pci_reg_state.word = value.word;
                        value.word = (INTEL_IOPORT_BASE & 0xfff1) | 0x1;
@@ -210,23 +210,23 @@ static int enable_cdimode(void)
                }
                break;
        case PCI_VENDOR_ID_ATI:
-               pci_read_config_dword(lpc_bridge,ATI_LPC_REG,&(value.dword));
+               pci_read_config_dword(lpc_bridge, ATI_LPC_REG, &(value.dword));
                pci_reg_state.dword = value.dword;
-               value.dword = (( pci_reg_state.dword & 0x7f ) | 0x80 ) << 0x10;
+               value.dword = ((pci_reg_state.dword & 0x7f) | 0x80) << 0x10;
                pci_write_config_dword(lpc_bridge, ATI_LPC_REG, value.dword);
                break;
        default:
                BUG();
        }
        dprintk("Saved state of PCI register: [%x].\n", pci_reg_state.dword);
-       
-       if( check_default_state() || check_cdimode_flag(0) ) {
+
+       if (check_default_state() || check_cdimode_flag(0)) {
                printk(O_ERR "EC state check failure, please report.\n");
                return -EIO;
        }
 
        return 0;
-       
+
 }
 
 /*
@@ -241,7 +241,7 @@ static int send_ec_cmd(unsigned int command, u8 code)
        lowlevel_write(0xfbfc, 0x2);
        lowlevel_write(command, code);
        lowlevel_write(0xfbfc, 0x1);
-       if(check_cdimode_flag(2))
+       if (check_cdimode_flag(2))
                return -ETIME;
        return 0;
 }
@@ -252,16 +252,15 @@ static int send_ec_cmd(unsigned int command, u8 code)
  * 0xfbfe: Read a previously selected Index
  * 0xfbfc: Set CDI mode flag
  */
-static int read_ec_cmd(unsigned int command, u8 *value)
+static int read_ec_cmd(unsigned int command, u8 * value)
 {
        *value = lowlevel_read(command);
        lowlevel_write(0xfbfc, 0x1);
-       if(check_cdimode_flag(2))
+       if (check_cdimode_flag(2))
                return -ETIME;
        return 0;
 }
 
-
 /*
  * Disable EC Command/Data/Index PIO Access 
  * Step 1: clear_cdimode
@@ -274,8 +273,8 @@ static int read_ec_cmd(unsigned int command, u8 *value)
 static void clear_cdimode(void)
 {
        lowlevel_write(0xfbfc, 0x0);
-       outb(0xf4,ioport_base + PIO_PORT_COMMAND1);
-       outb(0x32,ioport_base + PIO_PORT_COMMAND2);
+       outb(0xf4, ioport_base + PIO_PORT_COMMAND1);
+       outb(0x32, ioport_base + PIO_PORT_COMMAND2);
 }
 
 static void clear_cdimode_pci(void)
@@ -283,18 +282,18 @@ static void clear_cdimode_pci(void)
        switch (lpc_bridge->vendor) {
        case PCI_VENDOR_ID_INTEL:
                switch (lpc_bridge->device) {
-               case PCI_DEVICE_ID_INTEL_ICH7_0: /* ICH7 */
+               case PCI_DEVICE_ID_INTEL_ICH7_0:        /* ICH7 */
                case PCI_DEVICE_ID_INTEL_ICH7_1:
                case PCI_DEVICE_ID_INTEL_ICH7_30:
                case PCI_DEVICE_ID_INTEL_ICH7_31:
-                       pci_write_config_dword(lpc_bridge, INTEL_LPC_GEN4_DEC,pci_reg_state.dword);
-                       break;          
-               default:        /* All other Intel chipset */           
-                       pci_write_config_word(lpc_bridge,INTEL_LPC_GEN1_DEC,pci_reg_state.word);
+                       pci_write_config_dword(lpc_bridge, INTEL_LPC_GEN4_DEC, pci_reg_state.dword);
+                       break;
+               default:        /* All other Intel chipset */
+                       pci_write_config_word(lpc_bridge, INTEL_LPC_GEN1_DEC, pci_reg_state.word);
                }
                break;
        case PCI_VENDOR_ID_ATI:
-               pci_write_config_dword(lpc_bridge,ATI_LPC_REG,pci_reg_state.dword);
+               pci_write_config_dword(lpc_bridge, ATI_LPC_REG, pci_reg_state.dword);
                break;
        default:
                BUG();
@@ -311,22 +310,22 @@ static int omnibook_cdimode_init(const struct omnibook_operation *io_op)
        int retval = 0;
        int i;
 
-/* ectypes other than TSM30X have no business with this backend */     
-       if(!(omnibook_ectype & TSM30X))
+/* ectypes other than TSM30X have no business with this backend */
+       if (!(omnibook_ectype & TSM30X))
                return -ENODEV;
 
-       if(already_failed) {
+       if (already_failed) {
                dprintk("CDI backend init already failed, skipping.\n");
                return -ENODEV;
        }
 
-       if(!refcount) {
+       if (!refcount) {
                /* Fist use of the backend */
                mutex_lock(&compal_lock);
-               dprintk("Try to init cdimode\n");       
-               refcount = kmalloc(sizeof(struct kref),GFP_KERNEL);
-               if(!refcount) {
-                       retval= -ENOMEM;
+               dprintk("Try to init cdimode\n");
+               refcount = kmalloc(sizeof(struct kref), GFP_KERNEL);
+               if (!refcount) {
+                       retval = -ENOMEM;
                        goto out;
                }
 
@@ -334,19 +333,21 @@ static int omnibook_cdimode_init(const struct omnibook_operation *io_op)
 
                /* PCI probing: find the LPC Super I/O bridge PCI device */
                for (i = 0; !lpc_bridge && lpc_bridge_table[i].vendor; ++i)
-                       lpc_bridge = pci_get_device(lpc_bridge_table[i].vendor, lpc_bridge_table[i].device, NULL);
+                       lpc_bridge =
+                           pci_get_device(lpc_bridge_table[i].vendor, lpc_bridge_table[i].device,
+                                          NULL);
 
                if (!lpc_bridge) {
                        printk(O_ERR "Fail to find a supported LPC I/O bridge, please report\n");
                        retval = -ENODEV;
                        goto error1;
                }
-               
-               if((retval = pci_enable_device(lpc_bridge))) {
+
+               if ((retval = pci_enable_device(lpc_bridge))) {
                        printk(O_ERR "Unable to enable PCI device.\n");
                        goto error2;
                }
-               
+
                switch (lpc_bridge->vendor) {
                case PCI_VENDOR_ID_INTEL:
                        ioport_base = INTEL_IOPORT_BASE;
@@ -357,23 +358,23 @@ static int omnibook_cdimode_init(const struct omnibook_operation *io_op)
                default:
                        BUG();
                }
-               
-               if(!request_region(ioport_base ,4 ,OMNIBOOK_MODULE_NAME)) {
+
+               if (!request_region(ioport_base, 4, OMNIBOOK_MODULE_NAME)) {
                        printk(O_ERR "Request I/O region error\n");
                        retval = -ENODEV;
                        goto error2;
                }
-               
+
                /*
                 * Make an enable-check disable cycle for testing purpose
                 */
-               
+
                retval = enable_cdimode();
-               if(retval)
+               if (retval)
                        goto error3;
 
                clear_cdimode();
-               clear_cdimode_pci();            
+               clear_cdimode_pci();
 
                dprintk("Cdimode init ok\n");
                goto out;
@@ -382,18 +383,18 @@ static int omnibook_cdimode_init(const struct omnibook_operation *io_op)
                kref_get(refcount);
                return 0;
        }
-       
-error3:
+
+      error3:
        clear_cdimode_pci();
-       release_region(ioport_base,4);
-error2:
+       release_region(ioport_base, 4);
+      error2:
        pci_dev_put(lpc_bridge);
        lpc_bridge = NULL;
-error1:
+      error1:
        kfree(refcount);
        refcount = NULL;
        already_failed = 1;
-out:
+      out:
        mutex_unlock(&compal_lock);
        return retval;
 }
@@ -403,7 +404,7 @@ static void cdimode_free(struct kref *ref)
        mutex_lock(&compal_lock);
        dprintk("Cdimode not used anymore: disposing\n");
        pci_dev_put(lpc_bridge);
-       release_region(ioport_base,4);
+       release_region(ioport_base, 4);
        kfree(refcount);
        lpc_bridge = NULL;
        refcount = NULL;
@@ -415,37 +416,37 @@ static void omnibook_cdimode_exit(const struct omnibook_operation *io_op)
 /* ectypes other than TSM30X have no business with this backend */
        BUG_ON(!(omnibook_ectype & TSM30X));
        dprintk("Trying to dispose cdimode\n");
-       kref_put(refcount,cdimode_free);
+       kref_put(refcount, cdimode_free);
 }
 
 /* 
  * Read EC index and write result to value 
  * 'EC index' here is unrelated to an index in the EC registers
  */
-static int omnibook_cdimode_read(const struct omnibook_operation *io_op, u8 *value)
+static int omnibook_cdimode_read(const struct omnibook_operation *io_op, u8 * value)
 {
        int retval = 0;
-       
-       if(!lpc_bridge)
+
+       if (!lpc_bridge)
                return -ENODEV;
-       
-       if(mutex_lock_interruptible(&compal_lock))
+
+       if (mutex_lock_interruptible(&compal_lock))
                return -ERESTARTSYS;
-       
+
        retval = enable_cdimode();
-       if(retval)
+       if (retval)
                goto out;
-       retval = send_ec_cmd(0xfbfd,(unsigned int) io_op->read_addr);
-       if(retval)
+       retval = send_ec_cmd(0xfbfd, (unsigned int)io_op->read_addr);
+       if (retval)
                goto error;
-       retval = read_ec_cmd(0xfbfe,value);
-       
-       if(io_op->read_mask)
+       retval = read_ec_cmd(0xfbfe, value);
+
+       if (io_op->read_mask)
                *value &= io_op->read_mask;
-       
-error:
+
+      error:
        clear_cdimode();
-out:
+      out:
        clear_cdimode_pci();
        mutex_unlock(&compal_lock);
        return retval;
@@ -458,23 +459,23 @@ out:
 static int omnibook_cdimode_write(const struct omnibook_operation *io_op, u8 value)
 {
        int retval = 0;
-       
-       if(!lpc_bridge)
+
+       if (!lpc_bridge)
                return -ENODEV;
-       
-       if(mutex_lock_interruptible(&compal_lock))
+
+       if (mutex_lock_interruptible(&compal_lock))
                return -ERESTARTSYS;
-               
+
        retval = enable_cdimode();
-       if(retval)
+       if (retval)
                goto out;
-       retval = send_ec_cmd(0xfbfd,(unsigned int) io_op->write_addr);
-       if(retval)
+       retval = send_ec_cmd(0xfbfd, (unsigned int)io_op->write_addr);
+       if (retval)
                goto error;
-       retval = send_ec_cmd(0xfbfe,value);
-error:
+       retval = send_ec_cmd(0xfbfe, value);
+      error:
        clear_cdimode();
-out:
+      out:
        clear_cdimode_pci();
        mutex_unlock(&compal_lock);
        return retval;
@@ -486,32 +487,29 @@ out:
  */
 static int omnibook_cdimode_hotkeys(const struct omnibook_operation *io_op, unsigned int state)
 {
-       int retval;     
-       struct omnibook_operation hotkeys_op;
-       
-       /* Fn+foo handling */
-       hotkeys_op.backend = CDI;
-       hotkeys_op.write_addr = TSM70_FN_INDEX;
-       hotkeys_op.on_mask = TSM70_FN_ENABLE;
-       hotkeys_op.off_mask = TSM70_FN_DISABLE;
-       retval = omnibook_toggle(&hotkeys_op, !!(state & HKEY_FN) );
-       if(retval < 0)
+       int retval;
+       struct omnibook_operation hotkeys_op = 
+               { CDI, 0, TSM70_FN_INDEX, 0, TSM70_FN_ENABLE, TSM70_FN_DISABLE};
+
+       /* Fn+foo handling */
+       retval = omnibook_toggle(&hotkeys_op, !!(state & HKEY_FN));
+       if (retval < 0)
                return retval;
-       
+
        /* Multimedia keys handling */
-       if(state & HKEY_MULTIMEDIA) {
+       if (state & HKEY_MULTIMEDIA) {
                hotkeys_op.write_addr = TSM70_HOTKEYS_INDEX;
                retval = omnibook_cdimode_write(&hotkeys_op, TSM70_HOTKEYS_ENABLE);
        } else {
                /* FIXME: quirk use kbc backend */
-               retval = kbc_backend.byte_write(NULL,OMNIBOOK_KBC_CMD_ONETOUCH_DISABLE);
+               retval = kbc_backend.byte_write(NULL, OMNIBOOK_KBC_CMD_ONETOUCH_DISABLE);
        }
 
-       if(retval < 0)
+       if (retval < 0)
                return retval;
        else
-               return HKEY_MULTIMEDIA|HKEY_FN;
-}      
+               return HKEY_MULTIMEDIA | HKEY_FN;
+}
 
 /* Scan index space, this hard locks my machine */
 #if 0
@@ -523,7 +521,7 @@ static int compal_scan(char *buffer)
 
        for (i = 0; i < 255; i += 16) {
                for (j = 0; j < 16; j++) {
-                       omnibook_compal_read(i + j,&v);
+                       omnibook_compal_read(i + j, &v);
                        len += sprintf(buffer + len, "Read index %02x: %02x\n", i + j, v);
                        mdelay(500);
                }
index f582c703c74cb47f6c9ea2ab4077b6431b6da44a..19f40b79edcd66485c5c6b6721421aa963add272 100644 (file)
--- a/display.c
+++ b/display.c
@@ -25,41 +25,41 @@ static const char display_name[][16] = {
        "External DVI",
 };
 
-static int omnibook_display_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_display_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
        int retval;
        unsigned int sta, en_mask, det_mask;
 
        retval = io_op->backend->display_get(io_op, &sta);
-       if ( retval < 0)
+       if (retval < 0)
                return retval;
 
-       for( en_mask = DISPLAY_LCD_ON ; en_mask <= DISPLAY_DVI_ON; en_mask = en_mask << 1) {
-               det_mask = en_mask << 4; /* see display masks in omnibook.h */
-               if( !( retval & en_mask ) && !( retval & det_mask ) )
-                       continue; /* not supported */
-               len += sprintf(buffer + len, "%s:", 
-                               display_name[ ffs(en_mask) - 1 ]);
-               if( retval & det_mask )
-                       len += sprintf(buffer + len, " display %s",
-                               ( sta & det_mask ) ? "present" : "absent");
-               if( retval & en_mask )
-                       len += sprintf(buffer + len, " port %s",
-                               ( sta & en_mask ) ? "enabled" : "disabled");
-               len += sprintf(buffer + len, "\n"); 
+       for (en_mask = DISPLAY_LCD_ON; en_mask <= DISPLAY_DVI_ON; en_mask = en_mask << 1) {
+               det_mask = en_mask << 4;        /* see display masks in omnibook.h */
+               if (!(retval & en_mask) && !(retval & det_mask))
+                       continue;       /* not supported */
+               len += sprintf(buffer + len, "%s:", display_name[ffs(en_mask) - 1]);
+               if (retval & det_mask)
+                       len +=
+                           sprintf(buffer + len, " display %s",
+                                   (sta & det_mask) ? "present" : "absent");
+               if (retval & en_mask)
+                       len +=
+                           sprintf(buffer + len, " port %s",
+                                   (sta & en_mask) ? "enabled" : "disabled");
+               len += sprintf(buffer + len, "\n");
        }
 
-
        return len;
 }
 
-static int omnibook_display_write(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_display_write(char *buffer, struct omnibook_operation *io_op)
 {
        int retval;
-       unsigned int state;     
+       unsigned int state;
        char *endp;
-       
+
        state = simple_strtoul(buffer, &endp, 16);
        if (endp == buffer)
                return -EINVAL;
@@ -73,31 +73,32 @@ static struct omnibook_feature display_driver;
 
 static int __init omnibook_display_init(struct omnibook_operation *io_op)
 {
-       /* Disable file writing if unsuported by backend */     
-       if(!io_op->backend->display_set)
+       /* Disable file writing if unsuported by backend */
+       if (!io_op->backend->display_set)
                display_driver.write = NULL;
        return 0;
 }
 
-
 static struct omnibook_tbl display_table[] __initdata = {
-       { TSM30X,                               {ACPI, }},
-       { TSM40,                                {SMI, }},
-       { XE3GF|TSP10|TSM30X|TSM40,         SIMPLE_BYTE(EC,XE3GF_STA1,XE3GF_SHDD_MASK)},
-       { XE3GC,                            SIMPLE_BYTE(EC,XE3GC_STA1,XE3GC_CRTI_MASK)},
-       { OB500|OB510|OB6000|OB6100|XE4500, SIMPLE_BYTE(EC,OB500_STA1,OB500_CRTS_MASK)},
-       { OB4150,                           SIMPLE_BYTE(EC,OB4150_STA2,OB4150_CRST_MASK)},
-       { 0,}
+       {TSM30X, {ACPI,}},
+       {TSM40, {SMI, SMI_GET_DISPLAY_STATE, SMI_SET_DISPLAY_STATE, 0, 0, 0}},
+       {XE3GF | TSP10 | TSM30X | TSM40, SIMPLE_BYTE(EC, XE3GF_STA1, XE3GF_SHDD_MASK)},
+       {XE3GC, SIMPLE_BYTE(EC, XE3GC_STA1, XE3GC_CRTI_MASK)},
+       {OB500 | OB510 | OB6000 | OB6100 | XE4500, SIMPLE_BYTE(EC, OB500_STA1, OB500_CRTS_MASK)},
+       {OB4150, SIMPLE_BYTE(EC, OB4150_STA2, OB4150_CRST_MASK)},
+       {0,}
 };
 
 static struct omnibook_feature __declared_feature display_driver = {
-        .name = "display",
-        .enabled = 1,
-        .init = omnibook_display_init,
-        .read = omnibook_display_read,
-        .write = omnibook_display_write,
-        .ectypes = XE3GF|XE3GC|OB500|OB510|OB6000|OB6100|XE4500|OB4150|TSP10|TSM30X|TSM40,
-        .tbl = display_table,
+       .name = "display",
+       .enabled = 1,
+       .init = omnibook_display_init,
+       .read = omnibook_display_read,
+       .write = omnibook_display_write,
+       .ectypes =
+           XE3GF | XE3GC | OB500 | OB510 | OB6000 | OB6100 | XE4500 | OB4150 | TSP10 | TSM30X |
+           TSM40,
+       .tbl = display_table,
 };
 
 module_param_named(display, display_driver.enabled, int, S_IRUGO);
diff --git a/dock.c b/dock.c
index d25482fb18d538ac1748c692d3135a4301d70181..285ae1597c2df498d9cd7604bdf96eee33f3849c 100644 (file)
--- a/dock.c
+++ b/dock.c
 
 #include "ec.h"
 
-static int omnibook_dock_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_dock_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
        u8 dock;
        int retval;
-       
-       if ((retval = io_op->backend->byte_read(io_op,&dock)))
+
+       if ((retval = io_op->backend->byte_read(io_op, &dock)))
                return retval;
-       
-       len +=
-           sprintf(buffer + len, "Laptop is %s\n",
-                   (dock) ? "docked" : "undocked");
+
+       len += sprintf(buffer + len, "Laptop is %s\n", (dock) ? "docked" : "undocked");
 
        return len;
 }
 
 static struct omnibook_tbl dock_table[] __initdata = {
-       { XE3GF,                     SIMPLE_BYTE(EC,XE3GF_CSPR,XE3GF_CSPR_MASK)},
-       { OB500|OB510|OB6000|OB6100, SIMPLE_BYTE(EC,OB500_STA1,OB500_DCKS_MASK)},
-       { OB4150,                    SIMPLE_BYTE(EC,OB4150_DCID,0)},    
-       { 0,}
+       {XE3GF, SIMPLE_BYTE(EC, XE3GF_CSPR, XE3GF_CSPR_MASK)},
+       {OB500 | OB510 | OB6000 | OB6100, SIMPLE_BYTE(EC, OB500_STA1, OB500_DCKS_MASK)},
+       {OB4150, SIMPLE_BYTE(EC, OB4150_DCID, 0)},
+       {0,}
 };
 
-
 static struct omnibook_feature __declared_feature dock_driver = {
-        .name = "dock",
-        .enabled = 0,
-        .read = omnibook_dock_read,
-        .ectypes = XE3GF|OB500|OB510|OB6000|OB6100|OB4150,
-        .tbl = dock_table,
+       .name = "dock",
+       .enabled = 0,
+       .read = omnibook_dock_read,
+       .ectypes = XE3GF | OB500 | OB510 | OB6000 | OB6100 | OB4150,
+       .tbl = dock_table,
 };
 
 module_param_named(dock, dock_driver.enabled, int, S_IRUGO);
diff --git a/dump.c b/dump.c
index 2c0e47e5247a5821557ebda94798f3ee8a65f62d..7b1a0fedc9562cc7e9fba3d7b4b462439403357c 100644 (file)
--- a/dump.c
+++ b/dump.c
 
 static u8 ecdump_regs[256];
 
-static int ecdump_read(char *buffer,struct omnibook_operation *io_op)
+static int ecdump_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
        int i, j;
        u8 v;
 
-       len += sprintf(buffer + len, "EC      "
-                      " +00 +01 +02 +03 +04 +05 +06 +07"
-                      " +08 +09 +0a +0b +0c +0d +0e +0f\n");
+       len +=
+           sprintf(buffer + len,
+                   "EC      " " +00 +01 +02 +03 +04 +05 +06 +07"
+                   " +08 +09 +0a +0b +0c +0d +0e +0f\n");
        for (i = 0; i < 255; i += 16) {
                len += sprintf(buffer + len, "EC 0x%02x:", i);
                for (j = 0; j < 16; j++) {
-                       if (legacy_ec_read(i + j , &v))
+                       if (legacy_ec_read(i + j, &v))
                                break;
                        if (v != ecdump_regs[i + j])
                                len += sprintf(buffer + len, " *%02x", v);
@@ -51,15 +52,17 @@ static int ecdump_read(char *buffer,struct omnibook_operation *io_op)
 
        /* These are way too dangerous to advertise openly... */
 #if 0
-       len += sprintf(buffer + len, "commands:\t0x<offset> 0x<value>"
-                      " (<offset> is 00-ff, <value> is 00-ff)\n");
-       len += sprintf(buffer + len, "commands:\t0x<offset> <value>  "
-                      " (<offset> is 00-ff, <value> is 0-255)\n");
+       len +=
+           sprintf(buffer + len,
+                   "commands:\t0x<offset> 0x<value>" " (<offset> is 00-ff, <value> is 00-ff)\n");
+       len +=
+           sprintf(buffer + len,
+                   "commands:\t0x<offset> <value>  " " (<offset> is 00-ff, <value> is 0-255)\n");
 #endif
        return len;
 }
 
-static int ecdump_write(char *buffer,struct omnibook_operation *io_op)
+static int ecdump_write(char *buffer, struct omnibook_operation *io_op)
 {
 
        int i, v;
@@ -80,13 +83,12 @@ static int ecdump_write(char *buffer,struct omnibook_operation *io_op)
 }
 
 static struct omnibook_feature __declared_feature dump_driver = {
-        .name = "dump",
-        .enabled = 0,
-        .read = ecdump_read,
-        .write = ecdump_write,
+       .name = "dump",
+       .enabled = 0,
+       .read = ecdump_read,
+       .write = ecdump_write,
 };
 
 module_param_named(dump, dump_driver.enabled, int, S_IRUGO);
 MODULE_PARM_DESC(dump, "Use 0 to disable, 1 to enable embedded controller register dump support");
 /* End of file */
-
diff --git a/ec.c b/ec.c
index 2f10ff10d06810e50c1230033bafecd8a7c3ac8d..e8e30f046f4412b86966fb4a3cecd9379f3d9493 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -34,7 +34,6 @@
 
 static DEFINE_SPINLOCK(omnibook_ec_lock);
 
-
 /*
  * Timeout in ms for sending to controller
  */
@@ -52,9 +51,9 @@ static DEFINE_SPINLOCK(omnibook_ec_lock);
  * Embedded controller status register bits
  */
 
-#define OMNIBOOK_EC_STAT_OBF           0x01    /* Output buffer full */
-#define OMNIBOOK_EC_STAT_IBF           0x02    /* Input buffer full */
-#define OMNIBOOK_EC_STAT_CMD           0x08    /* Last write was a command write (0=data) */
+#define OMNIBOOK_EC_STAT_OBF           0x01    /* Output buffer full */
+#define OMNIBOOK_EC_STAT_IBF           0x02    /* Input buffer full */
+#define OMNIBOOK_EC_STAT_CMD           0x08    /* Last write was a command write (0=data) */
 
 /*
  * Embedded controller commands
@@ -84,7 +83,7 @@ static int omnibook_ec_wait(u8 event)
        default:
                return -EINVAL;
        }
-       if (timeout>0)
+       if (timeout > 0)
                return 0;
        return -ETIME;
 }
@@ -96,16 +95,16 @@ static int omnibook_ec_wait(u8 event)
  * disabled.
  */
 
-static int omnibook_ec_read(const struct omnibook_operation *io_op, u8 *data)
+static int omnibook_ec_read(const struct omnibook_operation *io_op, u8 * data)
 {
        int retval;
-       
+
 #ifdef CONFIG_ACPI_EC
        if (likely(!acpi_disabled)) {
                retval = ec_read((u8) io_op->read_addr, data);
-               if(io_op->read_mask)
+               if (io_op->read_mask)
                        *data &= io_op->read_mask;
-               dprintk("ACPI EC read at %lx success %i.\n",io_op->read_addr,retval);
+               dprintk("ACPI EC read at %lx success %i.\n", io_op->read_addr, retval);
                return retval;
        }
 #endif
@@ -122,14 +121,14 @@ static int omnibook_ec_read(const struct omnibook_operation *io_op, u8 *data)
        if (retval)
                goto end;
        *data = inb(OMNIBOOK_EC_DATA);
-       if(io_op->read_mask)
+       if (io_op->read_mask)
                *data &= io_op->read_mask;
-end:
+      end:
        spin_unlock_irq(&omnibook_ec_lock);
-       dprintk("Custom EC read at %lx success %i.\n",io_op->read_addr,retval);
+       dprintk("Custom EC read at %lx success %i.\n", io_op->read_addr, retval);
        return retval;
 }
-       
+
 /*
  * Write to the embedded controller:
  * If OMNIBOOK_LEGACY is set, decide at run-time if we can use the much cleaner 
@@ -142,15 +141,15 @@ end:
 static int omnibook_ec_write(const struct omnibook_operation *io_op, u8 data)
 {
        int retval;
-       
+
 #ifdef CONFIG_ACPI_EC
        if (likely(!acpi_disabled)) {
                retval = ec_write((u8) io_op->write_addr, data);
-               dprintk("ACPI EC write at %lx success %i.\n",io_op->write_addr,retval);
+               dprintk("ACPI EC write at %lx success %i.\n", io_op->write_addr, retval);
                return retval;
-       }       
+       }
 #endif
-       
+
        spin_lock_irq(&omnibook_ec_lock);
        retval = omnibook_ec_wait(OMNIBOOK_EC_STAT_IBF);
        if (retval)
@@ -164,9 +163,9 @@ static int omnibook_ec_write(const struct omnibook_operation *io_op, u8 data)
        if (retval)
                goto end;
        outb(data, OMNIBOOK_EC_DATA);
-end:
+      end:
        spin_unlock_irq(&omnibook_ec_lock);
-       dprintk("Custom EC write at %lx success %i.\n",io_op->write_addr,retval);
+       dprintk("Custom EC write at %lx success %i.\n", io_op->write_addr, retval);
        return retval;
 }
 
@@ -174,21 +173,14 @@ end:
  * legacy access function for unconverted old code who expect old omnibook_ec_read
  */
 
-int legacy_ec_read(u8 addr, u8 *data)
+int legacy_ec_read(u8 addr, u8 * data)
 {
        int retval;
-       struct omnibook_operation *io_op;
-
-       io_op = kzalloc(sizeof(struct omnibook_operation), GFP_KERNEL);
-       if(!io_op)
-               return -ENOMEM;
-       io_op->read_addr = addr;
-       retval = omnibook_ec_read(io_op, data);
-       kfree(io_op);
+       struct omnibook_operation io_op = SIMPLE_BYTE(EC, addr, 0);
+       retval = omnibook_ec_read(&io_op, data);
        return retval;
 }
 
-
 /*
  * legacy access function for unconverted old code who expect old omnibook_ec_write
  */
@@ -196,14 +188,8 @@ int legacy_ec_read(u8 addr, u8 *data)
 int legacy_ec_write(u8 addr, u8 data)
 {
        int retval;
-       struct omnibook_operation *io_op;
-
-       io_op = kzalloc(sizeof(struct omnibook_operation), GFP_KERNEL);
-       if(!io_op)
-               return -ENOMEM;
-       io_op->write_addr = addr;
-       retval = omnibook_ec_write(io_op, data);
-       kfree(io_op);
+       struct omnibook_operation io_op = SIMPLE_BYTE(EC, addr, 0);
+       retval = omnibook_ec_write(&io_op, data);
        return retval;
 }
 
@@ -213,13 +199,13 @@ static int omnibook_ec_display(const struct omnibook_operation *io_op, unsigned
        u8 raw_state;
 
        retval = io_op->backend->byte_read(io_op, &raw_state);
-       if(retval < 0)
+       if (retval < 0)
                return retval;
 
        *state = !!(raw_state) & DISPLAY_CRT_DET;
 
        return DISPLAY_CRT_DET;
-}      
+}
 
 /*
  * Registers of the keyboard controller
@@ -275,7 +261,7 @@ static int omnibook_kbc_write_command(u8 cmd)
                goto end;
        outb(cmd, OMNIBOOK_KBC_SC);
        retval = omnibook_kbc_wait(OMNIBOOK_KBC_STAT_IBF);
-end:
+      end:
        spin_unlock_irq(&omnibook_ec_lock);
        return retval;
 }
@@ -294,7 +280,7 @@ static int omnibook_kbc_write_data(u8 data)
                goto end;;
        outb(data, OMNIBOOK_KBC_DATA);
        retval = omnibook_kbc_wait(OMNIBOOK_KBC_STAT_IBF);
-end:
+      end:
        spin_unlock_irq(&omnibook_ec_lock);
        return retval;
 }
@@ -306,7 +292,7 @@ end:
 static int omnibook_kbc_command(const struct omnibook_operation *io_op, u8 data)
 {
        int retval;
-       
+
        if ((retval = omnibook_kbc_write_command(OMNIBOOK_KBC_CONTROL_CMD)))
                return retval;
 
@@ -320,15 +306,10 @@ static int omnibook_kbc_command(const struct omnibook_operation *io_op, u8 data)
 static int omnibook_kbc_hotkeys(const struct omnibook_operation *io_op, unsigned int state)
 {
        int retval;
-       struct omnibook_operation hotkeys_op;
 
-       hotkeys_op.backend = KBC;
-       hotkeys_op.on_mask = OMNIBOOK_KBC_CMD_ONETOUCH_ENABLE;
-       hotkeys_op.off_mask = OMNIBOOK_KBC_CMD_ONETOUCH_DISABLE;
+       retval = omnibook_toggle(io_op, !!(state & HKEY_ONETOUCH));
 
-       retval = omnibook_toggle( &hotkeys_op, !!(state & HKEY_ONETOUCH));
-       
-       if(retval < 0)
+       if (retval < 0)
                return retval;
        else
                return HKEY_ONETOUCH;
@@ -358,15 +339,15 @@ static struct pio_private_data_t pio_private_data = {
  * Match an entry in the linked list helper function: see if we have and entry
  * whose addr field match maddr
  */
-static struct pio_private_data_t * 
omnibook_match_port(struct pio_private_data_t *data, unsigned long maddr)
+static struct pio_private_data_t *omnibook_match_port(struct pio_private_data_t *data,
                                                    unsigned long maddr)
 {
-       struct list_head  *p;
+       struct list_head *p;
        struct pio_private_data_t *cursor;
 
-       list_for_each(p , &data->list ) {
+       list_for_each(p, &data->list) {
                cursor = list_entry(p, struct pio_private_data_t, list);
-               if( cursor->addr == maddr ) {
+               if (cursor->addr == maddr) {
                        return cursor;
                }
        }
@@ -380,29 +361,29 @@ static int omnibook_claim_port(struct pio_private_data_t *data, unsigned long ra
 {
        struct pio_private_data_t *match, *new;
 
-       match = omnibook_match_port( data, raddr);
-       if(match) {     
+       match = omnibook_match_port(data, raddr);
+       if (match) {
                /* Already requested by us: increment kref and quit */
                kref_get(&match->refcount);
                return 0;
-       }       
+       }
 
        /* there was no match: request the region and add to list */
-       if(!request_region(raddr ,1 , OMNIBOOK_MODULE_NAME)) {
+       if (!request_region(raddr, 1, OMNIBOOK_MODULE_NAME)) {
                printk(O_ERR "Request I/O port error\n");
                return -ENODEV;
        }
 
        new = kmalloc(sizeof(struct pio_private_data_t), GFP_KERNEL);
-       if(!new) {
-               release_region(raddr ,1 );
+       if (!new) {
+               release_region(raddr, 1);
                return -ENOMEM;
        }
 
        kref_init(&new->refcount);
        new->addr = raddr;
        list_add(&new->list, &data->list);
-       
+
        return 0;
 }
 
@@ -413,14 +394,14 @@ static int omnibook_pio_init(const struct omnibook_operation *io_op)
 {
        int retval = 0;
 
-       if(io_op->read_addr &&
-               (retval = omnibook_claim_port(io_op->backend->data, io_op->read_addr)))
+       if (io_op->read_addr
+           && (retval = omnibook_claim_port(io_op->backend->data, io_op->read_addr)))
                goto out;
 
-       if(io_op->write_addr && ( io_op->write_addr != io_op->read_addr ))
+       if (io_op->write_addr && (io_op->write_addr != io_op->read_addr))
                retval = omnibook_claim_port(io_op->backend->data, io_op->write_addr);
 
-out:
+      out:
        return retval;
 }
 
@@ -430,9 +411,9 @@ out:
 static void omnibook_free_port(struct kref *ref)
 {
        struct pio_private_data_t *data;
-       
+
        data = container_of(ref, struct pio_private_data_t, refcount);
-       release_region(data->addr ,1 );
+       release_region(data->addr, 1);
        list_del(&data->list);
        kfree(data);
 }
@@ -445,20 +426,20 @@ static void omnibook_pio_exit(const struct omnibook_operation *io_op)
        struct pio_private_data_t *match;
 
        match = omnibook_match_port(io_op->backend->data, io_op->read_addr);
-       if(match)
+       if (match)
                kref_put(&match->refcount, omnibook_free_port);
 
        match = NULL;
        match = omnibook_match_port(io_op->backend->data, io_op->write_addr);
-       if(match)
+       if (match)
                kref_put(&match->refcount, omnibook_free_port);
 
 }
 
-static int omnibook_io_read(const struct omnibook_operation *io_op, u8 *value)
+static int omnibook_io_read(const struct omnibook_operation *io_op, u8 * value)
 {
        *value = inb(io_op->read_addr);
-       if(io_op->read_mask)
+       if (io_op->read_mask)
                *value &= io_op->read_mask;
        return 0;
 }
@@ -469,7 +450,6 @@ static int omnibook_io_write(const struct omnibook_operation *io_op, u8 value)
        return 0;
 }
 
-
 /*
  * Backend interface declarations
  */
@@ -493,7 +473,7 @@ struct omnibook_backend ec_backend = {
        .name = "ec",
        .byte_read = omnibook_ec_read,
        .byte_write = omnibook_ec_write,
-       .display_get =  omnibook_ec_display,
+       .display_get = omnibook_ec_display,
 };
 
 int omnibook_apply_write_mask(const struct omnibook_operation *io_op, int toggle)
@@ -501,27 +481,26 @@ int omnibook_apply_write_mask(const struct omnibook_operation *io_op, int toggle
        int retval = 0;
        int mask;
        u8 data;
-       
 
-       if((retval = io_op->backend->byte_read(io_op,&data)))
+       if ((retval = io_op->backend->byte_read(io_op, &data)))
                return retval;
-       
-       iftoggle == 1)
+
+       if (toggle == 1)
                mask = io_op->on_mask;
-       else iftoggle == 0)
+       else if (toggle == 0)
                mask = io_op->off_mask;
        else
                return -EINVAL;
 
-       if(mask > 0)
+       if (mask > 0)
                data |= (u8) mask;
        else if (mask < 0)
                data &= ~((u8) (-mask));
        else
                return -EINVAL;
 
-       retval = io_op->backend->byte_write(io_op,data);
-       
+       retval = io_op->backend->byte_write(io_op, data);
+
        return retval;
 }
 
@@ -532,11 +511,10 @@ int omnibook_toggle(const struct omnibook_operation *io_op, int toggle)
 {
        int retval;
        u8 data;
-       
+
        data = toggle ? io_op->on_mask : io_op->off_mask;
        retval = io_op->backend->byte_write(io_op, data);
        return retval;
 }
 
-
 /* End of file */
diff --git a/ec.h b/ec.h
index 772f2e67de41508eaa3751cb7ba6b83ff66375b7..cf8fc87f9bd713dcbdac28081ac5b47ded4aa939 100644 (file)
--- a/ec.h
+++ b/ec.h
@@ -34,8 +34,8 @@ struct omnibook_operation {
                int off_mask; /* mask to set (pos value) or unset (neg value) to put feature to off state */
 };
 
-#define COMMAND(backend,data_on,data_off) .io_op = { backend, 0, 0, 0, data_on, data_off }
-#define SIMPLE_BYTE(backend,addr,mask) .io_op = { backend, addr, addr, mask, 0, 0 }
+#define COMMAND(backend,data_on,data_off) { backend, 0, 0, 0, data_on, data_off }
+#define SIMPLE_BYTE(backend,addr,mask) { backend, addr, addr, mask, 0, 0 }
 
 struct omnibook_tbl {
        enum omnibook_ectype_t ectypes;
diff --git a/fan.c b/fan.c
index aa66e049f1fcdbae7132eaf684002a054487007f..ba88cbd5505735de0cfb1d6ebf17ab2cbd55b681 100644 (file)
--- a/fan.c
+++ b/fan.c
 #include <asm/io.h>
 #include "ec.h"
 
-static struct omnibook_operation ctmp_io_op = { EC, XE3GF_CTMP , 0, 0, 0, 0};
-static struct omnibook_operation fot_io_op = { EC, XE3GF_FOT, XE3GF_FOT, 0, 0, 0};
+static const struct omnibook_operation ctmp_io_op = { EC, XE3GF_CTMP, 0, 0, 0, 0 };
+static const struct omnibook_operation fot_io_op = { EC, XE3GF_FOT, XE3GF_FOT, 0, 0, 0 };
 
 static int omnibook_get_fan(struct omnibook_operation *io_op)
 {
        u8 fan;
        int retval;
 
-       if((retval = io_op->backend->byte_read(io_op, &fan)))
+       if ((retval = io_op->backend->byte_read(io_op, &fan)))
                return retval;
 
        /*
@@ -38,9 +38,9 @@ static int omnibook_get_fan(struct omnibook_operation *io_op)
         * TSP10|XE3GF return an integer
         */
 
-       if(omnibook_ectype & (TSP10|XE3GF))
+       if (omnibook_ectype & (TSP10 | XE3GF))
                retval = fan;
-       else if(omnibook_ectype & (OB6000|OB6100|OB4150|AMILOD))
+       else if (omnibook_ectype & (OB6000 | OB6100 | OB4150 | AMILOD))
                retval = !!fan;
        else
                retval = !fan;
@@ -50,22 +50,22 @@ static int omnibook_get_fan(struct omnibook_operation *io_op)
 
 static int omnibook_fan_on(struct omnibook_operation *io_op)
 {
-       return omnibook_apply_write_mask(io_op,1);
+       return omnibook_apply_write_mask(io_op, 1);
 }
 
 static int omnibook_fan_off(struct omnibook_operation *io_op)
 {
-       int i,retval = 0;
+       int i, retval = 0;
 
 /*
  * Special handling for XE3GF & TSP10
  */
-       if (omnibook_ectype & (XE3GF|TSP10) ) {
+       if (omnibook_ectype & (XE3GF | TSP10)) {
                u8 fot, temp;
                retval = omnibook_get_fan(io_op);
-               
+
                /* error or fan is already off */
-               if (retval <= 0 )
+               if (retval <= 0)
                        return retval;
 
                /* now we set FOT to current temp, then reset to initial value */
@@ -73,14 +73,14 @@ static int omnibook_fan_off(struct omnibook_operation *io_op)
                        return retval;
                if ((retval = ctmp_io_op.backend->byte_read(&ctmp_io_op, &temp)))
                        return retval;
-               
+
 /*
  * Wait for no longer than 250ms, this is arbitrary
  */
-               for(i=0; i < 250; i++) {
+               for (i = 0; i < 250; i++) {
                        fot_io_op.backend->byte_write(&fot_io_op, temp);
                        mdelay(1);
-                       ifomnibook_get_fan(io_op) == 0) {
+                       if (omnibook_get_fan(io_op) == 0) {
                                retval = fot_io_op.backend->byte_write(&fot_io_op, fot);
                                return retval;
                        }
@@ -88,13 +88,13 @@ static int omnibook_fan_off(struct omnibook_operation *io_op)
                fot_io_op.backend->byte_write(&fot_io_op, fot);
                printk(O_ERR "Attempt to switch off the fan failed.\n");
                return -EIO;
-       } else 
+       } else
                retval = omnibook_apply_write_mask(io_op, 0);
 
        return retval;
 }
 
-static int omnibook_fan_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_fan_read(char *buffer, struct omnibook_operation *io_op)
 {
        int fan;
        int len = 0;
@@ -113,7 +113,7 @@ static int omnibook_fan_read(char *buffer,struct omnibook_operation *io_op)
        return len;
 }
 
-static int omnibook_fan_write(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_fan_write(char *buffer, struct omnibook_operation *io_op)
 {
        int retval;
 
@@ -142,29 +142,32 @@ static int __init omnibook_fan_init(struct omnibook_operation *io_op)
         * AMILOD
         * They only support fan reading 
         */
-       if (omnibook_ectype & (OB4150|XE2|AMILOD) )
+       if (omnibook_ectype & (OB4150 | XE2 | AMILOD))
                fan_feature.write = NULL;
        return 0;
 }
 
 static struct omnibook_tbl fan_table[] __initdata = {
-       { XE3GF|TSP10,   {EC,XE3GF_FSRD,XE3GF_FSRD,0,XE3GF_FAN_ON_MASK,0}},
-       { OB500,         {PIO,OB500_GPO1,OB500_GPO1,OB500_FAN_OFF_MASK,-OB500_FAN_ON_MASK,OB500_FAN_OFF_MASK}},
-       { OB510,         {PIO,OB510_GPIO,OB510_GPIO,OB510_FAN_OFF_MASK,-OB510_FAN_ON_MASK,OB510_FAN_OFF_MASK}},
-       { OB6000|OB6100, {EC,OB6000_STA1,OB6000_STA1,OB6000_FAN_MASK,OB6000_FAN_MASK,-OB6000_FAN_MASK}},
-       { OB4150|AMILOD, {EC,OB4150_STA1,0,OB4150_FAN_MASK,0,0}},
-       { XE2,           {PIO,OB500_GPO1,0,XE2_FAN_MASK,0,0}},
-       { 0,}
+       {XE3GF | TSP10, {EC, XE3GF_FSRD, XE3GF_FSRD, 0, XE3GF_FAN_ON_MASK, 0}},
+       {OB500,
+        {PIO, OB500_GPO1, OB500_GPO1, OB500_FAN_OFF_MASK, -OB500_FAN_ON_MASK, OB500_FAN_OFF_MASK}},
+       {OB510,
+        {PIO, OB510_GPIO, OB510_GPIO, OB510_FAN_OFF_MASK, -OB510_FAN_ON_MASK, OB510_FAN_OFF_MASK}},
+       {OB6000 | OB6100,
+        {EC, OB6000_STA1, OB6000_STA1, OB6000_FAN_MASK, OB6000_FAN_MASK, -OB6000_FAN_MASK}},
+       {OB4150 | AMILOD, {EC, OB4150_STA1, 0, OB4150_FAN_MASK, 0, 0}},
+       {XE2, {PIO, OB500_GPO1, 0, XE2_FAN_MASK, 0, 0}},
+       {0,}
 };
 
 static struct omnibook_feature __declared_feature fan_driver = {
-        .name = "fan",
-        .enabled = 1,
-        .read = omnibook_fan_read,
-        .write = omnibook_fan_write,
-        .init = omnibook_fan_init,
-        .ectypes = XE3GF|OB500|OB510|OB6000|OB6100|OB4150|XE2|AMILOD|TSP10,
-        .tbl = fan_table,
+       .name = "fan",
+       .enabled = 1,
+       .read = omnibook_fan_read,
+       .write = omnibook_fan_write,
+       .init = omnibook_fan_init,
+       .ectypes = XE3GF | OB500 | OB510 | OB6000 | OB6100 | OB4150 | XE2 | AMILOD | TSP10,
+       .tbl = fan_table,
 };
 
 module_param_named(fan, fan_feature.enabled, int, S_IRUGO);
index d5b49e9cec1be6861568e99c95e1ae5904681710..ab86a6b65f6604598880a0c2504d222cee42f2a0 100644 (file)
@@ -46,11 +46,11 @@ static int omnibook_get_fan_policy(void)
        int retval = 0;
        int i;
        u8 tmp;
-       
+
        /*
         * XE3GF
         */
-       if (omnibook_ectype & (XE3GF) ) {
+       if (omnibook_ectype & (XE3GF)) {
                for (i = 0; i <= OMNIBOOK_FAN_LEVELS; i++) {
                        if ((retval = legacy_ec_read(XE3GF_FOT + i, &tmp)))
                                return retval;
@@ -72,12 +72,11 @@ static int omnibook_set_fan_policy(void)
        /*
         * XE3GF
         */
-       if (omnibook_ectype & (XE3GF) ) {
+       if (omnibook_ectype & (XE3GF)) {
                if (omnibook_fan_policy[0] > OMNIBOOK_FOT_MAX)
                        return -EINVAL;
                for (i = 0; i < OMNIBOOK_FAN_LEVELS; i++) {
-                       if ((omnibook_fan_policy[i] >
-                            omnibook_fan_policy[i + 1])
+                       if ((omnibook_fan_policy[i] > omnibook_fan_policy[i + 1])
                            || (omnibook_fan_policy[i] < OMNIBOOK_FAN_MIN)
                            || (omnibook_fan_policy[i] > OMNIBOOK_FAN_MAX))
                                return -EINVAL;
@@ -85,8 +84,7 @@ static int omnibook_set_fan_policy(void)
                                return -EINVAL;
                }
                for (i = 0; i <= OMNIBOOK_FAN_LEVELS; i++) {
-                       if ((retval =
-                            legacy_ec_write(XE3GF_FOT + i, omnibook_fan_policy[i])))
+                       if ((retval = legacy_ec_write(XE3GF_FOT + i, omnibook_fan_policy[i])))
                                return retval;
                }
        } else {
@@ -115,7 +113,7 @@ static int omnibook_set_fan_policy_defaults(void)
        /*
         * XE3GF
         */
-       if (omnibook_ectype & (XE3GF) ) {
+       if (omnibook_ectype & (XE3GF)) {
                for (i = 0; i <= OMNIBOOK_FAN_LEVELS; i++) {
                        if ((retval = legacy_ec_write(XE3GF_FOT + i, fan_defaults[i])))
                                return retval;
@@ -128,7 +126,7 @@ static int omnibook_set_fan_policy_defaults(void)
        return retval;
 }
 
-static int omnibook_fan_policy_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_fan_policy_read(char *buffer, struct omnibook_operation *io_op)
 {
        int retval;
        int len = 0;
@@ -137,29 +135,20 @@ static int omnibook_fan_policy_read(char *buffer,struct omnibook_operation *io_o
        if ((retval = omnibook_get_fan_policy()))
                return retval;
 
-       len +=
-           sprintf(buffer + len, "Fan off temperature:        %2d C\n",
-                   omnibook_fan_policy[0]);
-       len +=
-           sprintf(buffer + len, "Fan on temperature:         %2d C\n",
-                   omnibook_fan_policy[1]);
+       len += sprintf(buffer + len, "Fan off temperature:        %2d C\n", omnibook_fan_policy[0]);
+       len += sprintf(buffer + len, "Fan on temperature:         %2d C\n", omnibook_fan_policy[1]);
        for (i = 2; i <= OMNIBOOK_FAN_LEVELS; i++) {
                len +=
-                   sprintf(buffer + len,
-                           "Fan level %1d temperature:    %2d C\n", i,
+                   sprintf(buffer + len, "Fan level %1d temperature:    %2d C\n", i,
                            omnibook_fan_policy[i]);
        }
-       len +=
-           sprintf(buffer + len, "Minimal temperature to set: %2d C\n",
-                   OMNIBOOK_FAN_MIN);
-       len +=
-           sprintf(buffer + len, "Maximal temperature to set: %2d C\n",
-                   OMNIBOOK_FAN_MAX);
+       len += sprintf(buffer + len, "Minimal temperature to set: %2d C\n", OMNIBOOK_FAN_MIN);
+       len += sprintf(buffer + len, "Maximal temperature to set: %2d C\n", OMNIBOOK_FAN_MAX);
 
        return len;
 }
 
-static int omnibook_fan_policy_write(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_fan_policy_write(char *buffer, struct omnibook_operation *io_op)
 {
        int n = 0;
        char *b;
@@ -202,11 +191,11 @@ static int omnibook_fan_policy_write(char *buffer,struct omnibook_operation *io_
 }
 
 static struct omnibook_feature __declared_feature fan_policy_driver = {
-        .name = "fan_policy",
-        .enabled = 1,
-        .read = omnibook_fan_policy_read,
-        .write = omnibook_fan_policy_write,
-        .ectypes = XE3GF,
+       .name = "fan_policy",
+       .enabled = 1,
+       .read = omnibook_fan_policy_read,
+       .write = omnibook_fan_policy_write,
+       .ectypes = XE3GF,
 };
 
 module_param_named(fan_policy, fan_policy_driver.enabled, int, S_IRUGO);
index 34829886896f009a0b0dc9751e4d826519db3590..5bc8cdf3c9ddfb72829986fd825a913b36ab5281 100644 (file)
--- a/hotkeys.c
+++ b/hotkeys.c
@@ -18,7 +18,6 @@
 #include "omnibook.h"
 #include "ec.h"
 
-
 /*
  * Save state for suspend/resume operation
  */
@@ -33,38 +32,38 @@ static int omnibook_hotkeys_set(struct omnibook_operation *io_op, unsigned int s
        int write_capability;
 
        write_capability = io_op->backend->hotkeys_set(io_op, state);
-       ifwrite_capability < 0)
+       if (write_capability < 0)
                goto out;
 
        /* Update saved state */
        saved_state = state & write_capability;
 
-out:   
+      out:
        return write_capability;
 }
 
 static int omnibook_hotkeys_get(struct omnibook_operation *io_op, unsigned int *state)
 {
-       
+
        unsigned int read_state = 0;
        int read_capability = 0;
-       
-       if(io_op->backend->hotkeys_get)
+
+       if (io_op->backend->hotkeys_get)
                read_capability = io_op->backend->hotkeys_get(io_op, &read_state);
-       if(read_capability < 0)
+       if (read_capability < 0)
                goto out;
 
        /* Return previously set state for the fields that are write only */
        *state = (read_state & read_capability) + (saved_state & ~read_capability);
 
-out:   
+      out:
        return read_capability;
 }
 
 /*
  * Power management handlers
  */
+
 /*
  * Restore previously saved state
  */
@@ -72,7 +71,7 @@ static int omnibook_hotkeys_resume(struct omnibook_operation *io_op)
 {
        int retval;
        retval = io_op->backend->hotkeys_set(io_op, saved_state);
-       return min(retval,0);
+       return min(retval, 0);
 }
 
 /*
@@ -83,13 +82,13 @@ static int omnibook_hotkeys_suspend(struct omnibook_operation *io_op)
        int retval = 0;
 
        retval = omnibook_hotkeys_get(io_op, &saved_state);
-       if(retval < 0)
+       if (retval < 0)
                return retval;
 
        retval = io_op->backend->hotkeys_set(io_op, HKEY_OFF);
-       if(retval < 0)
+       if (retval < 0)
                return retval;
-       
+
        return 0;
 }
 
@@ -103,35 +102,35 @@ static const char pretty_name[][27] = {
        "Fn + F5 hotkey is"
 };
 
-static int omnibook_hotkeys_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_hotkeys_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
        int read_capability, write_capability;
        unsigned int read_state, mask;
 
        read_capability = omnibook_hotkeys_get(io_op, &read_state);
-       if(read_capability < 0)
+       if (read_capability < 0)
                return read_capability;
 
        write_capability = omnibook_hotkeys_set(io_op, read_state);
-       if(write_capability < 0)
+       if (write_capability < 0)
                return write_capability;
 
-       for( mask = HKEY_ONETOUCH ; mask <= HKEY_FNF5; mask = mask << 1) {
-       /* we assume write capability or read capability imply support */
-                if( (read_capability | write_capability ) & mask )
-                       len += sprintf(buffer + len, "%s %s.\n", 
-                               pretty_name[ ffs(mask) - 1 ],
-                               ( read_state & mask ) ? "enabled" : "disabled");
+       for (mask = HKEY_ONETOUCH; mask <= HKEY_FNF5; mask = mask << 1) {
+               /* we assume write capability or read capability imply support */
+               if ((read_capability | write_capability) & mask)
+                       len +=
+                           sprintf(buffer + len, "%s %s.\n", pretty_name[ffs(mask) - 1],
+                                   (read_state & mask) ? "enabled" : "disabled");
        }
        return len;
 }
 
-static int omnibook_hotkeys_write(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_hotkeys_write(char *buffer, struct omnibook_operation *io_op)
 {
-       unsigned int state;     
+       unsigned int state;
        char *endp;
-       
+
        if (strncmp(buffer, "off", 3) == 0)
                omnibook_hotkeys_set(io_op, HKEY_OFF);
        else if (strncmp(buffer, "on", 2) == 0)
@@ -147,8 +146,8 @@ static int omnibook_hotkeys_write(char *buffer,struct omnibook_operation *io_op)
 }
 
 static int __init omnibook_hotkeys_init(struct omnibook_operation *io_op)
-{      
-       int retval;     
+{
+       int retval;
        printk(O_INFO "Enabling all hotkeys.\n");
        retval = omnibook_hotkeys_set(io_op, HKEY_ON);
        return retval < 0 ? retval : 0;
@@ -161,23 +160,26 @@ static void __exit omnibook_hotkeys_cleanup(struct omnibook_operation *io_op)
 }
 
 static struct omnibook_tbl hotkey_table[] __initdata = {
-       { XE3GF|XE3GC|OB500|OB510|OB6000|OB6100|XE4500|AMILOD|TSP10, {KBC,}},
-       { TSM30X,       {CDI,}},
-       { TSM40,        {SMI,}},
-       { 0,}
+       {XE3GF | XE3GC | OB500 | OB510 | OB6000 | OB6100 | XE4500 | AMILOD | TSP10, 
+       COMMAND(KBC,OMNIBOOK_KBC_CMD_ONETOUCH_ENABLE,OMNIBOOK_KBC_CMD_ONETOUCH_DISABLE)},
+       {TSM30X, {CDI,}},
+       {TSM40, {SMI,}},
+       {0,}
 };
 
 static struct omnibook_feature __declared_feature hotkeys_driver = {
-        .name = "hotkeys",
-        .enabled = 1,
-        .read = omnibook_hotkeys_read,
-        .write = omnibook_hotkeys_write,
-        .init = omnibook_hotkeys_init,
-        .exit = omnibook_hotkeys_cleanup,
-        .suspend = omnibook_hotkeys_suspend,
-        .resume = omnibook_hotkeys_resume,
-        .ectypes = XE3GF|XE3GC|OB500|OB510|OB6000|OB6100|XE4500|AMILOD|TSP10|TSM30X|TSM40,
-        .tbl = hotkey_table,
+       .name = "hotkeys",
+       .enabled = 1,
+       .read = omnibook_hotkeys_read,
+       .write = omnibook_hotkeys_write,
+       .init = omnibook_hotkeys_init,
+       .exit = omnibook_hotkeys_cleanup,
+       .suspend = omnibook_hotkeys_suspend,
+       .resume = omnibook_hotkeys_resume,
+       .ectypes =
+           XE3GF | XE3GC | OB500 | OB510 | OB6000 | OB6100 | XE4500 | AMILOD | TSP10 | TSM30X |
+           TSM40,
+       .tbl = hotkey_table,
 };
 
 module_param_named(hotkeys, hotkeys_driver.enabled, int, S_IRUGO);
diff --git a/info.c b/info.c
index 386f7f930f667c04f23b326dd30bd807f5269f13..8e25e7a1a9d2b35a6726fcdd9dd253a6fe25321a 100644 (file)
--- a/info.c
+++ b/info.c
@@ -20,7 +20,7 @@
 #include <linux/dmi.h>
 #include <linux/version.h>
 
-static int omnibook_version_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_version_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
 
@@ -29,53 +29,37 @@ static int omnibook_version_read(char *buffer,struct omnibook_operation *io_op)
        return len;
 }
 
-static int omnibook_dmi_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_dmi_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
 
+       len += sprintf(buffer + len, "BIOS Vendor:   %s\n", dmi_get_system_info(DMI_BIOS_VENDOR));
+       len += sprintf(buffer + len, "BIOS Version:  %s\n", dmi_get_system_info(DMI_BIOS_VERSION));
+       len += sprintf(buffer + len, "BIOS Release:  %s\n", dmi_get_system_info(DMI_BIOS_DATE));
+       len += sprintf(buffer + len, "System Vendor: %s\n", dmi_get_system_info(DMI_SYS_VENDOR));
+       len += sprintf(buffer + len, "Product Name:  %s\n", dmi_get_system_info(DMI_PRODUCT_NAME));
        len +=
-           sprintf(buffer + len, "BIOS Vendor:   %s\n",
-                   dmi_get_system_info(DMI_BIOS_VENDOR));
+           sprintf(buffer + len, "Version:       %s\n", dmi_get_system_info(DMI_PRODUCT_VERSION));
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
        len +=
-           sprintf(buffer + len, "BIOS Version:  %s\n",
-                   dmi_get_system_info(DMI_BIOS_VERSION));
-       len +=
-           sprintf(buffer + len, "BIOS Release:  %s\n",
-                   dmi_get_system_info(DMI_BIOS_DATE));
-       len +=
-           sprintf(buffer + len, "System Vendor: %s\n",
-                   dmi_get_system_info(DMI_SYS_VENDOR));
-       len +=
-           sprintf(buffer + len, "Product Name:  %s\n",
-                   dmi_get_system_info(DMI_PRODUCT_NAME));
-       len +=
-           sprintf(buffer + len, "Version:       %s\n",
-                   dmi_get_system_info(DMI_PRODUCT_VERSION));
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))     
-       len +=
-           sprintf(buffer + len, "Serial Number: %s\n",
-                   dmi_get_system_info(DMI_PRODUCT_SERIAL));
+           sprintf(buffer + len, "Serial Number: %s\n", dmi_get_system_info(DMI_PRODUCT_SERIAL));
 #endif
-       len +=
-           sprintf(buffer + len, "Board Vendor:  %s\n",
-                   dmi_get_system_info(DMI_BOARD_VENDOR));
-       len +=
-           sprintf(buffer + len, "Board Name:    %s\n",
-                   dmi_get_system_info(DMI_BOARD_VERSION));
+       len += sprintf(buffer + len, "Board Vendor:  %s\n", dmi_get_system_info(DMI_BOARD_VENDOR));
+       len += sprintf(buffer + len, "Board Name:    %s\n", dmi_get_system_info(DMI_BOARD_VERSION));
 
        return len;
 }
 
 static struct omnibook_feature __declared_feature version_driver = {
-        .name = "version",
-        .enabled = 1,
-        .read = omnibook_version_read,
+       .name = "version",
+       .enabled = 1,
+       .read = omnibook_version_read,
 };
 
 static struct omnibook_feature __declared_feature dmi_driver = {
-        .name = "dmi",
-        .enabled = 1,
-        .read = omnibook_dmi_read,
+       .name = "dmi",
+       .enabled = 1,
+       .read = omnibook_dmi_read,
 };
 
 module_param_named(dmi, dmi_driver.enabled, int, S_IRUGO);
diff --git a/init.c b/init.c
index ba08eb1b09c6e07f5937b78ee289e1e4c9273e0a..079ac4844fa7dffc9f9e2aaeec8f0587775bfb76 100644 (file)
--- a/init.c
+++ b/init.c
@@ -79,12 +79,11 @@ static int compat_omnibook_resume(struct device *dev, u32 level)
 
 #endif
 
-
 static struct proc_dir_entry *omnibook_proc_root = NULL;
 
 enum omnibook_ectype_t omnibook_ectype = NONE;
 
-static charlaptop_model __initdata;
+static char *laptop_model __initdata;
 
 static int omnibook_userset = 0;
 
@@ -104,15 +103,15 @@ static struct platform_driver omnibook_driver = {
 #endif
        .driver = {
                   .name = OMNIBOOK_MODULE_NAME,
-                  .owner  = THIS_MODULE,
+                  .owner = THIS_MODULE,
                   },
 };
 
-#else /* 2.6.15 */
+#else                          /* 2.6.15 */
 
 static struct device_driver omnibook_driver = {
-       .name   = OMNIBOOK_MODULE_NAME,
-       .bus    = &platform_bus_type,
+       .name = OMNIBOOK_MODULE_NAME,
+       .bus = &platform_bus_type,
        .probe = compat_omnibook_probe,
        .remove = compat_omnibook_remove,
 #ifdef CONFIG_PM
@@ -120,13 +119,12 @@ static struct device_driver omnibook_driver = {
        .resume = compat_omnibook_resume,
 #endif
 };
+
 static struct platform_device omnibook_device = {
-       .name   = OMNIBOOK_MODULE_NAME,
+       .name = OMNIBOOK_MODULE_NAME,
 };
 
-#endif /* 2.6.15 */
-
+#endif                         /* 2.6.15 */
 
 /* Linked list of all enabled features */
 static struct omnibook_feature *omnibook_available_feature;
@@ -137,19 +135,19 @@ extern struct omnibook_feature _end_features_driver[];
 
 static int __init dmi_matched(struct dmi_system_id *dmi)
 {
-       omnibook_ectype = (int) dmi->driver_data;
+       omnibook_ectype = (int)dmi->driver_data;
        if (dmi->ident)
-               laptop_model = (char*) dmi->ident;
+               laptop_model = (char *)dmi->ident;
        else
                laptop_model = dmi_get_system_info(DMI_PRODUCT_VERSION);
-       return 1; /* return non zero means we stop the parsing selecting this entry*/
+       return 1;               /* return non zero means we stop the parsing selecting this entry */
 }
 
 /* 
  * Callback function for procfs file reading: the name of the file read was stored in *data 
  */
-static int procfile_read_dispatch(char *page, char **start, off_t off,
-                                 int count, int *eof, void *data)
+static int procfile_read_dispatch(char *page, char **start, off_t off, int count, int *eof,
+                                 void *data)
 {
        struct omnibook_feature *feature = (struct omnibook_feature *)data;
        int len;
@@ -157,7 +155,7 @@ static int procfile_read_dispatch(char *page, char **start, off_t off,
        if (!feature || !feature->read)
                return -EINVAL;
 
-       len = feature->read(page,feature->io_op);
+       len = feature->read(page, feature->io_op);
        if (len < 0)
                return len;
 
@@ -176,8 +174,7 @@ static int procfile_read_dispatch(char *page, char **start, off_t off,
 /* 
  * Callback function for procfs file writing: the name of the file written was stored in *data 
  */
-static int procfile_write_dispatch(struct file *file,
-                                  const char __user * userbuf,
+static int procfile_write_dispatch(struct file *file, const char __user * userbuf,
                                   unsigned long count, void *data)
 {
        struct omnibook_feature *feature = (struct omnibook_feature *)data;
@@ -199,7 +196,7 @@ static int procfile_write_dispatch(struct file *file,
        /* Make sure the string is \0 terminated */
        kernbuf[count] = '\0';
 
-       retval = feature->write(kernbuf,feature->io_op);
+       retval = feature->write(kernbuf, feature->io_op);
        if (retval == 0)
                retval = count;
 
@@ -213,26 +210,26 @@ static int procfile_write_dispatch(struct file *file,
  * Also make corresponding backend initialisation if necessary, and skip
  * to the next entry if it fails.
  */
-static struct omnibook_operation * omnibook_backend_match(struct omnibook_tbl *tbl)
+static struct omnibook_operation *omnibook_backend_match(struct omnibook_tbl *tbl)
 {
        int i;
        struct omnibook_operation *matched = NULL;
 
-       for (i = 0; tbl[i].ectypes ; i++) {
+       for (i = 0; tbl[i].ectypes; i++) {
                if (omnibook_ectype & tbl[i].ectypes) {
-                       if(tbl[i].io_op.backend->init && tbl[i].io_op.backend->init(&tbl[i].io_op)) {
-                               dprintk("Backend %s init failed, skipping entry.\n", tbl[i].io_op.backend->name);
+                       if (tbl[i].io_op.backend->init && tbl[i].io_op.backend->init(&tbl[i].io_op)) {
+                               dprintk("Backend %s init failed, skipping entry.\n",
+                                       tbl[i].io_op.backend->name);
                                continue;
-                       } 
+                       }
                        matched = &tbl[i].io_op;
-                       dprintk("Returning table entry n°%i.\n",i);
+                       dprintk("Returning table entry n°%i.\n", i);
                        break;
                }
        }
        return matched;
 }
 
-
 /* 
  * Initialise a feature and add it to the linked list of active features
  */
@@ -250,27 +247,25 @@ static int __init omnibook_init(struct omnibook_feature *feature)
  * Select appropriate backend for feature operations
  * We copy the io_op field so the tbl can be initdata
  */
-       if(feature->tbl) {
-               dprintk("begin table match of %s feature.\n",feature->name);
+       if (feature->tbl) {
+               dprintk("Begin table match of %s feature.\n", feature->name);
                op = omnibook_backend_match(feature->tbl);
-               if(!op) {
-                       dprintk("match failed: disabling %s.\n",feature->name);
+               if (!op) {
+                       dprintk("Match failed: disabling %s.\n", feature->name);
                        return -ENODEV;
                }
-               feature->io_op = kmalloc(sizeof(struct omnibook_operation),GFP_KERNEL);
+               feature->io_op = kmalloc(sizeof(struct omnibook_operation), GFP_KERNEL);
                if (!feature->io_op)
                        return -ENOMEM;
                memcpy(feature->io_op, op, sizeof(struct omnibook_operation));
        } else
-               dprintk("%s feature has no backend table, io_op not initialized.\n",feature->name);
+               dprintk("%s feature has no backend table, io_op not initialized.\n", feature->name);
 
 /*
  * Specific feature init code
  */
        if (feature->init && (retval = feature->init(feature->io_op))) {
-               printk(O_ERR "Init function of %s failed with error %i.\n",
-                       feature->name,
-                       retval);
+               printk(O_ERR "Init function of %s failed with error %i.\n", feature->name, retval);
                goto err;
        }
 /*
@@ -287,15 +282,12 @@ static int __init omnibook_init(struct omnibook_feature *feature)
                 * FIXME: Special case for apmemu (not under /proc/omnibook)
                 */
                if (feature->proc_entry)
-                       proc_entry = create_proc_entry(feature->proc_entry, pmode,
-                                                     NULL);
+                       proc_entry = create_proc_entry(feature->proc_entry, pmode, NULL);
                else
-                       proc_entry = create_proc_entry(feature->name, pmode,
-                                              omnibook_proc_root);
+                       proc_entry = create_proc_entry(feature->name, pmode, omnibook_proc_root);
 
                if (!proc_entry) {
-                       printk(O_ERR
-                              "Unable to create proc entry %s\n",feature->name);
+                       printk(O_ERR "Unable to create proc entry %s\n", feature->name);
                        if (feature->exit)
                                feature->exit(feature->io_op);
                        retval = -ENOENT;
@@ -309,14 +301,13 @@ static int __init omnibook_init(struct omnibook_feature *feature)
        }
        list_add_tail(&feature->list, &omnibook_available_feature->list);
        return 0;
-err:
+      err:
        if (feature->io_op && feature->io_op->backend->exit)
                feature->io_op->backend->exit(feature->io_op);
        kfree(feature->io_op);
        return retval;
 }
 
-
 /* 
  * Callback function for driver registering :
  * Initialize the linked list of enabled features and call omnibook_init to populate it
@@ -327,24 +318,22 @@ static int __init omnibook_probe(struct platform_device *dev)
        struct list_head *p;
        struct omnibook_feature *feature;
 
-       
-       omnibook_available_feature =
-           kzalloc(sizeof(struct omnibook_feature), GFP_KERNEL);
+       omnibook_available_feature = kzalloc(sizeof(struct omnibook_feature), GFP_KERNEL);
        if (!omnibook_available_feature)
                return -ENOMEM;
        INIT_LIST_HEAD(&omnibook_available_feature->list);
-       
-       for (i=0; i < _end_features_driver - _start_features_driver; i++ ) {
-               
+
+       for (i = 0; i < _end_features_driver - _start_features_driver; i++) {
+
                feature = &_start_features_driver[i];
 
-               if (!feature->enabled)  
+               if (!feature->enabled)
                        continue;
-               
+
                if ((omnibook_ectype & feature->ectypes) || (!feature->ectypes))
                        omnibook_init(feature);
        }
-       
+
        printk(O_INFO "Enabled features:");
        list_for_each(p, &omnibook_available_feature->list) {
                feature = list_entry(p, struct omnibook_feature, list);
@@ -352,7 +341,7 @@ static int __init omnibook_probe(struct platform_device *dev)
                        printk(" %s", feature->name);
        }
        printk(".\n");
-       
+
        return 0;
 }
 
@@ -368,8 +357,8 @@ static int __exit omnibook_remove(struct platform_device *dev)
                feature = list_entry(p, struct omnibook_feature, list);
                list_del(p);
                /* Feature specific cleanup */
-                if (feature->exit)
-                        feature->exit(feature->io_op);
+               if (feature->exit)
+                       feature->exit(feature->io_op);
                /* Generic backend cleanup */
                if (feature->io_op && feature->io_op->backend->exit)
                        feature->io_op->backend->exit(feature->io_op);
@@ -380,7 +369,7 @@ static int __exit omnibook_remove(struct platform_device *dev)
                kfree(feature->io_op);
        }
        kfree(omnibook_available_feature);
-       
+
        return 0;
 }
 
@@ -398,9 +387,7 @@ static int omnibook_suspend(struct platform_device *dev, pm_message_t state)
                if (feature->suspend) {
                        retval = feature->suspend(feature->io_op);
                        if (!retval)
-                               printk(O_ERR
-                                       "Unable to suspend the %s feature",
-                                       feature->name);
+                               printk(O_ERR "Unable to suspend the %s feature", feature->name);
                }
        }
        return 0;
@@ -420,9 +407,7 @@ static int omnibook_resume(struct platform_device *dev)
                if (feature->resume) {
                        retval = feature->resume(feature->io_op);
                        if (!retval)
-                               printk(O_ERR
-                                      "Unable to resume the %s feature",
-                                      feature->name);
+                               printk(O_ERR "Unable to resume the %s feature", feature->name);
                }
        }
        return 0;
@@ -437,18 +422,19 @@ static int __init set_ectype_param(const char *val, struct kernel_param *kp)
        char *endp;
        int value;
 
-       if (!val) return -EINVAL;
-       
+       if (!val)
+               return -EINVAL;
+
        value = simple_strtol(val, &endp, 10);
-       if (endp == val) /* No match */
+       if (endp == val)        /* No match */
                return -EINVAL;
-       omnibook_ectype = 1 << ( value - 1);
+       omnibook_ectype = 1 << (value - 1);
        return 0;
 }
 
 static int get_ectype_param(char *buffer, struct kernel_param *kp)
 {
-       return sprintf(buffer,"%i", ffs(omnibook_ectype));
+       return sprintf(buffer, "%i", ffs(omnibook_ectype));
 }
 
 static int __init omnibook_module_init(void)
@@ -456,11 +442,10 @@ static int __init omnibook_module_init(void)
        int retval;
 
        printk(O_INFO "Driver version %s.\n", OMNIBOOK_MODULE_VERSION);
-           
+
        if (omnibook_ectype != NONE)
-               printk(O_WARN
-                      "Forced load with EC type %i.\n", ffs(omnibook_ectype));
-       else if ( dmi_check_system(omnibook_ids) ) 
+               printk(O_WARN "Forced load with EC type %i.\n", ffs(omnibook_ectype));
+       else if (dmi_check_system(omnibook_ids))
                printk(O_INFO "%s detected.\n", laptop_model);
        else
                printk(O_INFO "Unknown model.\n");
@@ -478,33 +463,33 @@ static int __init omnibook_module_init(void)
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
 
        retval = platform_driver_register(&omnibook_driver);
-       if (retval < 0) return retval;
+       if (retval < 0)
+               return retval;
 
        omnibook_device = platform_device_alloc(OMNIBOOK_MODULE_NAME, -1);
        if (!omnibook_device) {
                platform_driver_unregister(&omnibook_driver);
                return -ENOMEM;
        }
-       
+
        retval = platform_device_add(omnibook_device);
        if (retval) {
                platform_device_put(omnibook_device);
                platform_driver_unregister(&omnibook_driver);
                return retval;
        }
-
-#else /* 2.6.15 */
+#else                          /* 2.6.15 */
 
        retval = driver_register(&omnibook_driver);
-       if (retval < 0) return retval;
-        
-        retval = platform_device_register(&omnibook_device);
-        
-        if (retval) {
-               driver_unregister(&omnibook_driver);    
+       if (retval < 0)
                return retval;
-       }
 
+       retval = platform_device_register(&omnibook_device);
+
+       if (retval) {
+               driver_unregister(&omnibook_driver);
+               return retval;
+       }
 #endif
        return 0;
 }
@@ -533,12 +518,12 @@ module_init(omnibook_module_init);
 module_exit(omnibook_module_cleanup);
 
 MODULE_AUTHOR("Soós Péter, Mathieu Bérard");
-MODULE_DESCRIPTION("Kernel interface for HP OmniBook, HP Pavilion, Toshiba Satellite, Acer Aspire and Compal ACL00 laptops");
+MODULE_DESCRIPTION
+    ("Kernel interface for HP OmniBook, HP Pavilion, Toshiba Satellite, Acer Aspire and Compal ACL00 laptops");
 MODULE_LICENSE("GPL");
 module_param_call(ectype, set_ectype_param, get_ectype_param, NULL, S_IRUGO);
 module_param_named(userset, omnibook_userset, int, S_IRUGO);
 MODULE_PARM_DESC(ectype, "Type of embedded controller firmware");
 MODULE_PARM_DESC(userset, "Use 0 to disable, 1 to enable users to set parameters");
 
-
 /* End of file */
diff --git a/lcd.c b/lcd.c
index 3a06a0b2b9d9d449744475a5a705572adcb2a4fc..f138e3bea1f63d4b1bfd0d93b79a232dd4486118 100644 (file)
--- a/lcd.c
+++ b/lcd.c
@@ -48,12 +48,12 @@ static int omnibook_get_backlight(struct backlight_device *bd)
        int retval = 0;
        struct omnibook_operation *io_op;
        u8 brgt;
-       
+
        io_op = class_get_devdata(&bd->class_dev);
        retval = io_op->backend->byte_read(io_op, &brgt);
        if (!retval)
                retval = brgt;
-       
+
        return retval;
 }
 
@@ -67,21 +67,21 @@ static int omnibook_set_backlight(struct backlight_device *bd)
 }
 #endif
 
-static int omnibook_brightness_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_brightness_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
        u8 brgt;
 
        io_op->backend->byte_read(io_op, &brgt);
 
-       len += sprintf(buffer + len, "LCD brightness: %2d (max value: %d)\n",
-                       brgt,
-                       omnibook_max_brightness);
+       len +=
+           sprintf(buffer + len, "LCD brightness: %2d (max value: %d)\n", brgt,
+                   omnibook_max_brightness);
 
        return len;
 }
 
-static int omnibook_brightness_write(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_brightness_write(char *buffer, struct omnibook_operation *io_op)
 {
        int brgt = 0;
        char *endp;
@@ -112,18 +112,21 @@ static int __init omnibook_brightness_init(struct omnibook_operation *io_op)
         * TSM40
         * TSA105
         */
-       if (omnibook_ectype & (TSM30X|TSM40|TSA105) )
+       if (omnibook_ectype & (TSM30X | TSM40 | TSA105))
                omnibook_max_brightness = 7;
        else {
                omnibook_max_brightness = 10;
-               printk(O_WARN "Assuming that LCD brightness is between 0 and %i,\n", omnibook_max_brightness);
-               printk(O_WARN "please contact http://sourceforge.net/projects/omnibook to confirm.\n");
+               printk(O_WARN "Assuming that LCD brightness is between 0 and %i,\n",
+                      omnibook_max_brightness);
+               printk(O_WARN
+                      "please contact http://sourceforge.net/projects/omnibook to confirm.\n");
        }
 
 #ifdef CONFIG_OMNIBOOK_BACKLIGHT
+       io_op->backend->byte_read(io_op, (u8*) &omnibookbl_data.brightness);
        omnibookbl_data.max_brightness = omnibook_max_brightness;
-           omnibook_backlight_device =
-           backlight_device_register(OMNIBOOK_MODULE_NAME, (void *) io_op, &omnibookbl_data);
+       omnibook_backlight_device =
+           backlight_device_register(OMNIBOOK_MODULE_NAME, (void *)io_op, &omnibookbl_data);
        if (IS_ERR(omnibook_backlight_device)) {
                printk(O_ERR "Unable to register as backlight device.\n");
                return -ENODEV;
@@ -140,24 +143,24 @@ static void __exit omnibook_brightness_cleanup(struct omnibook_operation *io_op)
 }
 
 static struct omnibook_tbl lcd_table[] __initdata = {
-       { TSM30X,               {CDI,TSM70_LCD_READ,TSM70_LCD_WRITE,0,0,0}},
-       { TSM40,                {SMI,SMI_GET_LCD_BRIGHTNESS,SMI_SET_LCD_BRIGHTNESS,0,0,0}},
-       { XE3GF|TSP10|TSM30X,   SIMPLE_BYTE(EC,XE3GF_BRTS,XE3GF_BRTS_MASK)},
-       { XE3GC,                SIMPLE_BYTE(EC,XE3GC_BTVL,XE3GC_BTVL_MASK)},
-       { AMILOD,               SIMPLE_BYTE(EC,AMILOD_CBRG,XE3GC_BTVL_MASK)},
-       { TSA105,               SIMPLE_BYTE(EC,A105_BNDT,A105_BNDT_MASK)},
-       { 0,}
+       {TSM30X, {CDI, TSM70_LCD_READ, TSM70_LCD_WRITE, 0, 0, 0}},
+       {TSM40, {SMI, SMI_GET_LCD_BRIGHTNESS, SMI_SET_LCD_BRIGHTNESS, 0, 0, 0}},
+       {XE3GF | TSP10 | TSM30X, SIMPLE_BYTE(EC, XE3GF_BRTS, XE3GF_BRTS_MASK)},
+       {XE3GC, SIMPLE_BYTE(EC, XE3GC_BTVL, XE3GC_BTVL_MASK)},
+       {AMILOD, SIMPLE_BYTE(EC, AMILOD_CBRG, XE3GC_BTVL_MASK)},
+       {TSA105, SIMPLE_BYTE(EC, A105_BNDT, A105_BNDT_MASK)},
+       {0,}
 };
 
 static struct omnibook_feature __declared_feature lcd_driver = {
-        .name = "lcd",
-        .enabled = 1,
-        .read = omnibook_brightness_read,
-        .write = omnibook_brightness_write,
-        .init = omnibook_brightness_init,
-        .exit = omnibook_brightness_cleanup,
-        .ectypes = XE3GF|XE3GC|AMILOD|TSP10|TSM30X|TSM40|TSA105,
-        .tbl = lcd_table,
+       .name = "lcd",
+       .enabled = 1,
+       .read = omnibook_brightness_read,
+       .write = omnibook_brightness_write,
+       .init = omnibook_brightness_init,
+       .exit = omnibook_brightness_cleanup,
+       .ectypes = XE3GF | XE3GC | AMILOD | TSP10 | TSM30X | TSM40 | TSA105,
+       .tbl = lcd_table,
 };
 
 module_param_named(lcd, lcd_driver.enabled, int, S_IRUGO);
index 620c4bb1c0872f5ef1b2bdd147b4bd1006a96dcd..78b1b96f8c3854cdfbc0328d454971f620ce67b6 100644 (file)
--- a/muteled.c
+++ b/muteled.c
@@ -33,26 +33,26 @@ static int omnibook_muteled_set(struct omnibook_operation *io_op, int status)
 /*
  * Hardware query is unsupported, reading is unreliable.
  */
-static int omnibook_muteled_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_muteled_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
 
-       len += sprintf(buffer+len, "Last mute LED action was an %s command.\n", 
-                       (omnibook_muteled_enabled) ? "on" : "off");
+       len +=
+           sprintf(buffer + len, "Last mute LED action was an %s command.\n",
+                   (omnibook_muteled_enabled) ? "on" : "off");
 
        return len;
 }
 
-static int omnibook_muteled_write(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_muteled_write(char *buffer, struct omnibook_operation *io_op)
 {
-       int cmd;        
+       int cmd;
 
-       if ( *buffer == '0' || *buffer == '1') {
+       if (*buffer == '0' || *buffer == '1') {
                cmd = *buffer - '0';
-               if(!omnibook_muteled_set(io_op, cmd)) {
+               if (!omnibook_muteled_set(io_op, cmd)) {
                        omnibook_muteled_enabled = cmd;
-                       printk(O_INFO "Switching mute LED to %s state.\n", 
-                               cmd ? "on" : "off");
+                       printk(O_INFO "Switching mute LED to %s state.\n", cmd ? "on" : "off");
                }
        } else {
                return -EINVAL;
@@ -61,25 +61,24 @@ static int omnibook_muteled_write(char *buffer,struct omnibook_operation *io_op)
 }
 
 static int omnibook_muteled_resume(struct omnibook_operation *io_op)
-{      
-       return omnibook_muteled_set(io_op,omnibook_muteled_enabled);            
+{
+       return omnibook_muteled_set(io_op, omnibook_muteled_enabled);
 }
 
 static struct omnibook_tbl muteled_table[] __initdata = {
-       { XE4500, COMMAND(KBC,OMNIBOOK_KBC_CMD_MUTELED_ON,OMNIBOOK_KBC_CMD_MUTELED_OFF)},
-       { 0,}
+       {XE4500, COMMAND(KBC, OMNIBOOK_KBC_CMD_MUTELED_ON, OMNIBOOK_KBC_CMD_MUTELED_OFF)},
+       {0,}
 };
 
 static struct omnibook_feature __declared_feature muteled_driver = {
-        .name = "muteled",
-        .enabled = 1,
-        .read = omnibook_muteled_read,
-        .write = omnibook_muteled_write,
-        .resume = omnibook_muteled_resume,
-        .ectypes = XE4500,
-        .tbl = muteled_table,
+       .name = "muteled",
+       .enabled = 1,
+       .read = omnibook_muteled_read,
+       .write = omnibook_muteled_write,
+       .resume = omnibook_muteled_resume,
+       .ectypes = XE4500,
+       .tbl = muteled_table,
 };
 
 module_param_named(muteled, muteled_driver.enabled, int, S_IRUGO);
 MODULE_PARM_DESC(muteled, "Use 0 to disable, 1 to enable 'Audo Mute' LED control");
-
diff --git a/nbsmi.c b/nbsmi.c
index cc08635a055624832e9eefa97be822e373b7f271..2f4a074a3a81693cb360fbcdf2736f239bf31618 100644 (file)
--- a/nbsmi.c
+++ b/nbsmi.c
@@ -19,7 +19,7 @@
  * -Frederico Munoz with the 'tecra_acpi' project
  * Thanks to them
  */
+
 #include "omnibook.h"
 
 #include <linux/preempt.h>
@@ -40,7 +40,7 @@
 
 #define BUFFER_SIZE    0x20
 #define INTEL_OFFSET   0x60
-#define        INTEL_SMI_PORT  0xb2 /* APM_CNT port in INTEL ICH specs */
+#define        INTEL_SMI_PORT  0xb2    /* APM_CNT port in INTEL ICH specs */
 #define ATI_OFFSET     0xef
 #define        ATI_SMI_PORT    0xb0
 
@@ -64,9 +64,9 @@ static DEFINE_SPINLOCK(smi_spinlock);
  * Private data of this backend
  */
 static struct kref *refcount;
-static struct pci_dev *lpc_bridge;     /* Southbridge chip ISA bridge/LPC interface PCI device */
+static struct pci_dev *lpc_bridge;     /* Southbridge chip ISA bridge/LPC interface PCI device */
 static u8 start_offset;
-static int already_failed = 0;         /* Backend init already failed at leat once */
+static int already_failed = 0; /* Backend init already failed at leat once */
 
 /*
  * Possible list of supported southbridges
@@ -77,200 +77,233 @@ static int already_failed = 0;            /* Backend init already failed at leat once */
 extern const struct pci_device_id lpc_bridge_table[];
 
 /*
- * Since we are going to trigger an SMI, all registers may be mangled in the
- * process. So we save and restore all registers and eflags in the stack.
+ * Since we are going to trigger an SMI, all registers (I assume this does not
+ * include esp and maybe ebp) and eflags may be mangled in the
+ * process. 
+ * So we save and restore all registers and eflags using the stack.
  * We also disable preemtion and IRQs upon SMI call.
+ * FIXME: To be sorted out:
+ * -> Can we reliably use spin_lock_irqsave/restore and remove the pushf/popf ?
+ * -> Can we remove the pusha/popa and add eax ebx ecx edx esi edi to clobber list ?
  */
 
-static inline void ati_do_smi_call(int *retval, u16 function)
+static inline u32 ati_do_smi_call( u16 function)
 {
-       // Call to SMI
-       spin_lock_irq(&smi_spinlock);
-       __asm__ __volatile__("pushf;    \
-                             pusha;    \
-                             out %w0,%w1;      \
-                             popa;     \
-                             popf"
-                            :
-                            : "a"(function), "Nd"(ATI_SMI_PORT)
-                            : "esp");
-       /*      outw( function, ATI_SMI_PORT ); Call to SMI */
-       *retval = inw(ATI_SMI_PORT + 1);
-       spin_unlock_irq(&smi_spinlock); 
+       u32 flags;
+       u32 retval = 0;
+       spin_lock_irqsave(&smi_spinlock,flags);
+       
+/*
+ * eflags, eax, ebx, ecx, edx, esi and edi are clobbered upon writing to SMI_PORT
+ * thus the clobber list.
+ *
+ * Equivalent pseudocode:
+ *
+ * eax = function; [non null]
+ * outw(eax, ATI_SMI_PORT); <- This Trigger an SMI
+ * if( eax == 0 ) [success if eax has been cleared]
+ *     goto out;
+ * if( inb(ATI_SMI_PORT + 1) == 0) [if not in eax, success maybe be stored here]
+ *     goto out;
+ * retval = -EIO; [too bad]
+ * out:
+ */
+
+       __asm__ __volatile__("movw  %1, %%ax;   \
+                             outw  %%ax, %2;   \
+                             orw %%ax, %%ax;   \
+                             jz 1f;            \
+                             inw %3, %%ax;     \
+                             orw %%ax, %%ax;   \
+                             jz 1f;            \
+                             movl %4, %0;      \
+                             1:;"
+                            : "=m" (retval)
+                            : "g"(function), "N"(ATI_SMI_PORT), "N"(ATI_SMI_PORT+1), "i"(-EIO)
+                            : "memory", "eax", "ebx", "ecx", "edx", "esi", "edi", "cc");
+
+       spin_unlock_irqrestore(&smi_spinlock,flags);
+       return retval;
 }
 
-static inline void intel_do_smi_call(int *retval, u16 function, u32 sci_en)
+static inline u32 intel_do_smi_call(u16 function)
 {
-       u32 state;
-       
-       spin_lock_irq(&smi_spinlock);
+       u32 state, sci_en, flags;
+       u32 retval = 0;
+       spin_lock_irqsave(&smi_spinlock,flags);
+
+/* 
+ * We get the PMBASE offset ( bits 15:7 at 0x40 offset of PCI config space )
+ * And we access offset 2c (GPE0_EN), save the state, disable all SCI
+ * and restore the state after the SMI call
+ */                    
+       pci_read_config_dword(lpc_bridge, INTEL_PMBASE, &sci_en);
+       sci_en = sci_en & 0xff80; /* Keep bits 15:7 */
+       sci_en += INTEL_GPE0_EN;  /* GPEO_EN offset */
        state = inl(sci_en);
-       outl( 0, sci_en );
 
-       /* Success/Failure is saved in eax so don't save is on stack */
-       
-       __asm__ __volatile__("pushf;    \
-                             push %%ecx;push %%edx;push %%ebx;push %%esi;push %%edi; push %%ebp;       \
-                             out %w0,%w1;      \
-                             pop %%ebp; pop %%edi; pop %%esi; pop %%ebx; pop %%edx; pop %%ecx;         \
-                             popf;     \
-                             movl %%eax, (%2)"
-                            :
-                            : "a"(function), "Nd"(INTEL_SMI_PORT), "b"(retval)
-                            : "ecx", "edx", "esi", "edi", "esp");
-       
+/*
+ * eflags, eax, ebx, ecx, edx, esi and edi are clobbered upon writing to SMI_PORT
+ * thus the clobber list.
+ *
+ * Equivalent pseudocode:
+ *
+ * eax = function; [non null]
+ * outw(eax, INTEL_SMI_PORT); <- This Trigger an SMI
+ * if( eax == 0 ) [success if eax has been cleared]
+ *     goto out; 
+ * retval = -EIO; [too bad]
+ * out:
+ */
+       __asm__ __volatile__("movw %1, %%ax;    \
+                             outw %%ax, %2;    \
+                             orw %%ax, %%ax;   \
+                             jz 1f;            \
+                             movl %3, %0;      \
+                             1:;"
+                            : "=m" (retval)
+                            : "g"(function), "N"(INTEL_SMI_PORT), "i"(-EIO)
+                            : "memory", "eax", "ebx", "ecx", "edx", "esi", "edi", "cc");
+
        outl( state, sci_en );
-       spin_unlock_irq(&smi_spinlock); 
+       spin_unlock_irqrestore(&smi_spinlock,flags);
+       return retval;
 }
 
-
-static int nbsmi_smi_command(u16 function,const u8 *inputbuffer, u8 *outputbuffer)
+static int nbsmi_smi_command(u16 function, const u8 * inputbuffer, u8 * outputbuffer)
 {
-       u32 retval;
-       u32 sci_en;
        int count;
-       
-       for(count = 0; count < BUFFER_SIZE; count++) {
-               outb( count + start_offset, RTC_PORT(2) );
-               outb( *(inputbuffer + count), RTC_PORT(3) );
-       }
+       u32 retval = 0;
 
+       for (count = 0; count < BUFFER_SIZE; count++) {
+               outb(count + start_offset, RTC_PORT(2));
+               outb(*(inputbuffer + count), RTC_PORT(3));
+       }
 
 /* 
  * We have to write 0xe4XX to smi_port
  * where XX is the SMI function code
- */    
-       function = ( function & 0xff ) << 8;
+ */
+       function = (function & 0xff) << 8;
        function |= 0xe4;
-       
 
        switch (lpc_bridge->vendor) {
-               case PCI_VENDOR_ID_INTEL:
-/* 
- * We get the PMBASE offset ( bits 15:7 at 0x40 offset of PCI config space )
- * And we access offset 2c (GPE0_EN), save the state, disable all SCI
- * and restore the state in intel_do_smi_call function
- */
-                       pci_read_config_dword(lpc_bridge, INTEL_PMBASE, &sci_en);
-                       sci_en = sci_en & 0xff80; /* Keep bits 15:7 */
-                       sci_en += INTEL_GPE0_EN;  /* GPEO_EN offset */
-                       intel_do_smi_call(&retval,function,sci_en);
-                       break;
-               case PCI_VENDOR_ID_ATI:
-                       ati_do_smi_call(&retval,function);
-                       break;
-               default:
-                       BUG();
+       case PCI_VENDOR_ID_INTEL:
+               retval = intel_do_smi_call(function);
+               break;
+       case PCI_VENDOR_ID_ATI:
+               retval = ati_do_smi_call(function);
+               break;
+       default:
+               BUG();
        }
 
-       if(retval)
+       if (retval)
                printk(O_ERR "smi_command failed with error %u.\n", retval);
 
-       for(count = 0; count < BUFFER_SIZE; count++) {
-               outb( count + start_offset, RTC_PORT(2) );
-               *(outputbuffer + count) = inb( RTC_PORT(3) );
+       for (count = 0; count < BUFFER_SIZE; count++) {
+               outb(count + start_offset, RTC_PORT(2));
+               *(outputbuffer + count) = inb(RTC_PORT(3));
        }
-       
+
        return retval;
 }
 
-
-static int nbsmi_smi_read_command(const struct omnibook_operation *io_op, u8 *data)
+static int nbsmi_smi_read_command(const struct omnibook_operation *io_op, u8 * data)
 {
        int retval;
        u8 *inputbuffer;
        u8 *outputbuffer;
-       
-       if(!lpc_bridge)
+
+       if (!lpc_bridge)
                return -ENODEV;
 
-       if(mutex_lock_interruptible(&smi_lock))
+       if (mutex_lock_interruptible(&smi_lock))
                return -ERESTARTSYS;
-       
-       inputbuffer = kcalloc(BUFFER_SIZE,sizeof(u8),GFP_KERNEL);
-       if(!inputbuffer) {
+
+       inputbuffer = kcalloc(BUFFER_SIZE, sizeof(u8), GFP_KERNEL);
+       if (!inputbuffer) {
                retval = -ENOMEM;
                goto error1;
        }
-       
-       outputbuffer = kcalloc(BUFFER_SIZE,sizeof(u8),GFP_KERNEL);
-       if(!outputbuffer) {
+
+       outputbuffer = kcalloc(BUFFER_SIZE, sizeof(u8), GFP_KERNEL);
+       if (!outputbuffer) {
                retval = -ENOMEM;
                goto error2;
        }
-       
-       retval = nbsmi_smi_command( (u16) io_op->read_addr, inputbuffer, outputbuffer);
-       if(retval)
+
+       retval = nbsmi_smi_command((u16) io_op->read_addr, inputbuffer, outputbuffer);
+       if (retval)
                goto out;
-       
+
        *data = outputbuffer[0];
 
-       if(io_op->read_mask)
+       if (io_op->read_mask)
                *data &= io_op->read_mask;
 
-out:
+      out:
        kfree(outputbuffer);
-error2:
+      error2:
        kfree(inputbuffer);
-error1:
+      error1:
        mutex_unlock(&smi_lock);
        return retval;
 }
 
-static int nbsmi_smi_write_command(const struct omnibook_operation *io_op, u8 data) 
+static int nbsmi_smi_write_command(const struct omnibook_operation *io_op, u8 data)
 {
        int retval;
        u8 *inputbuffer;
        u8 *outputbuffer;
-       
-       if(!lpc_bridge)
+
+       if (!lpc_bridge)
                return -ENODEV;
 
-       if(mutex_lock_interruptible(&smi_lock))
+       if (mutex_lock_interruptible(&smi_lock))
                return -ERESTARTSYS;
-       
-       inputbuffer = kcalloc(BUFFER_SIZE,sizeof(u8),GFP_KERNEL);
-       if(!inputbuffer) {
+
+       inputbuffer = kcalloc(BUFFER_SIZE, sizeof(u8), GFP_KERNEL);
+       if (!inputbuffer) {
                retval = -ENOMEM;
                goto error1;
        }
-       
-       outputbuffer = kcalloc(BUFFER_SIZE,sizeof(u8),GFP_KERNEL);
-       if(!outputbuffer) {
+
+       outputbuffer = kcalloc(BUFFER_SIZE, sizeof(u8), GFP_KERNEL);
+       if (!outputbuffer) {
                retval = -ENOMEM;
                goto error2;
        }
-       
+
        inputbuffer[0] = data;
 
-       retval = nbsmi_smi_command( (u16) io_op->write_addr, inputbuffer, outputbuffer);
-       
+       retval = nbsmi_smi_command((u16) io_op->write_addr, inputbuffer, outputbuffer);
+
        kfree(outputbuffer);
-error2:
+      error2:
        kfree(inputbuffer);
-error1:
+      error1:
        mutex_unlock(&smi_lock);
        return retval;
 }
 
-
 /*
  * Read/Write to INDEX/DATA interface at port 0x300 (SMSC Mailbox registers)
  * Used by Hotkeys feature under already taken mutex.
  */
-static void nbsmi_ec_read_command(u16 index, u16 *data)
+static void nbsmi_ec_read_command(u16 index, u16 * data)
 {
        spin_lock_irq(&smi_spinlock);
-       outw(index,EC_INDEX_PORT);
-       *data = inw(EC_DATA_PORT);      
+       outw(index, EC_INDEX_PORT);
+       *data = inw(EC_DATA_PORT);
        spin_unlock_irq(&smi_spinlock);
 }
 
 static void nbsmi_ec_write_command(u16 index, u16 data)
 {
        spin_lock_irq(&smi_spinlock);
-       outw(index,EC_INDEX_PORT);
-       outw(data,EC_DATA_PORT);
+       outw(index, EC_INDEX_PORT);
+       outw(data, EC_DATA_PORT);
        spin_unlock_irq(&smi_spinlock);
 }
 
@@ -287,22 +320,22 @@ static int omnibook_nbsmi_init(const struct omnibook_operation *io_op)
        u16 ec_data;
        u32 smi_port = 0;
 
-/* ectypes other than TSM40 have no business with this backend */      
-       if(!(omnibook_ectype & TSM40))
+/* ectypes other than TSM40 have no business with this backend */
+       if (!(omnibook_ectype & TSM40))
                return -ENODEV;
 
-       if(already_failed) {
+       if (already_failed) {
                dprintk("NbSmi backend init already failed, skipping.\n");
                return -ENODEV;
        }
 
-       if(!refcount) {
+       if (!refcount) {
                /* Fist use of the backend */
                mutex_lock(&smi_lock);
-               dprintk("Try to init NbSmi\n"); 
-               refcount = kmalloc(sizeof(struct kref),GFP_KERNEL);
-               if(!refcount) {
-                       retval= -ENOMEM;
+               dprintk("Try to init NbSmi\n");
+               refcount = kmalloc(sizeof(struct kref), GFP_KERNEL);
+               if (!refcount) {
+                       retval = -ENOMEM;
                        goto out;
                }
 
@@ -310,19 +343,21 @@ static int omnibook_nbsmi_init(const struct omnibook_operation *io_op)
 
                /* PCI probing: find the LPC Super I/O bridge PCI device */
                for (i = 0; !lpc_bridge && lpc_bridge_table[i].vendor; ++i)
-                       lpc_bridge = pci_get_device(lpc_bridge_table[i].vendor, lpc_bridge_table[i].device, NULL);
+                       lpc_bridge =
+                           pci_get_device(lpc_bridge_table[i].vendor, lpc_bridge_table[i].device,
+                                          NULL);
 
                if (!lpc_bridge) {
                        printk(O_ERR "Fail to find a supported LPC I/O bridge, please report\n");
                        retval = -ENODEV;
                        goto error1;
                }
-               
-               if((retval = pci_enable_device(lpc_bridge))) {
+
+               if ((retval = pci_enable_device(lpc_bridge))) {
                        printk(O_ERR "Unable to enable PCI device.\n");
                        goto error2;
                }
-               
+
                switch (lpc_bridge->vendor) {
                case PCI_VENDOR_ID_INTEL:
                        start_offset = INTEL_OFFSET;
@@ -335,34 +370,32 @@ static int omnibook_nbsmi_init(const struct omnibook_operation *io_op)
                default:
                        BUG();
                }
-               
-               if(!request_region(smi_port, 2 , OMNIBOOK_MODULE_NAME)) {
+
+               if (!request_region(smi_port, 2, OMNIBOOK_MODULE_NAME)) {
                        printk(O_ERR "Request SMI I/O region error\n");
                        retval = -ENODEV;
                        goto error2;
                }
 
-               if(!request_region(EC_INDEX_PORT, 2 , OMNIBOOK_MODULE_NAME)) {
+               if (!request_region(EC_INDEX_PORT, 2, OMNIBOOK_MODULE_NAME)) {
                        printk(O_ERR "Request EC I/O region error\n");
                        retval = -ENODEV;
                        goto error3;
                }
 
-
                /*
-                * Try some heuristic tests to avoid enabling this interface on unsuported laptops:
-                * See what a port 300h read index 8f gives. Guess there is nothing if read 0xffff
-                */
+                * Try some heuristic tests to avoid enabling this interface on unsuported laptops:
+                * See what a port 300h read index 8f gives. Guess there is nothing if read 0xffff
+                */
 
                nbsmi_ec_read_command(SMI_FN_PRESSED, &ec_data);
-               dprintk("NbSmi test probe read: %x\n",ec_data);
-               if(ec_data == 0xffff) {
+               dprintk("NbSmi test probe read: %x\n", ec_data);
+               if (ec_data == 0xffff) {
                        printk(O_ERR "Probing at SMSC Mailbox registers failed, disabling NbSmi\n");
                        retval = -ENODEV;
                        goto error4;
                }
-       
-       
+
                dprintk("NbSmi init ok\n");
                goto out;
        } else {
@@ -370,18 +403,18 @@ static int omnibook_nbsmi_init(const struct omnibook_operation *io_op)
                kref_get(refcount);
                return 0;
        }
-error4:
-       release_region(EC_INDEX_PORT,2);
-error3:
-       release_region(smi_port,2);
-error2:
+      error4:
+       release_region(EC_INDEX_PORT, 2);
+      error3:
+       release_region(smi_port, 2);
+      error2:
        pci_dev_put(lpc_bridge);
        lpc_bridge = NULL;
-error1:
+      error1:
        kfree(refcount);
        refcount = NULL;
        already_failed = 1;
-out:
+      out:
        mutex_unlock(&smi_lock);
        return retval;
 }
@@ -392,7 +425,7 @@ static void nbsmi_free(struct kref *ref)
 
        mutex_lock(&smi_lock);
        dprintk("NbSmi not used anymore: disposing\n");
-       
+
        switch (lpc_bridge->vendor) {
        case PCI_VENDOR_ID_INTEL:
                smi_port = INTEL_SMI_PORT;
@@ -403,10 +436,10 @@ static void nbsmi_free(struct kref *ref)
        default:
                BUG();
        }
-       
+
        pci_dev_put(lpc_bridge);
-       release_region(smi_port,2);
-       release_region(EC_INDEX_PORT,2);
+       release_region(smi_port, 2);
+       release_region(EC_INDEX_PORT, 2);
        kfree(refcount);
        lpc_bridge = NULL;
        refcount = NULL;
@@ -418,7 +451,7 @@ static void omnibook_nbsmi_exit(const struct omnibook_operation *io_op)
 /* ectypes other than TSM40 have no business with this backend */
        BUG_ON(!(omnibook_ectype & TSM40));
        dprintk("Trying to dispose NbSmi\n");
-       kref_put(refcount,nbsmi_free);
+       kref_put(refcount, nbsmi_free);
 }
 
 static int omnibook_nbsmi_get_wireless(const struct omnibook_operation *io_op, unsigned int *state)
@@ -426,29 +459,30 @@ static int omnibook_nbsmi_get_wireless(const struct omnibook_operation *io_op, u
        int retval = 0;
        struct omnibook_operation aerial_op;
        u8 data;
-       
+
        aerial_op.read_addr = SMI_GET_KILL_SWITCH;
+       aerial_op.read_mask = 0;
 
-       if((retval = nbsmi_smi_read_command(&aerial_op, &data)))
+       if ((retval = nbsmi_smi_read_command(&aerial_op, &data)))
                goto out;
-       
-       *state = data ? KILLSWITCH : 0; /* Make it 1 or 0 */
+
+       *state = data ? KILLSWITCH : 0;
 
        aerial_op.read_addr = SMI_GET_AERIAL;
+       aerial_op.read_mask = 0;
 
-       if((retval = nbsmi_smi_read_command(&aerial_op, &data)))
+       if ((retval = nbsmi_smi_read_command(&aerial_op, &data)))
                goto out;
 
-       *state |= ( data & WLEX_MASK ) ? WIFI_EX : 0;
-       *state |= ( data & WLAT_MASK ) ? WIFI_STA : 0;
-       *state |= ( data & BTEX_MASK ) ? BT_EX : 0;
-       *state |= ( data & BTAT_MASK ) ? BT_STA : 0;
+       *state |= (data & WLEX_MASK) ? WIFI_EX : 0;
+       *state |= (data & WLAT_MASK) ? WIFI_STA : 0;
+       *state |= (data & BTEX_MASK) ? BT_EX : 0;
+       *state |= (data & BTAT_MASK) ? BT_STA : 0;
 
-out:
+      out:
        return retval;
 }
 
-
 static int omnibook_nbsmi_set_wireless(const struct omnibook_operation *io_op, unsigned int state)
 {
        int retval = 0;
@@ -456,12 +490,12 @@ static int omnibook_nbsmi_set_wireless(const struct omnibook_operation *io_op, u
        struct omnibook_operation aerial_op;
 
        aerial_op.write_addr = SMI_SET_AERIAL;
-       
+
        data |= state & BT_STA;
-       data |= ( state & WIFI_STA ) << 0x1 ;
+       data |= (state & WIFI_STA) << 0x1;
 
        retval = nbsmi_smi_write_command(&aerial_op, data);
-       
+
        return retval;
 }
 
@@ -473,19 +507,20 @@ static int omnibook_nbmsi_hotkeys_get(const struct omnibook_operation *io_op, un
        int retval;
        u8 data = 0;
        struct omnibook_operation hotkeys_op;
-       
+
        hotkeys_op.read_addr = SMI_GET_FN_INTERFACE;
+       hotkeys_op.read_mask = 0;
 
        retval = nbsmi_smi_read_command(&hotkeys_op, &data);
-       if(retval < 0)
-               return retval;  
+       if (retval < 0)
+               return retval;
 
-       *state = ( data & SMI_FN_KEYS_MASK ) ? HKEY_FN : 0;
-       *state |= ( data & SMI_STICK_KEYS_MASK ) ? HKEY_STICK : 0;
-       *state |= ( data & SMI_FN_TWICE_LOCK_MASK ) ? HKEY_TWICE_LOCK : 0;
-       *state |= ( data & SMI_FN_DOCK_MASK ) ? HKEY_DOCK : 0;
+       *state = (data & SMI_FN_KEYS_MASK) ? HKEY_FN : 0;
+       *state |= (data & SMI_STICK_KEYS_MASK) ? HKEY_STICK : 0;
+       *state |= (data & SMI_FN_TWICE_LOCK_MASK) ? HKEY_TWICE_LOCK : 0;
+       *state |= (data & SMI_FN_DOCK_MASK) ? HKEY_DOCK : 0;
 
-       return HKEY_FN|HKEY_STICK|HKEY_TWICE_LOCK|HKEY_DOCK;
+       return HKEY_FN | HKEY_STICK | HKEY_TWICE_LOCK | HKEY_DOCK;
 }
 
 static int omnibook_nbmsi_hotkeys_set(const struct omnibook_operation *io_op, unsigned int state)
@@ -495,82 +530,74 @@ static int omnibook_nbmsi_hotkeys_set(const struct omnibook_operation *io_op, un
        struct omnibook_operation hotkeys_op;
 
        hotkeys_op.write_addr = SMI_SET_FN_INTERFACE;
-       data |= ( state & HKEY_FN ) ? SMI_FN_KEYS_MASK : 0;
-       data |= ( state & HKEY_STICK) ? SMI_STICK_KEYS_MASK : 0;
-       data |= ( state & HKEY_TWICE_LOCK) ? SMI_FN_TWICE_LOCK_MASK : 0;
-       data |= ( state & HKEY_DOCK) ? SMI_FN_DOCK_MASK : 0;
+       data |= (state & HKEY_FN) ? SMI_FN_KEYS_MASK : 0;
+       data |= (state & HKEY_STICK) ? SMI_STICK_KEYS_MASK : 0;
+       data |= (state & HKEY_TWICE_LOCK) ? SMI_FN_TWICE_LOCK_MASK : 0;
+       data |= (state & HKEY_DOCK) ? SMI_FN_DOCK_MASK : 0;
 
        retval = nbsmi_smi_write_command(&hotkeys_op, data);
-       if(retval < 0)
+       if (retval < 0)
                return retval;
 
        hotkeys_op.write_addr = SMI_SET_FN_F5_INTERFACE;
-       data = !!( state & HKEY_FNF5); 
+       data = !!(state & HKEY_FNF5);
 
        retval = nbsmi_smi_write_command(&hotkeys_op, data);
-       if(retval < 0)
+       if (retval < 0)
                return retval;
        else
-               return HKEY_FN|HKEY_STICK|HKEY_TWICE_LOCK|HKEY_DOCK|HKEY_FNF5;
+               return HKEY_FN | HKEY_STICK | HKEY_TWICE_LOCK | HKEY_DOCK | HKEY_FNF5;
 }
 
 static const unsigned int nbsmi_display_mode_list[] = {
        DISPLAY_LCD_ON,
-       DISPLAY_LCD_ON|DISPLAY_CRT_ON,
+       DISPLAY_LCD_ON | DISPLAY_CRT_ON,
        DISPLAY_CRT_ON,
-       DISPLAY_LCD_ON|DISPLAY_TVO_ON,
+       DISPLAY_LCD_ON | DISPLAY_TVO_ON,
        DISPLAY_TVO_ON,
 };
 
-static int  omnibook_nbmsi_display_get(const struct omnibook_operation *io_op, unsigned int *state)
+static int omnibook_nbmsi_display_get(const struct omnibook_operation *io_op, unsigned int *state)
 {
        int retval = 0;
        u8 data;
-       struct omnibook_operation display_op;
 
-       display_op.read_addr = SMI_GET_DISPLAY_STATE;
-
-       retval = nbsmi_smi_read_command(&display_op, &data);
-       if(retval < 0)
+       retval = nbsmi_smi_read_command(io_op, &data);
+       if (retval < 0)
                return retval;
 
-       ifdata > (ARRAY_SIZE(nbsmi_display_mode_list) - 1))
-               return -EIO;    
-       
+       if (data > (ARRAY_SIZE(nbsmi_display_mode_list) - 1))
+               return -EIO;
+
        *state = nbsmi_display_mode_list[data];
 
-       return DISPLAY_LCD_ON|DISPLAY_CRT_ON|DISPLAY_TVO_ON;
+       return DISPLAY_LCD_ON | DISPLAY_CRT_ON | DISPLAY_TVO_ON;
 }
 
 static int omnibook_nbmsi_display_set(const struct omnibook_operation *io_op, unsigned int state)
 {
-       int retval = 0;
+       int retval;
        int i;
        u8 matched = 0;
-       struct omnibook_operation display_op;
 
-       display_op.write_addr = SMI_SET_DISPLAY_STATE;
-
-       for(i = 0; i < ARRAY_SIZE(nbsmi_display_mode_list); i++) {
-               if(nbsmi_display_mode_list[i] == state) {
+       for (i = 0; i < ARRAY_SIZE(nbsmi_display_mode_list); i++) {
+               if (nbsmi_display_mode_list[i] == state) {
                        matched = i;
                        break;
-               }       
+               }
        }
-       if(!matched) {
+       if (!matched) {
                printk("Display mode %x is unsupported.\n", state);
                return -EINVAL;
        }
-       
-       retval = nbsmi_smi_write_command(&display_op, matched);
-       if(retval < 0)
+
+       retval = nbsmi_smi_write_command(io_op, matched);
+       if (retval < 0)
                return retval;
 
-       return DISPLAY_LCD_ON|DISPLAY_CRT_ON|DISPLAY_TVO_ON;
+       return DISPLAY_LCD_ON | DISPLAY_CRT_ON | DISPLAY_TVO_ON;
 }
 
-
-
 struct omnibook_backend nbsmi_backend = {
        .name = "nbsmi",
        .init = omnibook_nbsmi_init,
index 694e462c1d87497ff0c37f31f5911f0daa2165d9..61bc6c33b6e64bd5bd04b62979caffc7a9b765f7 100644 (file)
@@ -23,30 +23,31 @@ static int omnibook_temperature_read(char *buffer, struct omnibook_operation *io
        int len = 0;
        int retval;
        u8 temp;
-       
-       if((retval = io_op->backend->byte_read(io_op, &temp)))
+
+       if ((retval = io_op->backend->byte_read(io_op, &temp)))
                return retval;
 
-       len +=
-           sprintf(buffer + len, "CPU temperature:            %2d C\n", temp);
+       len += sprintf(buffer + len, "CPU temperature:            %2d C\n", temp);
 
        return len;
 }
 
 static struct omnibook_tbl temp_table[] __initdata = {
-       { XE3GF|TSP10|TSM30X,                   SIMPLE_BYTE(EC,XE3GF_CTMP,0)},
-       { XE3GC|AMILOD,                         SIMPLE_BYTE(EC,XE3GC_CTMP,0)},
-       { OB500|OB510|OB6000|OB6100|XE4500|XE2, SIMPLE_BYTE(EC,OB500_CTMP,0)},
-       { OB4150,                               SIMPLE_BYTE(EC,OB4150_TMP,0)},
-       { 0,}
+       {XE3GF | TSP10 | TSM30X, SIMPLE_BYTE(EC, XE3GF_CTMP, 0)},
+       {XE3GC | AMILOD, SIMPLE_BYTE(EC, XE3GC_CTMP, 0)},
+       {OB500 | OB510 | OB6000 | OB6100 | XE4500 | XE2, SIMPLE_BYTE(EC, OB500_CTMP, 0)},
+       {OB4150, SIMPLE_BYTE(EC, OB4150_TMP, 0)},
+       {0,}
 };
-       
+
 static struct omnibook_feature __declared_feature temperature_driver = {
-        .name = "temperature",
-        .enabled = 1,
-        .read = omnibook_temperature_read,
-        .ectypes = XE3GF|XE3GC|OB500|OB510|OB6000|OB6100|XE4500|OB4150|XE2|AMILOD|TSP10|TSM30X,
-        .tbl = temp_table,
+       .name = "temperature",
+       .enabled = 1,
+       .read = omnibook_temperature_read,
+       .ectypes =
+           XE3GF | XE3GC | OB500 | OB510 | OB6000 | OB6100 | XE4500 | OB4150 | XE2 | AMILOD | TSP10
+           | TSM30X,
+       .tbl = temp_table,
 };
 
 module_param_named(temperature, temperature_driver.enabled, int, S_IRUGO);
index d7193a7520f22d52da210ffbb6a8553f3ddc3d1d..93035af9c2a6df0aba4773462e4889bb52e5ff67 100644 (file)
@@ -46,7 +46,6 @@ static int omnibook_touchpad_resume(struct omnibook_operation *io_op)
 static int omnibook_touchpad_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
-       
 
        len +=
            sprintf(buffer + len, "Last touchpad action was an %s command.\n",
@@ -59,9 +58,9 @@ static int omnibook_touchpad_write(char *buffer, struct omnibook_operation *io_o
 {
        int cmd;
 
-       if ( *buffer == '0' || *buffer == '1') {
+       if (*buffer == '0' || *buffer == '1') {
                cmd = *buffer - '0';
-               if(!omnibook_touchpad_set(io_op, cmd)) {
+               if (!omnibook_touchpad_set(io_op, cmd)) {
                        omnibook_touchpad_enabled = cmd;
                        printk(O_INFO "%sabling touchpad.\n", cmd ? "En" : "Dis");
                }
@@ -76,25 +75,26 @@ static int omnibook_touchpad_write(char *buffer, struct omnibook_operation *io_o
  */
 static void __exit omnibook_touchpad_cleanup(struct omnibook_operation *io_op)
 {
-       omnibook_touchpad_set(io_op,1);
+       omnibook_touchpad_set(io_op, 1);
        printk(O_INFO "Enabling touchpad.\n");
 }
 
 static struct omnibook_tbl touchpad_table[] __initdata = {
-       { XE3GF|XE3GC|TSP10, COMMAND(KBC,OMNIBOOK_KBC_CMD_TOUCHPAD_ENABLE,OMNIBOOK_KBC_CMD_TOUCHPAD_DISABLE)},
-       { TSM30X, {CDI, 0, TSM70_FN_INDEX, 0, TSM70_TOUCHPAD_ON, TSM70_TOUCHPAD_OFF}},
-       { 0,}
+       {XE3GF | XE3GC | TSP10,
+        COMMAND(KBC, OMNIBOOK_KBC_CMD_TOUCHPAD_ENABLE, OMNIBOOK_KBC_CMD_TOUCHPAD_DISABLE)},
+       {TSM30X, {CDI, 0, TSM70_FN_INDEX, 0, TSM70_TOUCHPAD_ON, TSM70_TOUCHPAD_OFF}},
+       {0,}
 };
 
 static struct omnibook_feature __declared_feature touchpad_driver = {
-        .name = "touchpad",
-        .enabled = 1,
-        .read = omnibook_touchpad_read,
-        .write = omnibook_touchpad_write,
-        .exit = omnibook_touchpad_cleanup,
-        .resume = omnibook_touchpad_resume,
-        .ectypes = XE3GF|XE3GC|TSP10|TSM30X,
-        .tbl = touchpad_table,
+       .name = "touchpad",
+       .enabled = 1,
+       .read = omnibook_touchpad_read,
+       .write = omnibook_touchpad_write,
+       .exit = omnibook_touchpad_cleanup,
+       .resume = omnibook_touchpad_resume,
+       .ectypes = XE3GF | XE3GC | TSP10 | TSM30X,
+       .tbl = touchpad_table,
 };
 
 module_param_named(touchpad, touchpad_driver.enabled, int, S_IRUGO);
index bc9782a65710ee0c8b5b6bfbc76951597c4a3528..045cd1da1344b0c0cb3fadab508626e9914a5a4e 100644 (file)
 #include "omnibook.h"
 #include "ec.h"
 
-static int omnibook_wifi_read(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_wifi_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
        int retval;
        unsigned int state;
-       
-       if((retval = io_op->backend->aerial_get(io_op,&state)))
+
+       if ((retval = io_op->backend->aerial_get(io_op, &state)))
                return retval;
-       
-       len += sprintf(buffer + len,"Wifi adapter is %s", (state & WIFI_EX) ? "present" : "absent");
+
+       len +=
+           sprintf(buffer + len, "Wifi adapter is %s", (state & WIFI_EX) ? "present" : "absent");
        if (state & WIFI_EX)
-               len += sprintf(buffer + len," and %s", (state & WIFI_STA) ? "enabled" : "disabled");
-       len += sprintf(buffer + len,".\n");
-       len += sprintf(buffer + len,"Wifi Kill switch is %s.\n", (state & KILLSWITCH) ? "on" : "off");
-       
+               len +=
+                   sprintf(buffer + len, " and %s", (state & WIFI_STA) ? "enabled" : "disabled");
+       len += sprintf(buffer + len, ".\n");
+       len +=
+           sprintf(buffer + len, "Wifi Kill switch is %s.\n", (state & KILLSWITCH) ? "on" : "off");
+
        return len;
-       
+
 }
 
-static int omnibook_wifi_write(char *buffer,struct omnibook_operation *io_op)
+static int omnibook_wifi_write(char *buffer, struct omnibook_operation *io_op)
 {
-       int retval = 0; 
+       int retval = 0;
        unsigned int state;
-       
-       if((retval = io_op->backend->aerial_get(io_op,&state)))
+
+       if ((retval = io_op->backend->aerial_get(io_op, &state)))
                return retval;
-       
-       if(*buffer == '0' )
+
+       if (*buffer == '0')
                state &= ~WIFI_STA;
-       else if (*buffer == '1' )
+       else if (*buffer == '1')
                state |= WIFI_STA;
        else
                return -EINVAL;
-       
-       if((retval = io_op->backend->aerial_set(io_op, state)))
+
+       if ((retval = io_op->backend->aerial_set(io_op, state)))
                return retval;
 
-       return retval;  
+       return retval;
 }
 
 static struct omnibook_feature wifi_feature;
@@ -64,17 +67,17 @@ static int __init omnibook_wifi_init(struct omnibook_operation *io_op)
 {
        int retval = 0;
        unsigned int state;
-       
+
 /*
  *  Refuse enabling/disabling a non-existent device
  */
-       
-       if((retval = io_op->backend->aerial_get(io_op, &state)))
+
+       if ((retval = io_op->backend->aerial_get(io_op, &state)))
                return retval;
-       
-       if(!(state & WIFI_EX))
-               wifi_feature.write = NULL;      
-       
+
+       if (!(state & WIFI_EX))
+               wifi_feature.write = NULL;
+
        return retval;
 }
 
@@ -82,9 +85,9 @@ static int __init omnibook_wifi_init(struct omnibook_operation *io_op)
  * Shared with bluetooth.c
  */
 struct omnibook_tbl wireless_table[] __initdata = {
-       { TSM30X, {ACPI,}}, /* stubs to select backend */
-       { TSM40,  {SMI,}}, /* stubs to select backend */
-       { 0,}
+       {TSM30X, {ACPI,}},      /* stubs to select backend */
+       {TSM40, {SMI,}},        /* stubs to select backend */
+       {0,}
 };
 
 static struct omnibook_feature __declared_feature wifi_driver = {
@@ -93,7 +96,7 @@ static struct omnibook_feature __declared_feature wifi_driver = {
        .read = omnibook_wifi_read,
        .write = omnibook_wifi_write,
        .init = omnibook_wifi_init,
-       .ectypes = TSM30X|TSM40,
+       .ectypes = TSM30X | TSM40,
        .tbl = wireless_table,
 };