]> Devoid-pointer.net GitWeb - omnibook.git/commitdiff
Use new procfs API.
authorMichal Malý <madcatxster@gmail.com>
Tue, 9 Jul 2013 08:56:04 +0000 (10:56 +0200)
committerMichal Malý <madcatxster@gmail.com>
Tue, 9 Jul 2013 08:56:04 +0000 (10:56 +0200)
22 files changed:
Makefile
ac.c [changed mode: 0644->0755]
battery.c
blank.c [changed mode: 0644->0755]
bluetooth.c [changed mode: 0644->0755]
cooling.c [changed mode: 0644->0755]
display.c
dock.c
dump.c
fan.c
fan_policy.c
hotkeys.c
info.c
init.c
lcd.c
muteled.c
omnibook.h [changed mode: 0644->0755]
polling.c
temperature.c
throttling.c
touchpad.c
wireless.c

index b414f22326c48a3917663eb9af40d21f9424730d..a17c495e471643656875dabbb74a44389509bfcf 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -126,7 +126,7 @@ ifeq ($(OMNIBOOK_STANDALONE),y)
 ifeq ($(OMNIBOOK_WANT_BACKLIGHT),y)
 ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
 # we support backlight interface only after 2.6.16
-ifeq ($(shell if [ $(SUBLEVEL) -gt 16 ] ; then echo -n 'y'; fi),y)
+ifeq ($(shell if [ $(VERSION) -eq 2 -a $(SUBLEVEL) -gt 16 ] || [ $(VERSION) -ge 3 ] ; then echo -n 'y'; fi),y)
 EXTRA_CFLAGS += -DCONFIG_OMNIBOOK_BACKLIGHT
 else
 $(warning "Backlight support in only supported for kernel version newer than 2.6.16")
diff --git a/ac.c b/ac.c
old mode 100644 (file)
new mode 100755 (executable)
index f03cefb..064196b
--- a/ac.c
+++ b/ac.c
 #include "omnibook.h"
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_ac_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       u8 ac;
+       int retval;
+
+       retval = backend_byte_read(io_op, &ac);
+       if (retval < 0)
+               return retval;
+
+       seq_printf(m, "AC %s\n", (!!ac) ? "on-line" : "off-line");
+       return 0;
+}
+#else
 static int omnibook_ac_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -32,6 +50,7 @@ static int omnibook_ac_read(char *buffer, struct omnibook_operation *io_op)
 
        return len;
 }
