Merge tag 'spi-3.6' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc
[deliverable/linux.git] / drivers / power / ds2781_battery.c
index ca0d653d0a7a2c3ac0d4c422f66317c3993dc49b..5f92a4bb33f95aaafe772c3aeea1b2bc54a00186 100644 (file)
@@ -37,7 +37,6 @@ struct ds2781_device_info {
        struct device *dev;
        struct power_supply bat;
        struct device *w1_dev;
-       struct task_struct *mutex_holder;
 };
 
 enum current_types {
@@ -62,11 +61,7 @@ static inline struct power_supply *to_power_supply(struct device *dev)
 static inline int ds2781_battery_io(struct ds2781_device_info *dev_info,
        char *buf, int addr, size_t count, int io)
 {
-       if (dev_info->mutex_holder == current)
-               return w1_ds2781_io_nolock(dev_info->w1_dev, buf, addr,
-                               count, io);
-       else
-               return w1_ds2781_io(dev_info->w1_dev, buf, addr, count, io);
+       return w1_ds2781_io(dev_info->w1_dev, buf, addr, count, io);
 }
 
 int w1_ds2781_read(struct ds2781_device_info *dev_info, char *buf,
@@ -643,9 +638,7 @@ static ssize_t ds2781_read_param_eeprom_bin(struct file *filp,
        struct power_supply *psy = to_power_supply(dev);
        struct ds2781_device_info *dev_info = to_ds2781_device_info(psy);
 
-       count = min_t(loff_t, count,
-               DS2781_EEPROM_BLOCK1_END -
-               DS2781_EEPROM_BLOCK1_START + 1 - off);
+       count = min_t(loff_t, count, DS2781_PARAM_EEPROM_SIZE - off);
 
        return ds2781_read_block(dev_info, buf,
                                DS2781_EEPROM_BLOCK1_START + off, count);
@@ -661,9 +654,7 @@ static ssize_t ds2781_write_param_eeprom_bin(struct file *filp,
        struct ds2781_device_info *dev_info = to_ds2781_device_info(psy);
        int ret;
 
-       count = min_t(loff_t, count,
-               DS2781_EEPROM_BLOCK1_END -
-               DS2781_EEPROM_BLOCK1_START + 1 - off);
+       count = min_t(loff_t, count, DS2781_PARAM_EEPROM_SIZE - off);
 
        ret = ds2781_write(dev_info, buf,
                                DS2781_EEPROM_BLOCK1_START + off, count);
@@ -682,7 +673,7 @@ static struct bin_attribute ds2781_param_eeprom_bin_attr = {
                .name = "param_eeprom",
                .mode = S_IRUGO | S_IWUSR,
        },
-       .size = DS2781_EEPROM_BLOCK1_END - DS2781_EEPROM_BLOCK1_START + 1,
+       .size = DS2781_PARAM_EEPROM_SIZE,
        .read = ds2781_read_param_eeprom_bin,
        .write = ds2781_write_param_eeprom_bin,
 };
@@ -696,9 +687,7 @@ static ssize_t ds2781_read_user_eeprom_bin(struct file *filp,
        struct power_supply *psy = to_power_supply(dev);
        struct ds2781_device_info *dev_info = to_ds2781_device_info(psy);
 
-       count = min_t(loff_t, count,
-               DS2781_EEPROM_BLOCK0_END -
-               DS2781_EEPROM_BLOCK0_START + 1 - off);
+       count = min_t(loff_t, count, DS2781_USER_EEPROM_SIZE - off);
 
        return ds2781_read_block(dev_info, buf,
                                DS2781_EEPROM_BLOCK0_START + off, count);
@@ -715,9 +704,7 @@ static ssize_t ds2781_write_user_eeprom_bin(struct file *filp,
        struct ds2781_device_info *dev_info = to_ds2781_device_info(psy);
        int ret;
 
-       count = min_t(loff_t, count,
-               DS2781_EEPROM_BLOCK0_END -
-               DS2781_EEPROM_BLOCK0_START + 1 - off);
+       count = min_t(loff_t, count, DS2781_USER_EEPROM_SIZE - off);
 
        ret = ds2781_write(dev_info, buf,
                                DS2781_EEPROM_BLOCK0_START + off, count);
@@ -736,7 +723,7 @@ static struct bin_attribute ds2781_user_eeprom_bin_attr = {
                .name = "user_eeprom",
                .mode = S_IRUGO | S_IWUSR,
        },
-       .size = DS2781_EEPROM_BLOCK0_END - DS2781_EEPROM_BLOCK0_START + 1,
+       .size = DS2781_USER_EEPROM_SIZE,
        .read = ds2781_read_user_eeprom_bin,
        .write = ds2781_write_user_eeprom_bin,
 };
@@ -783,7 +770,6 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
        dev_info->bat.properties        = ds2781_battery_props;
        dev_info->bat.num_properties    = ARRAY_SIZE(ds2781_battery_props);
        dev_info->bat.get_property      = ds2781_battery_get_property;
-       dev_info->mutex_holder          = current;
 
        ret = power_supply_register(&pdev->dev, &dev_info->bat);
        if (ret) {
@@ -813,8 +799,6 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
                goto fail_remove_bin_file;
        }
 
-       dev_info->mutex_holder = NULL;
-
        return 0;
 
 fail_remove_bin_file:
@@ -834,8 +818,6 @@ static int __devexit ds2781_battery_remove(struct platform_device *pdev)
 {
        struct ds2781_device_info *dev_info = platform_get_drvdata(pdev);
 
-       dev_info->mutex_holder = current;
-
        /* remove attributes */
        sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2781_attr_group);
 
This page took 0.033519 seconds and 5 git commands to generate.