Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 318196
b: refs/heads/master
c: b02f8be
h: refs/heads/master
v: v3
  • Loading branch information
NeilBrown authored and Greg Kroah-Hartman committed Jun 13, 2012
1 parent db2a764 commit 676813e
Show file tree
Hide file tree
Showing 18 changed files with 58 additions and 96 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b7e938d06d0de43bdbee8844a8736c81480c1031
refs/heads/master: b02f8bede217a4b145ecc16d3940c78d83941147
11 changes: 1 addition & 10 deletions trunk/drivers/power/ds2780_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ struct ds2780_device_info {
struct device *dev;
struct power_supply bat;
struct device *w1_dev;
struct task_struct *mutex_holder;
};

enum current_types {
Expand All @@ -64,10 +63,7 @@ static inline struct power_supply *to_power_supply(struct device *dev)
static inline int ds2780_battery_io(struct ds2780_device_info *dev_info,
char *buf, int addr, size_t count, int io)
{
if (dev_info->mutex_holder == current)
return w1_ds2780_io_nolock(dev_info->w1_dev, buf, addr, count, io);
else
return w1_ds2780_io(dev_info->w1_dev, buf, addr, count, io);
return w1_ds2780_io(dev_info->w1_dev, buf, addr, count, io);
}

static inline int ds2780_read8(struct ds2780_device_info *dev_info, u8 *val,
Expand Down Expand Up @@ -779,7 +775,6 @@ static int __devinit ds2780_battery_probe(struct platform_device *pdev)
dev_info->bat.properties = ds2780_battery_props;
dev_info->bat.num_properties = ARRAY_SIZE(ds2780_battery_props);
dev_info->bat.get_property = ds2780_battery_get_property;
dev_info->mutex_holder = current;

ret = power_supply_register(&pdev->dev, &dev_info->bat);
if (ret) {
Expand Down Expand Up @@ -809,8 +804,6 @@ static int __devinit ds2780_battery_probe(struct platform_device *pdev)
goto fail_remove_bin_file;
}

dev_info->mutex_holder = NULL;

return 0;

fail_remove_bin_file:
Expand All @@ -830,8 +823,6 @@ static int __devexit ds2780_battery_remove(struct platform_device *pdev)
{
struct ds2780_device_info *dev_info = platform_get_drvdata(pdev);

dev_info->mutex_holder = current;

/* remove attributes */
sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2780_attr_group);

Expand Down
12 changes: 1 addition & 11 deletions trunk/drivers/power/ds2781_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down Expand Up @@ -775,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) {
Expand Down Expand Up @@ -805,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:
Expand All @@ -826,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);

Expand Down
4 changes: 4 additions & 0 deletions trunk/drivers/w1/masters/ds1wm.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ static void ds1wm_search(void *data, struct w1_master *master_dev,
return;
}

mutex_lock(&master_dev->bus_mutex);
if (ds1wm_reset(ds1wm_data)) {
mutex_unlock(&master_dev->bus_mutex);
dev_dbg(&ds1wm_data->pdev->dev,
"pass: %d reset error (or no slaves)\n", pass);
break;
Expand Down Expand Up @@ -387,6 +389,7 @@ static void ds1wm_search(void *data, struct w1_master *master_dev,

}
if (ds1wm_data->read_error) {
mutex_unlock(&master_dev->bus_mutex);
dev_err(&ds1wm_data->pdev->dev,
"pass: %d read error, retrying\n", pass);
break;
Expand All @@ -400,6 +403,7 @@ static void ds1wm_search(void *data, struct w1_master *master_dev,
dev_dbg(&ds1wm_data->pdev->dev,
"pass: %d resetting bus\n", pass);
ds1wm_reset(ds1wm_data);
mutex_unlock(&master_dev->bus_mutex);
if ((r_prime & ((u64)1 << 63)) && (d & ((u64)1 << 63))) {
dev_err(&ds1wm_data->pdev->dev,
"pass: %d bus error, retrying\n", pass);
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/w1/slaves/w1_bq27000.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ static int w1_bq27000_read(struct device *dev, unsigned int reg)
u8 val;
struct w1_slave *sl = container_of(dev->parent, struct w1_slave, dev);

mutex_lock(&sl->master->mutex);
mutex_lock(&sl->master->bus_mutex);
w1_write_8(sl->master, HDQ_CMD_READ | reg);
val = w1_read_8(sl->master);
mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);

return val;
}
Expand Down
24 changes: 12 additions & 12 deletions trunk/drivers/w1/slaves/w1_ds2408.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ static int _read_reg(struct w1_slave *sl, u8 address, unsigned char* buf)
if (!buf)
return -EINVAL;

mutex_lock(&sl->master->mutex);
mutex_lock(&sl->master->bus_mutex);
dev_dbg(&sl->dev, "mutex locked");

if (w1_reset_select_slave(sl)) {
mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);
return -EIO;
}

Expand All @@ -66,7 +66,7 @@ static int _read_reg(struct w1_slave *sl, u8 address, unsigned char* buf)
w1_write_block(sl->master, wrbuf, 3);
*buf = w1_read_8(sl->master);

mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);
dev_dbg(&sl->dev, "mutex unlocked");
return 1;
}
Expand Down Expand Up @@ -165,7 +165,7 @@ static ssize_t w1_f29_write_output(
return -EFAULT;

dev_dbg(&sl->dev, "locking mutex for write_output");
mutex_lock(&sl->master->mutex);
mutex_lock(&sl->master->bus_mutex);
dev_dbg(&sl->dev, "mutex locked");

if (w1_reset_select_slave(sl))
Expand Down Expand Up @@ -200,14 +200,14 @@ static ssize_t w1_f29_write_output(
/* read the result of the READ_PIO_REGS command */
if (w1_read_8(sl->master) == *buf) {
/* success! */
mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);
dev_dbg(&sl->dev,
"mutex unlocked, retries:%d", retries);
return 1;
}
}
error:
mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);
dev_dbg(&sl->dev, "mutex unlocked in error, retries:%d", retries);