+#endif
 
 static struct omnibook_tbl ac_table[] __initdata = {
        {XE3GF | TSP10 | TSM30X | TSM70, SIMPLE_BYTE(EC, XE3GF_ADP, XE3GF_ADP_MASK)},
index c9191fc2146ed72d8c389421ba3c75014504f3cc..fedb4be517caad66569b9845a82ea7e17278fe25 100644 (file)
--- a/battery.c
+++ b/battery.c
 #include "omnibook.h"
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
 struct omnibook_battery_info {
        u8 type;                /* 1 - Li-Ion, 2 NiMH */
        u16 sn;                 /* Serial number */
@@ -446,6 +450,92 @@ static int omnibook_get_battery_status(struct omnibook_operation *io_op,
        return 0;
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_battery_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       char *statustr;
+       char *typestr;
+       int max = 0;
+       int num = 0;
+       int retval;
+       int i;
+       struct omnibook_battery_info battinfo;
+       struct omnibook_battery_state battstat;
+       /*
+        * XE3GF
+        * XE3GC
+        * 0B6000
+        * 0B6100
+        * XE4500
+        * AMILOD
+        * TSP10
+        */
+       if (omnibook_ectype & (XE3GF | XE3GC | OB6000 | OB6100 | XE4500 | AMILOD | TSP10))
+               max = 2;
+       /*
+        * OB500
+        * 0B510
+        */
+       else if (omnibook_ectype & (OB500 | OB510))
+               max = 3;
+       /*
+        * TSM30X
+        * TSM70
+        */
+       else if (omnibook_ectype & (TSM70 | TSM30X))
+               max = 1;
+
+       if(mutex_lock_interruptible(&io_op->backend->mutex))
+                       return -ERESTARTSYS;
+
+       for (i = 0; i < max; i++) {
+               retval = omnibook_get_battery_info(io_op, i, &battinfo);
+               if (retval == 0) {
+                       num++;
+                       omnibook_get_battery_status(io_op, i, &battstat);
+                       typestr = (battinfo.type) ? "Li-Ion" : "NiMH";
+                       switch (battstat.status) {
+                       case OMNIBOOK_BATTSTAT_CHARGED:
+                               statustr = "charged";
+                               break;
+                       case OMNIBOOK_BATTSTAT_DISCHARGING:
+                               statustr = "discharging";
+                               break;
+                       case OMNIBOOK_BATTSTAT_CHARGING:
+                               statustr = "charging";
+                               break;
+                       case OMNIBOOK_BATTSTAT_CRITICAL:
+                               statustr = "critical";
+                               break;
+                       default:
+                               statustr = "unknown";
+                       }
+
+                       seq_printf(m, "Battery:            %11d\n", i);
+                       seq_printf(m, "Type:               %11s\n", typestr);
+                       if (battinfo.sn)
+                               seq_printf(m, "Serial Number:      %11d\n",
+                                          battinfo.sn);
+                       seq_printf(m, "Present Voltage:    %11d mV\n", battstat.pv);
+                       seq_printf(m, "Design Voltage:     %11d mV\n", battinfo.dv);
+                       seq_printf(m, "Remaining Capacity: %11d mAh\n", battstat.rc);
+                       if (battstat.lc)
+                               seq_printf(m, "Last Full Capacity: %11d mAh\n",
+                                          battstat.lc);
+                       seq_printf(m, "Design Capacity:    %11d mAh\n", battinfo.dc);
+                       seq_printf(m, "Gauge:              %11d %%\n", battstat.gauge);
+                       seq_printf(m, "Status:             %11s\n", statustr);
+                       seq_printf(m, "\n");
+               }
+       }
+       if (num == 0)
+               seq_printf(m, "No battery present\n");
+
+       mutex_unlock(&io_op->backend->mutex);
+
+       return 0;
+}
+#else
 static int omnibook_battery_read(char *buffer, struct omnibook_operation *io_op)
 {
        char *statustr;
@@ -534,6 +624,7 @@ static int omnibook_battery_read(char *buffer, struct omnibook_operation *io_op)
 
        return len;
 }
+#endif
 
 static struct omnibook_tbl battery_table[] __initdata = {
        {XE3GF | XE3GC | AMILOD | TSP10 | TSM70 | TSM30X, {EC,}},
diff --git a/blank.c b/blank.c
old mode 100644 (file)
new mode 100755 (executable)
index 1bad34c..e6c2cd1
--- a/blank.c
+++ b/blank.c
@@ -19,6 +19,9 @@
 
 #include <asm/io.h>
 #include "hardware.h"
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
 
 static struct omnibook_feature blank_driver;
 
@@ -70,6 +73,18 @@ static int console_blank_unregister_hook(void)
        return retval;
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_console_blank_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       spin_lock(&blank_spinlock);
+
+       seq_printf(m, "LCD console blanking hook is %s\n",
+                  (console_blank_hook == omnibook_lcd_blank) ? "enabled" : "disabled");
+
+       spin_unlock(&blank_spinlock);
+       return 0;
+}
+#else
 static int omnibook_console_blank_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -84,6 +99,7 @@ static int omnibook_console_blank_read(char *buffer, struct omnibook_operation *
 
        return len;
 }
+#endif
 
 static int omnibook_console_blank_write(char *buffer, struct omnibook_operation *io_op)
 {
old mode 100644 (file)
new mode 100755 (executable)
index 1095eec..d44d52b
 
 #include "omnibook.h"
 #include "hardware.h"
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_bt_read(struct seq_file* m, struct omnibook_operation *io_op)
+{
+       int retval;
+       unsigned int state;
+
+       if ((retval = backend_aerial_get(io_op, &state)))
+               return retval;
+
+       seq_printf(m, "Bluetooth adapter is %s",
+                          (state & BT_EX) ? "present" : "absent");
+       if (state & BT_EX)
+               seq_printf(m, " and %s", (state & BT_STA) ? "enabled" : "disabled");
+       seq_printf(m, ".\n");
+       return 0;
+}
+#else
 static int omnibook_bt_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -36,6 +56,7 @@ static int omnibook_bt_read(char *buffer, struct omnibook_operation *io_op)
        return len;
 
 }
+#endif
 
 static int omnibook_bt_write(char *buffer, struct omnibook_operation *io_op)
 {
old mode 100644 (file)
new mode 100755 (executable)
index 3f507bd..d7bae1b
--- a/cooling.c
+++ b/cooling.c
 #include "omnibook.h"
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif 
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_cooling_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       if(mutex_lock_interruptible(&io_op->backend->mutex))
+               return -ERESTARTSYS;
+
+       seq_printf(m, "Cooling method : %s\n", 
+                  io_op->backend->cooling_state ? "Performance"  : "Powersave" );
+
+       mutex_unlock(&io_op->backend->mutex);
+       return 0;
+}
+#else
 static int omnibook_cooling_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -30,6 +47,7 @@ static int omnibook_cooling_read(char *buffer, struct omnibook_operation *io_op)
        mutex_unlock(&io_op->backend->mutex);
        return len;
 }
+#endif
 
 static int omnibook_cooling_write(char *buffer, struct omnibook_operation *io_op)
 {
index 1c5d4d79d72832038c89158ff4082c49df68e15d..d00a75886792254168bebda3603d96c0c35655ca 100644 (file)
--- a/display.c
+++ b/display.c
 #include "omnibook.h"
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
 static const char display_name[][16] = {
        "Internal LCD",
        "External VGA",
@@ -25,6 +29,33 @@ static const char display_name[][16] = {
        "External DVI",
 };
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_display_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       int retval;
+       unsigned int sta, en_mask, det_mask;
+
+       retval = backend_display_get(io_op, &sta);
+       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 */
+               seq_printf(m, "%s:", display_name[ffs(en_mask) - 1]);
+               if (retval & det_mask)
+                       seq_printf(m, " display %s",
+                                  (sta & det_mask) ? "present" : "absent");
+               if (retval & en_mask)
+                       seq_printf(m, " port %s",
+                                   (sta & en_mask) ? "enabled" : "disabled");
+               seq_printf(m, "\n");
+       }
+
+       return 0;
+}
+#else
 static int omnibook_display_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -53,6 +84,7 @@ static int omnibook_display_read(char *buffer, struct omnibook_operation *io_op)
 
        return len;
 }
