aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/w1/masters/ds2490.c
diff options
context:
space:
mode:
authorDavid Fries <david@fries.net>2008-10-16 01:05:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-16 14:21:51 -0400
commite464af24734c40853dd68ec694d83a82e3930d66 (patch)
tree732fdf15dbe1bed0930c8db2c326d9f4c9347b04 /drivers/w1/masters/ds2490.c
parent7a4b9706ed762373f74311f96f5122fb74212192 (diff)
W1: ds2490.c reset ds2490 in init
Reset the device in init 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. Signed-off-by: David Fries <david@fries.net> Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/w1/masters/ds2490.c')
-rw-r--r--drivers/w1/masters/ds2490.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/w1/masters/ds2490.c b/drivers/w1/masters/ds2490.c
index 9a7fd71e1461..0f356939b349 100644
--- a/drivers/w1/masters/ds2490.c
+++ b/drivers/w1/masters/ds2490.c
@@ -316,6 +316,15 @@ static int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size)
316 int count, err; 316 int count, err;
317 struct ds_status st; 317 struct ds_status st;
318 318
319 /* Careful on size. If size is less than what is available in
320 * the input buffer, the device fails the bulk transfer and
321 * clears the input buffer. It could read the maximum size of
322 * the data buffer, but then do you return the first, last, or
323 * some set of the middle size bytes? As long as the rest of
324 * the code is correct there will be size bytes waiting. A
325 * call to ds_wait_status will wait until the device is idle
326 * and any data to be received would have been available.
327 */
319 count = 0; 328 count = 0;
320 err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]), 329 err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]),
321 buf, size, &count, 1000); 330 buf, size, &count, 1000);
@@ -824,6 +833,18 @@ static int ds_w1_init(struct ds_device *dev)
824{ 833{
825 memset(&dev->master, 0, sizeof(struct w1_bus_master)); 834 memset(&dev->master, 0, sizeof(struct w1_bus_master));
826 835
836 /* Reset the device as it can be in a bad state.
837 * This is necessary because a block write will wait for data
838 * to be placed in the output buffer and block any later
839 * commands which will keep accumulating and the device will
840 * not be idle. Another case is removing the ds2490 module
841 * while a bus search is in progress, somehow a few commands
842 * get through, but the input transfers fail leaving data in
843 * the input buffer. This will cause the next read to fail
844 * see the note in ds_recv_data.
845 */
846 ds_send_control_cmd(dev, CTL_RESET_DEVICE, 0);
847
827 dev->master.data = dev; 848 dev->master.data = dev;
828 dev->master.touch_bit = &ds9490r_touch_bit; 849 dev->master.touch_bit = &ds9490r_touch_bit;
829 /* read_bit and write_bit in w1_bus_master are expected to set and 850 /* read_bit and write_bit in w1_bus_master are expected to set and