return -EIO;
Expand All @@ -228,23 +228,23 @@ static ssize_t w1_f29_write_activity(
if (count != 1 || off != 0)
return -EFAULT;

mutex_lock(&sl->master->mutex);
mutex_lock(&sl->master->bus_mutex);

if (w1_reset_select_slave(sl))
goto error;

while (retries--) {
w1_write_8(sl->master, W1_F29_FUNC_RESET_ACTIVITY_LATCHES);
if (w1_read_8(sl->master) == W1_F29_SUCCESS_CONFIRM_BYTE) {
mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);
return 1;
}
if (w1_reset_resume_command(sl->master))
goto error;
}

error:
mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);
return -EIO;
}

Expand All @@ -263,7 +263,7 @@ static ssize_t w1_f29_write_status_control(
if (count != 1 || off != 0)
return -EFAULT;

mutex_lock(&sl->master->mutex);
mutex_lock(&sl->master->bus_mutex);

if (w1_reset_select_slave(sl))
goto error;
Expand All @@ -285,12 +285,12 @@ static ssize_t w1_f29_write_status_control(
w1_write_block(sl->master, w1_buf, 3);
if (w1_read_8(sl->master) == *buf) {
/* success! */
mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);
return 1;
}
}
error:
mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);

return -EIO;
}
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/w1/slaves/w1_ds2423.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static ssize_t w1_counter_read(struct device *device,
wrbuf[0] = 0xA5;
wrbuf[1] = rom_addr & 0xFF;
wrbuf[2] = rom_addr >> 8;
mutex_lock(&dev->mutex);
mutex_lock(&dev->bus_mutex);
if (!w1_reset_select_slave(sl)) {
w1_write_block(dev, wrbuf, 3);
read_byte_count = 0;
Expand Down Expand Up @@ -124,7 +124,7 @@ static ssize_t w1_counter_read(struct device *device,
} else {
c -= snprintf(out_buf + PAGE_SIZE - c, c, "Connection error");
}
mutex_unlock(&dev->mutex);
mutex_unlock(&dev->bus_mutex);
return PAGE_SIZE - c;
}

Expand Down
8 changes: 4 additions & 4 deletions trunk/drivers/w1/slaves/w1_ds2431.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static ssize_t w1_f2d_read_bin(struct file *filp, struct kobject *kobj,
if (count == 0)
return 0;

mutex_lock(&sl->master->mutex);
mutex_lock(&sl->master->bus_mutex);

/* read directly from the EEPROM in chunks of W1_F2D_READ_MAXLEN */
while (todo > 0) {
Expand All @@ -126,7 +126,7 @@ static ssize_t w1_f2d_read_bin(struct file *filp, struct kobject *kobj,
off += W1_F2D_READ_MAXLEN;
}

mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);

return count;
}
Expand Down Expand Up @@ -214,7 +214,7 @@ static ssize_t w1_f2d_write_bin(struct file *filp, struct kobject *kobj,
if (count == 0)
return 0;

mutex_lock(&sl->master->mutex);
mutex_lock(&sl->master->bus_mutex);

/* Can only write data in blocks of the size of the scratchpad */
addr = off;
Expand Down Expand Up @@ -259,7 +259,7 @@ static ssize_t w1_f2d_write_bin(struct file *filp, struct kobject *kobj,
}

out_up:
mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);

return count;
}
Expand Down
8 changes: 4 additions & 4 deletions trunk/drivers/w1/slaves/w1_ds2433.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static ssize_t w1_f23_read_bin(struct file *filp, struct kobject *kobj,
if ((count = w1_f23_fix_count(off, count, W1_EEPROM_SIZE)) == 0)
return 0;

mutex_lock(&sl->master->mutex);
mutex_lock(&sl->master->bus_mutex);

#ifdef CONFIG_W1_SLAVE_DS2433_CRC

Expand Down Expand Up @@ -138,7 +138,7 @@ static ssize_t w1_f23_read_bin(struct file *filp, struct kobject *kobj,
#endif /* CONFIG_W1_SLAVE_DS2433_CRC */

out_up:
mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);

return count;
}
Expand Down Expand Up @@ -233,7 +233,7 @@ static ssize_t w1_f23_write_bin(struct file *filp, struct kobject *kobj,
}
#endif /* CONFIG_W1_SLAVE_DS2433_CRC */