+#endif
 
 static int omnibook_display_write(char *buffer, struct omnibook_operation *io_op)
 {
diff --git a/dock.c b/dock.c
index 3264f70e4c627b42b158dce18d6ad5b4ddca8522..47ea235946af7905a5c42590b7b66924f9db52d8 100644 (file)
--- a/dock.c
+++ b/dock.c
 #include "omnibook.h"
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_dock_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       u8 dock;
+       int retval;
+
+       if ((retval = backend_byte_read(io_op, &dock)))
+               return retval;
+
+       seq_printf(m, "Laptop is %s\n", (dock) ? "docked" : "undocked");
+
+       return 0;
+}
+#else
 static int omnibook_dock_read(char *buffer, struct omnibook_operation *io_op)
 {
-       int len = 0;
+       int len = 0
        u8 dock;
        int retval;
 
        if ((retval = 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;
 }
+#endif
 
 static int omnibook_dock_write(char *buffer, struct omnibook_operation *io_op)
 {
diff --git a/dump.c b/dump.c
index ff959e96a8d127b9702d22e3912d176b1ae5f5bd..c31e2de2b9e5a49b39708de514184e5086ac3755 100644 (file)
--- a/dump.c
+++ b/dump.c
 #include "omnibook.h"
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
 static u8 ecdump_regs[256];
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int ecdump_read(struct seq_file* m, struct omnibook_operation *io_op)
+{
+       int i, j;
+       u8 v;
+
+       seq_printf(m,
+                  "EC      " " +00 +01 +02 +03 +04 +05 +06 +07"
+                  " +08 +09 +0a +0b +0c +0d +0e +0f\n");
+
+       if(mutex_lock_interruptible(&io_op->backend->mutex))
+                       return -ERESTARTSYS;
+
+       for (i = 0; i < 255; i += 16) {
+               seq_printf(m, "EC 0x%02x:", i);
+               for (j = 0; j < 16; j++) {
+                       io_op->read_addr = i +j;
+                       if (__backend_byte_read(io_op, &v))
+                               break;
+                       if (v != ecdump_regs[i + j])
+                               seq_printf(m, " *%02x", v);
+                       else
+                               seq_printf(m, "  %02x", v);
+                       ecdump_regs[i + j] = v;
+               }
+               seq_printf(m, "\n");
+               if (j != 16)
+                       break;
+       }
+
+       mutex_unlock(&io_op->backend->mutex);
+
+       /* These are way too dangerous to advertise openly... */
+#if 0
+       seq_printf(m,
+                  "commands:\t0x<offset> 0x<value>" " (<offset> is 00-ff, <value> is 00-ff)\n");
+       swq_printf(m,
+                  "commands:\t0x<offset> <value>  " " (<offset> is 00-ff, <value> is 0-255)\n");
+#endif
+       return 0;
+}
+#else
 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");
 
        if(mutex_lock_interruptible(&io_op->backend->mutex))
                        return -ERESTARTSYS;
@@ -59,15 +104,14 @@ 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;
 }
+#endif
 
 static int ecdump_write(char *buffer, struct omnibook_operation *io_op)
 {
diff --git a/fan.c b/fan.c
index d8129935deeb316f5c0d7d875a15af52f7f8f19c..f30d53ce1b42d4c55eea680b420887dfb88a5249 100644 (file)
--- a/fan.c
+++ b/fan.c
 #include <asm/io.h>
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
 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 };
 
@@ -104,10 +108,29 @@ static int omnibook_fan_off(struct omnibook_operation *io_op)
        return retval;
 }
 
-static int omnibook_fan_read(char *buffer, struct omnibook_operation *io_op)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_fan_read(struct seq_file *m, struct omnibook_operation *io_op)
 {
        int fan;
+       char *str;
+
+       fan = omnibook_get_fan(io_op);
+       if (fan < 0)
+               return fan;
+       str = (fan) ? "on" : "off";
+
+       if (fan > 1)
+               seq_printf(m, "Fan is %s (level %d)\n", str, fan);
+       else
+               seq_printf(m, "Fan is %s\n", str);
+
+       return 0;
+}
+#else
+static int omnibook_fan_read(char *buffer, struct omnibook_operation *io_op)
+{
        int len = 0;
+       int fan;
        char *str;
 
        fan = omnibook_get_fan(io_op);
@@ -122,6 +145,7 @@ static int omnibook_fan_read(char *buffer, struct omnibook_operation *io_op)
 
        return len;
 }
+#endif
 
 static int omnibook_fan_write(char *buffer, struct omnibook_operation *io_op)
 {
index 67915ffedbb48ab90e12dba5ac8faea146df3099..6d456fb5bd6da2568b1f6e6d4a541016c98e272a 100644 (file)
@@ -20,6 +20,9 @@
 #include <linux/ctype.h>
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
 /*
  * Default temperature limits.
  * Danger! You may overheat your CPU!
@@ -87,10 +90,39 @@ static int omnibook_set_fan_policy(struct omnibook_operation *io_op, const u8 *f
        return 0;
 }
 
-static int omnibook_fan_policy_read(char *buffer, struct omnibook_operation *io_op)
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_fan_policy_read(struct seq_file *m, struct omnibook_operation *io_op)
 {
        int retval;
+       u8 i;
+       u8 fan_policy[OMNIBOOK_FAN_LEVELS];
+
+       if(mutex_lock_interruptible(&io_op->backend->mutex))
+               return -ERESTARTSYS;
+
+       retval = omnibook_get_fan_policy(io_op, &fan_policy[0]);
+
+       mutex_unlock(&io_op->backend->mutex);
+
+       if(retval)
+               return retval;
+
+       seq_printf(m, "Fan off temperature:        %2d C\n", fan_policy[0]);
+       seq_printf(m, "Fan on temperature:         %2d C\n", fan_policy[1]);
+       for (i = 2; i < OMNIBOOK_FAN_LEVELS; i++) {
+               seq_printf(m, "Fan level %1d temperature:    %2d C\n", i,
+                          fan_policy[i]);
+       }
+       seq_printf(m, "Minimal temperature to set: %2d C\n", OMNIBOOK_FAN_MIN);
+       seq_printf(m, "Maximal temperature to set: %2d C\n", OMNIBOOK_FAN_MAX);
+
+       return 0;
+}
+#else
+static int omnibook_fan_policy_read(char *buffer, struct omnibook_operation *io_op)
+{
        int len = 0;
+       int retval;
        u8 i;
        u8 fan_policy[OMNIBOOK_FAN_LEVELS];
 
@@ -116,6 +148,7 @@ static int omnibook_fan_policy_read(char *buffer, struct omnibook_operation *io_
 
        return len;
 }
+#endif
 
 static int omnibook_fan_policy_write(char *buffer, struct omnibook_operation *io_op)
 {
index 7d541e12adbf6a0a2d8d7db1c20ede25249287af..97de6fff4832360ba539602c7b33519fb30e4634 100644 (file)
--- a/hotkeys.c
+++ b/hotkeys.c
 #include "omnibook.h"
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
 /* Predefined convinient on/off states */
 #define HKEY_ON  HKEY_ONETOUCH|HKEY_MULTIMEDIA|HKEY_FN|HKEY_DOCK|HKEY_FNF5
 #define HKEY_OFF 0
@@ -106,6 +110,29 @@ static const char pretty_name[][27] = {
        "Fn + F5 hotkey is",
 };
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_hotkeys_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       int retval;
+       unsigned int read_state = 0; /* buggy gcc 4.1 warning fix */
+       unsigned int shift, mask;
+
+       retval = hotkeys_get_save(io_op, &read_state);
+
+       if (retval < 0)
+               return retval;
+
+       for (shift = 0; shift <= HKEY_LAST_SHIFT ; shift++) {
+               mask = 1 << shift;
+               /* we assume write capability or read capability imply support */
+               if ((io_op->backend->hotkeys_read_cap | io_op->backend->hotkeys_write_cap) & mask)
+                       seq_printf(m, "%s %s.\n", pretty_name[shift],
+                                  (read_state & mask) ? "enabled" : "disabled");
+       }
+
+       return 0;
+}
+#else
 static int omnibook_hotkeys_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -129,6 +156,7 @@ static int omnibook_hotkeys_read(char *buffer, struct omnibook_operation *io_op)
 
        return len;
 }
