input: vsense: round multipliers up
authorGrazvydas Ignotas <notasas@gmail.com>
Fri, 10 Jun 2011 10:31:10 +0000 (13:31 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Fri, 27 Apr 2012 21:28:00 +0000 (00:28 +0300)
This will make read values consistent.

drivers/input/misc/vsense.c

index 5f781b8..737cf47 100644 (file)
@@ -338,7 +338,7 @@ static int vsense_proc_mult_write(struct file *file, const char __user *buffer,
                unsigned long count, void *data)
 {
        int *multiplier = data;
-       int ret, val;
+       int ret, val, adj;
 
        ret = vsense_proc_int_write(buffer, count, &val);
        if (ret < 0)
@@ -346,7 +346,10 @@ static int vsense_proc_mult_write(struct file *file, const char __user *buffer,
        if (val == 0)
                return -EINVAL;
 
-       *multiplier = val * 256 / 100;
+       /* round to higher absolute value */
+       adj = val < 0 ? -99 : 99;
+       *multiplier = (val * 256 + adj) / 100;
+
        return ret;
 }