twl4030_charger: Filter charge_current values under 1024
[pandora-kernel.git] / drivers / power / twl4030_charger.c
index 4cd0fcd..8ff3f29 100644 (file)
@@ -706,6 +706,19 @@ static ssize_t store_charge_current(struct device *dev,
        if (ret)
                return -EINVAL;
 
+       /*
+        * Previously, this sysfs parameter used a different raw-register
+        * format. All legal values in this format fall numerically into the
+        * range [0, 1023]. Since in the new format, these encode values so
+        * low as to be meaningless, reject them here so that anybody trying
+        * to use the old format will have at least a chance of figuring out
+        * why it isn't working any more. Note that in both formats, the value
+        * 0 has the same meaning, so it is allowed where values in the range
+        * [1, 1023] are not.
+        */
+       if (new_current < 1024 && new_current != 0)
+               return -EINVAL;
+
        ret = update_charge_parameters(bci, new_current, -1);
        if (ret)
                return ret;