+#endif
 
 static int omnibook_hotkeys_write(char *buffer, struct omnibook_operation *io_op)
 {
diff --git a/info.c b/info.c
index 8e25e7a1a9d2b35a6726fcdd9dd253a6fe25321a..f1914aa7fe65f0881d135eed84af57b2844dec80 100644 (file)
--- a/info.c
+++ b/info.c
 #include <linux/dmi.h>
 #include <linux/version.h>
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_version_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       seq_printf(m, "%s\n", OMNIBOOK_MODULE_VERSION);
+
+       return 0;
+}
+#else
 static int omnibook_version_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -28,7 +40,26 @@ static int omnibook_version_read(char *buffer, struct omnibook_operation *io_op)
 
        return len;
 }
+#endif
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_dmi_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       seq_printf(m, "BIOS Vendor:   %s\n", dmi_get_system_info(DMI_BIOS_VENDOR));
+       seq_printf(m, "BIOS Version:  %s\n", dmi_get_system_info(DMI_BIOS_VERSION));
+       seq_printf(m, "BIOS Release:  %s\n", dmi_get_system_info(DMI_BIOS_DATE));
+       seq_printf(m, "System Vendor: %s\n", dmi_get_system_info(DMI_SYS_VENDOR));
+       seq_printf(m, "Product Name:  %s\n", dmi_get_system_info(DMI_PRODUCT_NAME));
+       seq_printf(m, "Version:       %s\n", dmi_get_system_info(DMI_PRODUCT_VERSION));
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15))
+       seq_printf(m, "Serial Number: %s\n", dmi_get_system_info(DMI_PRODUCT_SERIAL));
+#endif
+       seq_printf(m, "Board Vendor:  %s\n", dmi_get_system_info(DMI_BOARD_VENDOR));
+       seq_printf(m, "Board Name:    %s\n", dmi_get_system_info(DMI_BOARD_VERSION));
+
+       return 0;
+}
+#else
 static int omnibook_dmi_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -49,6 +80,7 @@ static int omnibook_dmi_read(char *buffer, struct omnibook_operation *io_op)
 
        return len;
 }