mutex_lock(&sl->master->mutex);
mutex_lock(&sl->master->bus_mutex);

/* Can only write data to one page at a time */
idx = 0;
Expand All @@ -251,7 +251,7 @@ static ssize_t w1_f23_write_bin(struct file *filp, struct kobject *kobj,
}

out_up:
mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);

return count;
}
Expand Down
8 changes: 4 additions & 4 deletions trunk/drivers/w1/slaves/w1_ds2760.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static int w1_ds2760_io(struct device *dev, char *buf, int addr, size_t count,
if (!dev)
return 0;

mutex_lock(&sl->master->mutex);
mutex_lock(&sl->master->bus_mutex);

if (addr > DS2760_DATA_SIZE || addr < 0) {
count = 0;
Expand All @@ -54,7 +54,7 @@ static int w1_ds2760_io(struct device *dev, char *buf, int addr, size_t count,
}

out:
mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);

return count;
}
Expand All @@ -76,14 +76,14 @@ static int w1_ds2760_eeprom_cmd(struct device *dev, int addr, int cmd)
if (!dev)
return -EINVAL;

mutex_lock(&sl->master->mutex);
mutex_lock(&sl->master->bus_mutex);

if (w1_reset_select_slave(sl) == 0) {
w1_write_8(sl->master, cmd);
w1_write_8(sl->master, addr);
}

mutex_unlock(&sl->master->mutex);
mutex_unlock(&sl->master->bus_mutex);
return 0;
}

Expand Down
Loading

0 comments on commit 676813e

Please sign in to comment.