[ltp] Re: [ANN] tp_smapi - a new Linux SMAPI driver (Patch for Ubuntu / Older Kernels)

Guenther Starnberger linux-thinkpad@linux-thinkpad.org
Mon, 05 Dec 2005 22:49:50 +0100


--=-74Pel1johNuENSEuyGDu
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Mon, 2005-12-05 at 21:24 +0100, Guenther Starnberger wrote:

> now it compiles cleanly but i still get a segfault when cat'ing a file:

hmm.. of course it is always a good idea to reboot after an oops. now it
works fine with 2.6.12 (the default kernel in ubuntu breezy).

i've attached a patch which fixes the signature. on kernels >= 2,6,13
the current (new) method is used while on older kernels the older method
(without "struct device_attribute *attr") is used. i'm not sure which
version introduced the new signature. ubuntu ships with a heavily
patched 2.6.12 kernel which does use the old signature, but the post on
http://lkml.org/lkml/2005/5/11/27 indicates that the change could
already have happened in 2.6.12. so the #ifdef may need some corrections
to the kernel version.

anyway - i tried it with my X41 and it works fine[*] (thanks shem!):

-------- 8< -------- 8< -------- 8< -------- 8< -------- 8< --------
root@pico:/sys/devices/platform/smapi# echo 90 >start_charge_thresh
root@pico:/sys/devices/platform/smapi# cat start_charge_thresh
90
root@pico:/sys/devices/platform/smapi# echo 95 >stop_charge_thresh
root@pico:/sys/devices/platform/smapi# cat stop_charge_thresh
95
root@pico:/sys/devices/platform/smapi# cat inhibit_charge
0
root@pico:/sys/devices/platform/smapi# echo 1 >inhibit_charge
root@pico:/sys/devices/platform/smapi# cat inhibit_charge
1
-------- 8< -------- 8< -------- 8< -------- 8< -------- 8< --------

bye,
/gst

[*] i haven't tested yet if it really does have any effect but a least i
don't get any error and it seems to work.


--=-74Pel1johNuENSEuyGDu
Content-Disposition: attachment; filename=device_attr_change.patch
Content-Type: text/x-patch; name=device_attr_change.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

diff -urN tp_smapi-0.04.orig/tp_smapi.c tp_smapi-0.04/tp_smapi.c
--- tp_smapi-0.04.orig/tp_smapi.c	2005-12-05 15:27:57.000000000 +0100
+++ tp_smapi-0.04/tp_smapi.c	2005-12-05 22:35:26.000000000 +0100
@@ -303,7 +303,10 @@
 /*** proc file read/write routines ***/
 
 static int start_charge_thresh_show(struct device *dev,
-                                    struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
+                                    struct device_attribute *attr,
+#endif
+				    char *buf)
 {
 	int thresh;
 	int ret = get_thresh(BATTERY, THRESH_START, &thresh);
@@ -313,7 +316,10 @@
 }
 
 static int stop_charge_thresh_show(struct device *dev,
-                                   struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
+                                   struct device_attribute *attr,
+#endif
+				   char *buf)
 {
 	int thresh;
 	int ret = get_thresh(BATTERY, THRESH_STOP, &thresh);
@@ -324,7 +330,9 @@
 }
 
 static int start_charge_thresh_store(struct device *dev,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
                                      struct device_attribute *attr,
+#endif
                                      const char *buf, size_t count){
 	int thresh, other_thresh, ret;
 
@@ -351,7 +359,9 @@
 }
 
 static int stop_charge_thresh_store(struct device *dev,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
                                     struct device_attribute *attr,
+#endif
                                     const char *buf, size_t count)
 {
 	int thresh, other_thresh, ret;
@@ -379,7 +389,10 @@
 }
 
 static int inhibit_charge_show(struct device *dev,
-                            struct device_attribute *attr, char *buf)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
+                            struct device_attribute *attr,
+#endif
+			    char *buf)
 {
 	int ret, status;
 	ret = get_inhibit_charge(BATTERY, &status);
@@ -389,7 +402,9 @@
 }
 
 static int inhibit_charge_store(struct device *dev,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,13)
                                 struct device_attribute *attr,
+#endif
                                 const char *buf, size_t count)
 {
 	int ret, status;

--=-74Pel1johNuENSEuyGDu--