+#endif
 
 static struct omnibook_feature __declared_feature version_driver = {
        .name = "version",
diff --git a/init.c b/init.c
index 70d5415ab8628f003d112f2fa765d21a5a8cee7e..15361022e7b23ac83c526f91b6cefa8fe1576a41 100644 (file)
--- a/init.c
+++ b/init.c
 #include <linux/dmi.h>
 #include <linux/version.h>
 #include <asm/uaccess.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+//#include <linux/fs.h>
+#endif
 
 #include "hardware.h"
 #include "laptop.h"
@@ -43,6 +47,16 @@ static int __init omnibook_probe(struct platform_device *dev);
 static int __exit omnibook_remove(struct platform_device *dev);
 static int omnibook_suspend(struct platform_device *dev, pm_message_t state);
 static int omnibook_resume(struct platform_device *dev);
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_feature_open(struct inode *inode, struct file *file);
+static int omnibook_feature_show(struct seq_file *m, void *v);
+static ssize_t omnibook_feature_write(struct file *f, const char __user *userbuf, size_t s, loff_t *off);
+#endif
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
+static inline void *PDE_DATA(const struct inode *inode) {
+       return PDE(inode)->data;
+}
+#endif
 
 /*
  * For compatibility with kernel older than 2.6.15
@@ -128,6 +142,25 @@ static struct platform_device omnibook_device = {
 /* Linked list of all enabled features */
 static struct omnibook_feature *omnibook_available_feature;
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static const struct file_operations proc_fops_ro = {
+       .owner = THIS_MODULE,
+       .open = omnibook_feature_open,
+       .read = seq_read,
+       .llseek = seq_lseek,
+       .release = single_release,
+};
+
+static const struct file_operations proc_fops_rw = {
+       .owner = THIS_MODULE,
+       .open = omnibook_feature_open,
+       .read = seq_read,
+       .write = omnibook_feature_write,
+       .llseek = seq_lseek,
+       .release = single_release,
+};
+#endif
+
 /* Delimiters of the .features section wich holds all the omnibook_feature structs */
 extern struct omnibook_feature _start_features_driver[];
 extern struct omnibook_feature _end_features_driver[];
@@ -146,6 +179,51 @@ static int __init dmi_matched(const struct dmi_system_id *dmi)
        return 1;               /* return non zero means we stop the parsing selecting this entry */
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_feature_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, omnibook_feature_show, PDE_DATA(inode));
+}
+
+static int omnibook_feature_show(struct seq_file *m, void *v)
+{
+       struct omnibook_feature *feature = m->private;
+
+       if (!feature || !feature->read)
+               return -EINVAL;
+
+       return feature->read(m, feature->io_op);
+}
+static ssize_t omnibook_feature_write(struct file *f, const char __user *userbuf, size_t s, loff_t *off)
+{
+       struct omnibook_feature *feature = PDE_DATA(f->f_dentry->d_inode);
+       char *kernbuf;
+       int retval;
+
+       if (!feature || !feature->write)
+               return -EINVAL;
+
+       kernbuf = kmalloc(s + 1, GFP_KERNEL);
+       if (!kernbuf)
+               return -ENOMEM;
+
+       if (copy_from_user(kernbuf, userbuf, s)) {
+               kfree(kernbuf);
+               return -EFAULT;
+       }
+
+       /* Make sure the string is \0 terminated */
+       kernbuf[s] = '\0';
+
+       retval = feature->write(kernbuf, feature->io_op);
+       if (retval == 0)
+               retval = s;
+
+       kfree(kernbuf);
+
+       return retval;
+}
+#else
 /* 
  * Callback function for procfs file reading: the name of the file read was stored in *data 
  */
