Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 28608
b: refs/heads/master
c: abd52a1
h: refs/heads/master
v: v3
  • Loading branch information
Evgeniy Polyakov authored and Greg Kroah-Hartman committed Jun 22, 2006
1 parent 2a1fb9e commit a24e1a1
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 128 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: 46e07f6e5eb0e465e086b8f485f4238bd453e3e9
refs/heads/master: abd52a13206e02537ca1dc08fc5438c7d27bdbf1
24 changes: 12 additions & 12 deletions trunk/drivers/w1/masters/ds2482.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ struct ds2482_w1_chan {

struct ds2482_data {
struct i2c_client client;
struct semaphore access_lock;
struct mutex access_lock;

/* 1-wire interface(s) */
int w1_count; /* 1 or 8 */
Expand Down Expand Up @@ -265,7 +265,7 @@ static u8 ds2482_w1_touch_bit(void *data, u8 bit)
struct ds2482_data *pdev = pchan->pdev;
int status = -1;

down(&pdev->access_lock);
mutex_lock(&pdev->access_lock);

/* Select the channel */
ds2482_wait_1wire_idle(pdev);
Expand All @@ -277,7 +277,7 @@ static u8 ds2482_w1_touch_bit(void *data, u8 bit)
bit ? 0xFF : 0))
status = ds2482_wait_1wire_idle(pdev);

up(&pdev->access_lock);
mutex_unlock(&pdev->access_lock);

return (status & DS2482_REG_STS_SBR) ? 1 : 0;
}
Expand All @@ -297,7 +297,7 @@ static u8 ds2482_w1_triplet(void *data, u8 dbit)
struct ds2482_data *pdev = pchan->pdev;
int status = (3 << 5);

down(&pdev->access_lock);
mutex_lock(&pdev->access_lock);

/* Select the channel */
ds2482_wait_1wire_idle(pdev);
Expand All @@ -309,7 +309,7 @@ static u8 ds2482_w1_triplet(void *data, u8 dbit)
dbit ? 0xFF : 0))
status = ds2482_wait_1wire_idle(pdev);

up(&pdev->access_lock);
mutex_unlock(&pdev->access_lock);

/* Decode the status */
return (status >> 5);
Expand All @@ -326,7 +326,7 @@ static void ds2482_w1_write_byte(void *data, u8 byte)
struct ds2482_w1_chan *pchan = data;
struct ds2482_data *pdev = pchan->pdev;

down(&pdev->access_lock);
mutex_lock(&pdev->access_lock);

/* Select the channel */
ds2482_wait_1wire_idle(pdev);
Expand All @@ -336,7 +336,7 @@ static void ds2482_w1_write_byte(void *data, u8 byte)
/* Send the write byte command */
ds2482_send_cmd_data(pdev, DS2482_CMD_1WIRE_WRITE_BYTE, byte);

up(&pdev->access_lock);
mutex_unlock(&pdev->access_lock);
}

/**
Expand All @@ -351,7 +351,7 @@ static u8 ds2482_w1_read_byte(void *data)
struct ds2482_data *pdev = pchan->pdev;
int result;

down(&pdev->access_lock);
mutex_lock(&pdev->access_lock);

/* Select the channel */
ds2482_wait_1wire_idle(pdev);
Expand All @@ -370,7 +370,7 @@ static u8 ds2482_w1_read_byte(void *data)
/* Read the data byte */
result = i2c_smbus_read_byte(&pdev->client);

up(&pdev->access_lock);
mutex_unlock(&pdev->access_lock);

return result;
}
Expand All @@ -389,7 +389,7 @@ static u8 ds2482_w1_reset_bus(void *data)
int err;
u8 retval = 1;

down(&pdev->access_lock);
mutex_lock(&pdev->access_lock);

/* Select the channel */
ds2482_wait_1wire_idle(pdev);
Expand All @@ -409,7 +409,7 @@ static u8 ds2482_w1_reset_bus(void *data)
0xF0);
}

up(&pdev->access_lock);
mutex_unlock(&pdev->access_lock);

