+static ssize_t show_end_of_charge_current(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct power_supply *psy = dev_get_drvdata(dev);
+ struct twl4030_bci *bci = dev_get_drvdata(psy->dev->parent);
+ int ret, eoc_current;
+
+ if ((ret = twl4030bci_get_eoc_current(bci, &eoc_current)))
+ return ret;
+
+ return sprintf(buf, "%d\n", eoc_current);
+}
+
+static ssize_t store_end_of_charge_current(struct device *dev,
+ struct device_attribute *attr, const char *buf,
+ size_t count)
+{
+ struct power_supply *psy = dev_get_drvdata(dev);
+ struct twl4030_bci *bci = dev_get_drvdata(psy->dev->parent);
+ unsigned long new_eoc_current;
+ int eoc_current, ret;
+
+ ret = strict_strtoul(buf, 10, &new_eoc_current);
+ if (ret)
+ return -EINVAL;
+
+ eoc_current = new_eoc_current;
+ /* check for overflow */
+ if (eoc_current != new_eoc_current)
+ return -EINVAL;
+
+ if ((ret = update_charge_parameters(bci, -1, eoc_current)))
+ return ret;
+
+ return count;
+}
+
+static DEVICE_ATTR(end_of_charge_current, S_IRUGO | S_IWUSR,
+ show_end_of_charge_current, store_end_of_charge_current);
+