Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 114939
b: refs/heads/master
c: e464af2
h: refs/heads/master
i:
  114937: 190330c
  114935: 502d7f5
v: v3
  • Loading branch information
David Fries authored and Linus Torvalds committed Oct 16, 2008
1 parent 2effdc2 commit b72cb6c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7a4b9706ed762373f74311f96f5122fb74212192
refs/heads/master: e464af24734c40853dd68ec694d83a82e3930d66
21 changes: 21 additions & 0 deletions trunk/drivers/w1/masters/ds2490.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@ static int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size)
int count, err;
struct ds_status st;

/* Careful on size. If size is less than what is available in
* the input buffer, the device fails the bulk transfer and
* clears the input buffer. It could read the maximum size of
* the data buffer, but then do you return the first, last, or
* some set of the middle size bytes? As long as the rest of
* the code is correct there will be size bytes waiting. A
* call to ds_wait_status will wait until the device is idle
* and any data to be received would have been available.
*/
count = 0;
err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]),
buf, size, &count, 1000);
Expand Down Expand Up @@ -824,6 +833,18 @@ static int ds_w1_init(struct ds_device *dev)
{
memset(&dev->master, 0, sizeof(struct w1_bus_master));

/* Reset the device as it can be in a bad state.
* This is necessary because a block write will wait for data
* to be placed in the output buffer and block any later
* commands which will keep accumulating and the device will
* not be idle. Another case is removing the ds2490 module
* while a bus search is in progress, somehow a few commands
* get through, but the input transfers fail leaving data in
* the input buffer. This will cause the next read to fail
* see the note in ds_recv_data.
*/
ds_send_control_cmd(dev, CTL_RESET_DEVICE, 0);

dev->master.data = dev;
dev->master.touch_bit = &ds9490r_touch_bit;
/* read_bit and write_bit in w1_bus_master are expected to set and
Expand Down

0 comments on commit b72cb6c

Please sign in to comment.