The patch titled hdaps: more lenovo updates has been added to the -mm tree. Its filename is hdaps-more-lenovo-updates.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this From: Robert Love <rml@xxxxxxxxxx> Adds (better) support for the Lenovo X60. It also generalizes the axis inversion code, so we can support laptops that invert only one axis but not another. Signed-off-by: Robert Love <rml@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- drivers/hwmon/hdaps.c | 65 ++++++++++++++++++++-------------------- 1 files changed, 33 insertions(+), 32 deletions(-) diff -puN drivers/hwmon/hdaps.c~hdaps-more-lenovo-updates drivers/hwmon/hdaps.c --- 25/drivers/hwmon/hdaps.c~hdaps-more-lenovo-updates Tue May 9 10:36:02 2006 +++ 25-akpm/drivers/hwmon/hdaps.c Tue May 9 10:36:02 2006 @@ -62,6 +62,10 @@ #define HDAPS_INPUT_FUZZ 4 /* input event threshold */ #define HDAPS_INPUT_FLAT 4 +#define INVERT_NONE 0 /* do not invert any axis */ +#define INVERT_X 1 /* invert x axis */ +#define INVERT_Y 2 /* invert y axis */ + static struct timer_list hdaps_timer; static struct platform_device *pdev; static struct input_dev *hdaps_idev; @@ -181,10 +185,10 @@ static int __hdaps_read_pair(unsigned in __device_complete(); /* if hdaps_invert is set, negate the two values */ - if (hdaps_invert) { + if (hdaps_invert & INVERT_X) *x = -*x; + if (hdaps_invert & INVERT_Y) *y = -*y; - } return 0; } @@ -226,11 +230,15 @@ static int hdaps_device_init(void) * Others--namely the R50p, T41p, and T42p--return 0x03. These laptops * have "inverted" axises. * + * And the X60 returns 0x00 and it has a single axis (!) inverted. + * * The 0x02 value occurs when the chip has been previously initialized. */ + if (__check_latch(0x1611, 0x03) && __check_latch(0x1611, 0x02) && - __check_latch(0x1611, 0x01)) + __check_latch(0x1611, 0x01) && + __check_latch(0x1611, 0x00)) goto out; printk(KERN_DEBUG "hdaps: initial latch check good (0x%02x).\n", @@ -291,8 +299,10 @@ static int hdaps_probe(struct platform_d int ret; ret = hdaps_device_init(); - if (ret) + if (ret) { + printk(KERN_INFO "hdaps: device probe failed (ret=%d)\n", ret); return ret; + } printk(KERN_INFO "hdaps: device successfully initialized.\n"); return 0; @@ -427,27 +437,6 @@ static ssize_t hdaps_calibrate_store(str return count; } -static ssize_t hdaps_invert_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%u\n", hdaps_invert); -} - -static ssize_t hdaps_invert_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - int invert; - - if (sscanf(buf, "%d", &invert) != 1 || (invert != 1 && invert != 0)) - return -EINVAL; - - hdaps_invert = invert; - hdaps_calibrate(); - - return count; -} - static DEVICE_ATTR(position, 0444, hdaps_position_show, NULL); static DEVICE_ATTR(variance, 0444, hdaps_variance_show, NULL); static DEVICE_ATTR(temp1, 0444, hdaps_temp1_show, NULL); @@ -455,7 +444,6 @@ static DEVICE_ATTR(temp2, 0444, hdaps_te static DEVICE_ATTR(keyboard_activity, 0444, hdaps_keyboard_activity_show, NULL); static DEVICE_ATTR(mouse_activity, 0444, hdaps_mouse_activity_show, NULL); static DEVICE_ATTR(calibrate, 0644, hdaps_calibrate_show,hdaps_calibrate_store); -static DEVICE_ATTR(invert, 0644, hdaps_invert_show, hdaps_invert_store); static struct attribute *hdaps_attributes[] = { &dev_attr_position.attr, @@ -465,7 +453,6 @@ static struct attribute *hdaps_attribute &dev_attr_keyboard_activity.attr, &dev_attr_mouse_activity.attr, &dev_attr_calibrate.attr, - &dev_attr_invert.attr, NULL, }; @@ -486,11 +473,19 @@ static int hdaps_dmi_match(struct dmi_sy /* hdaps_dmi_match_invert - found an inverted match. */ static int hdaps_dmi_match_invert(struct dmi_system_id *id) { - hdaps_invert = 1; - printk(KERN_INFO "hdaps: inverting axis readings.\n"); + hdaps_invert = INVERT_X | INVERT_Y; + printk(KERN_INFO "hdaps: inverting both axis readings.\n"); return hdaps_dmi_match(id); } +/* hdaps_dmi_match_invert - found an inverted match. */ +static int hdaps_dmi_match_invert_y(struct dmi_system_id *id) +{ + hdaps_invert = INVERT_Y; + printk(KERN_INFO "hdaps: inverting y axis reading.\n"); + return hdaps_dmi_match(id); +} + #define HDAPS_DMI_MATCH_NORMAL(model) { \ .ident = "IBM " model, \ .callback = hdaps_dmi_match, \ @@ -518,6 +513,15 @@ static int hdaps_dmi_match_invert(struct } \ } +#define HDAPS_DMI_MATCH_LENOVY(model) { \ + .ident = "Lenovo " model, \ + .callback = hdaps_dmi_match_invert_y, \ + .matches = { \ + DMI_MATCH(DMI_BOARD_VENDOR, "LENOVO"), \ + DMI_MATCH(DMI_PRODUCT_VERSION, model) \ + } \ +} + static int __init hdaps_init(void) { int ret; @@ -626,9 +630,6 @@ static void __exit hdaps_exit(void) module_init(hdaps_init); module_exit(hdaps_exit); -module_param_named(invert, hdaps_invert, bool, 0); -MODULE_PARM_DESC(invert, "invert data along each axis"); - MODULE_AUTHOR("Robert Love"); MODULE_DESCRIPTION("IBM Hard Drive Active Protection System (HDAPS) driver"); MODULE_LICENSE("GPL v2"); _ Patches currently in -mm which might be from rml@xxxxxxxxxx are hdaps-more-lenovo-updates.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html