From: Michael Ruoss Stolen from http://bugzilla.kernel.org/show_bug.cgi?id=7154, cleaned up a bit. Cc: Jean Delvare Signed-off-by: Andrew Morton --- drivers/hwmon/hdaps.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff -puN drivers/hwmon/hdaps.c~hdapsc-inversion-of-each-axis drivers/hwmon/hdaps.c --- a/drivers/hwmon/hdaps.c~hdapsc-inversion-of-each-axis +++ a/drivers/hwmon/hdaps.c @@ -180,12 +180,11 @@ static int __hdaps_read_pair(unsigned in km_activity = inb(HDAPS_PORT_KMACT); __device_complete(); - /* if hdaps_invert is set, negate the two values */ - if (hdaps_invert) { + /* hdaps_invert is a bitvector. */ + if ((hdaps_invert & 1) == 1) *x = -*x; + if ((hdaps_invert & 2) == 2) *y = -*y; - } - return 0; } @@ -430,7 +429,7 @@ static ssize_t hdaps_calibrate_store(str static ssize_t hdaps_invert_show(struct device *dev, struct device_attribute *attr, char *buf) { - return sprintf(buf, "%u\n", hdaps_invert); + return sprintf(buf, "%u\n", hdaps_invert); } static ssize_t hdaps_invert_store(struct device *dev, @@ -439,7 +438,7 @@ static ssize_t hdaps_invert_store(struct { int invert; - if (sscanf(buf, "%d", &invert) != 1 || (invert != 1 && invert != 0)) + if (sscanf(buf, "%d", &invert) != 1 || (invert < 0 || invert > 3)) return -EINVAL; hdaps_invert = invert; @@ -630,8 +629,8 @@ 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_param_named(invert, hdaps_invert, int, 0); +MODULE_PARM_DESC(invert, "Invert data along axes. 1 inverts x-axis, 2 inverts y-axis, 3 inverts both axis."); MODULE_AUTHOR("Robert Love"); MODULE_DESCRIPTION("IBM Hard Drive Active Protection System (HDAPS) driver"); _