return retval;
}
Expand Down Expand Up @@ -482,7 +482,7 @@ static int ds2482_detect(struct i2c_adapter *adapter, int address, int kind)
snprintf(new_client->name, sizeof(new_client->name), "ds2482-%d00",
data->w1_count);

init_MUTEX(&data->access_lock);
mutex_init(&data->access_lock);

/* Tell the I2C layer a new client has arrived */
if ((err = i2c_attach_client(new_client)))
Expand Down
10 changes: 5 additions & 5 deletions trunk/drivers/w1/masters/ds2490.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ static int ds_send_control(struct ds_device *, u16, u16);
static int ds_send_control_cmd(struct ds_device *, u16, u16);

static LIST_HEAD(ds_devices);
static DECLARE_MUTEX(ds_mutex);
static DEFINE_MUTEX(ds_mutex);

static struct usb_driver ds_driver = {
.name = "DS9490R",
Expand Down Expand Up @@ -887,9 +887,9 @@ static int ds_probe(struct usb_interface *intf,
if (err)
goto err_out_clear;

down(&ds_mutex);
mutex_lock(&ds_mutex);
list_add_tail(&dev->ds_entry, &ds_devices);
up(&ds_mutex);
mutex_unlock(&ds_mutex);

return 0;

Expand All @@ -909,9 +909,9 @@ static void ds_disconnect(struct usb_interface *intf)
if (!dev)
return;

down(&ds_mutex);
mutex_lock(&ds_mutex);
list_del(&dev->ds_entry);
up(&ds_mutex);
mutex_unlock(&ds_mutex);

ds_w1_fini(dev);

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

atomic_inc(&sl->refcnt);
if (down_interruptible(&sl->master->mutex)) {
count = 0;
goto out_dec;
}
mutex_lock(&sl->master->mutex);

#ifdef CONFIG_W1_F23_CRC

Expand Down Expand Up @@ -140,9 +136,7 @@ static ssize_t w1_f23_read_bin(struct kobject *kobj, char *buf, loff_t off,
#endif /* CONFIG_W1_F23_CRC */

out_up:
up(&sl->master->mutex);
out_dec:
atomic_dec(&sl->refcnt);
mutex_unlock(&sl->master->mutex);

return count;
}
Expand Down Expand Up @@ -231,11 +225,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off,
}
#endif /* CONFIG_W1_F23_CRC */

atomic_inc(&sl->refcnt);
if (down_interruptible(&sl->master->mutex)) {
count = 0;
goto out_dec;
}
mutex_lock(&sl->master->mutex);

/* Can only write data to one page at a time */
idx = 0;
Expand All @@ -253,9 +243,7 @@ static ssize_t w1_f23_write_bin(struct kobject *kobj, char *buf, loff_t off,
}

out_up:
up(&sl->master->mutex);
out_dec:
atomic_dec(&sl->refcnt);
mutex_unlock(&sl->master->mutex);

return count;
}
Expand Down
12 changes: 2 additions & 10 deletions trunk/drivers/w1/slaves/w1_therm.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si
u8 rom[9], crc, verdict;
int i, max_trying = 10;

atomic_inc(&sl->refcnt);
smp_mb__after_atomic_inc();
if (down_interruptible(&sl->master->mutex)) {
count = 0;
goto out_dec;
}
mutex_lock(&sl->master->mutex);

if (off > W1_SLAVE_DATA_SIZE) {
count = 0;
Expand Down Expand Up @@ -233,10 +228,7 @@ static ssize_t w1_therm_read_bin(struct kobject *kobj, char *buf, loff_t off, si

count += sprintf(buf + count, "t=%d\n", w1_convert_temp(rom, sl->family->fid));
out:
up(&dev->mutex);
out_dec:
smp_mb__before_atomic_inc();
atomic_dec(&sl->refcnt);
mutex_unlock(&dev->mutex);

return count;
}
Expand Down
Loading

0 comments on commit a24e1a1

Please sign in to comment.