@@ -203,6 +281,7 @@ static int procfile_write_dispatch(struct file *file, const char __user * userbu
 
        return retval;
 }
+#endif
 
 /*
  * Match an ectype and return pointer to corresponding omnibook_operation.
@@ -231,6 +310,8 @@ static struct omnibook_operation *omnibook_backend_match(struct omnibook_tbl *tb
        return matched;
 }
 
+
+
 /* 
  * Initialise a feature and add it to the linked list of active features
  */
@@ -281,8 +362,16 @@ static int __init omnibook_init(struct omnibook_feature *feature)
                                pmode |= S_IWUGO;
                }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+               if (feature->write)
+                       proc_entry = proc_create_data(feature->name, pmode, omnibook_proc_root, &proc_fops_rw, feature);
+               else
+                       proc_entry = proc_create_data(feature->name, pmode, omnibook_proc_root, &proc_fops_ro, feature);
+#else
                proc_entry = create_proc_entry(feature->name, pmode, omnibook_proc_root);
 
+#endif
+
                if (!proc_entry) {
                        printk(O_ERR "Unable to create proc entry %s\n", feature->name);
                        if (feature->exit)
@@ -290,6 +379,7 @@ static int __init omnibook_init(struct omnibook_feature *feature)
                        retval = -ENOENT;
                        goto err;
                }
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
                proc_entry->data = feature;
                proc_entry->read_proc = &procfile_read_dispatch;
                if (feature->write)
@@ -297,6 +387,7 @@ static int __init omnibook_init(struct omnibook_feature *feature)
                #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
                        proc_entry->owner = THIS_MODULE;
                #endif
+#endif
        }
        list_add_tail(&feature->list, &omnibook_available_feature->list);
        return 0;
diff --git a/lcd.c b/lcd.c
index 85fe17cae84871c3683b075df902c93544cc0e49..2ee40e3156c36fbf6927dfd829772f03a02173d6 100644 (file)
--- a/lcd.c
+++ b/lcd.c
 
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
 unsigned int omnibook_max_brightness;
 
 #ifdef CONFIG_OMNIBOOK_BACKLIGHT
@@ -82,6 +86,20 @@ static int omnibook_set_backlight(struct backlight_device *bd)
 }
 #endif /* CONFIG_OMNIBOOK_BACKLIGHT */
 
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_brightness_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       u8 brgt;
+
+       backend_byte_read(io_op, &brgt);
+
+       seq_printf(m, "LCD brightness: %2d (max value: %d)\n", brgt,
+                  omnibook_max_brightness);
+
+       return 0;
+}
+#else
 static int omnibook_brightness_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -95,6 +113,7 @@ static int omnibook_brightness_read(char *buffer, struct omnibook_operation *io_
 
        return len;
 }
+#endif
 
 static int omnibook_brightness_write(char *buffer, struct omnibook_operation *io_op)
 {
index a21793a50bff54559b0b44081f41e3fdada70b9d..a383cf34ff292d81294197f6e64208e399269498 100644 (file)
--- a/muteled.c
+++ b/muteled.c
 #include "omnibook.h"
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
 static int omnibook_muteled_set(struct omnibook_operation *io_op, int status)
 {
        int retval = 0;
@@ -40,6 +44,18 @@ static int omnibook_muteled_set(struct omnibook_operation *io_op, int status)
 /*
  * Hardware query is unsupported, reading is unreliable.
  */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_muteled_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       if(mutex_lock_interruptible(&io_op->backend->mutex))
+               return -ERESTARTSYS;
+       seq_printf(m, "Last mute LED action was an %s command.\n",
+                  io_op->backend->touchpad_state ? "on" : "off");
+
+       mutex_unlock(&io_op->backend->mutex);
+       return 0;
+}
+#else
 static int omnibook_muteled_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -53,6 +69,7 @@ static int omnibook_muteled_read(char *buffer, struct omnibook_operation *io_op)
        mutex_unlock(&io_op->backend->mutex);
        return len;
 }
+#endif
 
 static int omnibook_muteled_write(char *buffer, struct omnibook_operation *io_op)
 {
old mode 100644 (file)
new mode 100755 (executable)
index 762d936..493c396
@@ -56,7 +56,11 @@ struct omnibook_operation;
 struct omnibook_feature {
        char *name;                                             /* Name */
        int enabled;                                            /* Set from module parameter */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+       int (*read)(struct seq_file *,struct omnibook_operation *);
+#else
        int (*read) (char *,struct omnibook_operation *);       /* Procfile read function */
+#endif
        int (*write) (char *,struct omnibook_operation *);      /* Procfile write function */
        int (*init) (struct omnibook_operation *);              /* Specific Initialization function */
        void (*exit) (struct omnibook_operation *);             /* Specific Cleanup function */
index 2d28f7e4e1eb698787819f0e12df9c3f079208f3..9e0b0907f15fe4a806ee183f50a30e459bd2b763 100644 (file)
--- a/polling.c
+++ b/polling.c
 #include <linux/workqueue.h>
 #include <linux/jiffies.h>
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
 /*
  * XE3GC type key_polling polling:
  *
@@ -125,7 +129,11 @@ static int omnibook_key_polling_disable(void)
        if(!key_polling_enabled)
                goto out;
 
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,0,0))
+       cancel_delayed_work_sync(&omnibook_poll_work);
+#else
        cancel_rearming_delayed_workqueue(omnibook_wq, &omnibook_poll_work);
+#endif
        dprintk("Scancode emulation for volume buttons disabled.\n");
        key_polling_enabled = 0;
 
@@ -134,7 +142,23 @@ static int omnibook_key_polling_disable(void)
        return 0;
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_key_polling_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       if(mutex_lock_interruptible(&poll_mutex))
+               return -ERESTARTSYS;
 
+       seq_printf(m, "Volume buttons polling is %s.\n",
+                  (key_polling_enabled) ? "enabled" : "disabled");
+#ifdef CONFIG_OMNIBOOK_DEBUG
+       if(key_polling_enabled) 
+               seq_printf(m, "Will poll in %i msec.\n",
+               jiffies_to_msecs(omnibook_poll_work.timer.expires - jiffies));
+#endif
+       mutex_unlock(&poll_mutex);
+       return 0;
+}
+#else
 static int omnibook_key_polling_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -152,6 +176,7 @@ static int omnibook_key_polling_read(char *buffer, struct omnibook_operation *io
        mutex_unlock(&poll_mutex);
        return len;
 }
+#endif
 
 static int omnibook_key_polling_write(char *buffer, struct omnibook_operation *io_op)
 {
@@ -169,7 +194,6 @@ static int omnibook_key_polling_write(char *buffer, struct omnibook_operation *i
        return retval;
 }
 
-
 /*
  * Stop polling upon suspend an restore it upon resume
  */
@@ -188,7 +212,11 @@ static int omnibook_key_polling_suspend(struct omnibook_operation *io_op)
 {
        mutex_lock(&poll_mutex);
        if(key_polling_enabled)
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,0,0))
+               cancel_delayed_work_sync(&omnibook_poll_work);
+#else
                cancel_rearming_delayed_workqueue(omnibook_wq, &omnibook_poll_work);
+#endif
        mutex_unlock(&poll_mutex);
        return 0;
 }
index b27b6118fc5fd5aa1a481ab2094dd20c6a27ceb7..2638da95e84363e5d3497a9ddf852be42d5af503 100644 (file)
 #include "omnibook.h"
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_temperature_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       int retval;
+       u8 temp;
+
+       if ((retval = backend_byte_read(io_op, &temp)))
+               return retval;
+
+       seq_printf(m, "CPU temperature:            %2d C\n", temp);
+
+       return 0;
+}
+#else
 static int omnibook_temperature_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -31,6 +49,7 @@ static int omnibook_temperature_read(char *buffer, struct omnibook_operation *io
 
        return len;
 }
+#endif
 
 static struct omnibook_tbl temp_table[] __initdata = {
        {XE3GF | TSP10 | TSM70 | TSM30X | TSX205, SIMPLE_BYTE(EC, XE3GF_CTMP, 0)},
index 945eafaa11ef84ca4a4213525386d0d75ba6e906..c7234d74456fff5d2e0822f8c7ef42e510a8de50 100644 (file)
 #include "omnibook.h"
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
 /*
  * Throttling level/rate mapping found in ICH6M datasheets
  * the output is set to mimic the one of /proc/acpi/cpu/CPU0/throttling
  * XXX: We always assume that there are 8 T-States and one processor.
  */
 static const int trate[8] = { 0, 12, 25, 37, 50, 62, 75, 87 };
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_throttle_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       int tstate = 0;
+       int retval, i;
 
+       retval = backend_throttle_get(io_op, &tstate);
+       if (retval < 0)
+               return retval;
+
+       seq_printf(m, "state count:             8\n");
+        seq_printf(m, "active state:            T%d\n", tstate);
+       for (i = 0; i < 8; i += 1)
+       {
+               seq_printf(m, "   %cT%d:                  %02d%%\n",
+                          (i == tstate ? '*' : ' '),
+                          i,
+                          trate[i]);
+       }
+
+       return 0;
+}
+#else
 static int omnibook_throttle_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -46,6 +72,7 @@ static int omnibook_throttle_read(char *buffer, struct omnibook_operation *io_op
 
        return len;
 }
+#endif
 
 static int omnibook_throttle_write(char *buffer, struct omnibook_operation *io_op)
 {
index b95e2ecb5cc62b9b8034204090f7a834e180d9a2..b8359358b64ec8795b61d231b3372fcb016633ae 100644 (file)
 #include "omnibook.h"
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
 static int omnibook_touchpad_set(struct omnibook_operation *io_op, int status)
 {
        int retval = 0;
@@ -52,6 +56,19 @@ static int omnibook_touchpad_resume(struct omnibook_operation *io_op)
 /*
  * Hardware query is unsupported, so reading is unreliable.
  */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_touchpad_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       if(mutex_lock_interruptible(&io_op->backend->mutex))
+               return -ERESTARTSYS;
+
+       seq_printf(m, "Last touchpad action was an %s command.\n",
+                  io_op->backend->touchpad_state ? "enable" : "disable");
+
+       mutex_unlock(&io_op->backend->mutex);
+       return 0;
+}
+#else
 static int omnibook_touchpad_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -66,6 +83,7 @@ static int omnibook_touchpad_read(char *buffer, struct omnibook_operation *io_op
        mutex_unlock(&io_op->backend->mutex);
        return len;
 }
+#endif
 
 static int omnibook_touchpad_write(char *buffer, struct omnibook_operation *io_op)
 {
index 71b0c41b37a0971464433d28279bbfdb88b0ea35..2547032a28c48525c6ed2b631d5a2ae0007aa4a5 100644 (file)
 #include "omnibook.h"
 #include "hardware.h"
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+#include <linux/seq_file.h>
+#endif
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
+static int omnibook_wifi_read(struct seq_file *m, struct omnibook_operation *io_op)
+{
+       int retval;
+       unsigned int state;
+
+       if ((retval = backend_aerial_get(io_op, &state)))
+               return retval;
+
+       seq_printf(m, "Wifi adapter is %s", (state & WIFI_EX) ? "present" : "absent");
+       if (state & WIFI_EX)
+               seq_printf(m, " and %s", (state & WIFI_STA) ? "enabled" : "disabled");
+       seq_printf(m, ".\n");
+       seq_printf(m, "Wifi Kill switch is %s.\n", (state & KILLSWITCH) ? "on" : "off");
+
+       return 0;
+}
+#else
 static int omnibook_wifi_read(char *buffer, struct omnibook_operation *io_op)
 {
        int len = 0;
@@ -39,6 +61,7 @@ static int omnibook_wifi_read(char *buffer, struct omnibook_operation *io_op)
        return len;
 
 }
+#endif
 
 static int omnibook_wifi_write(char *buffer, struct omnibook_operation *io_op)
 {