diff options
author | Evgeniy Polyakov <johnpol@2ka.mipt.ru> | 2005-08-03 07:14:50 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2005-09-08 17:41:26 -0400 |
commit | 8949d2aa05ddf5e9a31d738568a79915970cb38e (patch) | |
tree | bb5c18d4a5ff014a4a521fb5817ad231e8d0c81f /drivers/w1/dscore.c | |
parent | 2d8331792ea3f5ccfd147288afba148537337019 (diff) |
[PATCH] W1: Sync with w1/ds9490 tree.
Whitespace, static/nonstatic cleanups.
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/w1/dscore.c')
-rw-r--r-- | drivers/w1/dscore.c | 161 |
1 files changed, 84 insertions, 77 deletions
diff --git a/drivers/w1/dscore.c b/drivers/w1/dscore.c index eee6644d33d6..15fb250451e5 100644 --- a/drivers/w1/dscore.c +++ b/drivers/w1/dscore.c | |||
@@ -1,8 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * dscore.c | 2 | * dscore.c |
3 | * | 3 | * |
4 | * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> | 4 | * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru> |
5 | * | 5 | * |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by | 8 | * it under the terms of the GNU General Public License as published by |
@@ -32,19 +32,16 @@ static struct usb_device_id ds_id_table [] = { | |||
32 | }; | 32 | }; |
33 | MODULE_DEVICE_TABLE(usb, ds_id_table); | 33 | MODULE_DEVICE_TABLE(usb, ds_id_table); |
34 | 34 | ||
35 | int ds_probe(struct usb_interface *, const struct usb_device_id *); | 35 | static int ds_probe(struct usb_interface *, const struct usb_device_id *); |
36 | void ds_disconnect(struct usb_interface *); | 36 | static void ds_disconnect(struct usb_interface *); |
37 | 37 | ||
38 | int ds_touch_bit(struct ds_device *, u8, u8 *); | 38 | int ds_touch_bit(struct ds_device *, u8, u8 *); |
39 | int ds_read_byte(struct ds_device *, u8 *); | 39 | int ds_read_byte(struct ds_device *, u8 *); |
40 | int ds_read_bit(struct ds_device *, u8 *); | 40 | int ds_read_bit(struct ds_device *, u8 *); |
41 | int ds_write_byte(struct ds_device *, u8); | 41 | int ds_write_byte(struct ds_device *, u8); |
42 | int ds_write_bit(struct ds_device *, u8); | 42 | int ds_write_bit(struct ds_device *, u8); |
43 | int ds_start_pulse(struct ds_device *, int); | 43 | static int ds_start_pulse(struct ds_device *, int); |
44 | int ds_set_speed(struct ds_device *, int); | ||
45 | int ds_reset(struct ds_device *, struct ds_status *); | 44 | int ds_reset(struct ds_device *, struct ds_status *); |
46 | int ds_detect(struct ds_device *, struct ds_status *); | ||
47 | int ds_stop_pulse(struct ds_device *, int); | ||
48 | struct ds_device * ds_get_device(void); | 45 | struct ds_device * ds_get_device(void); |
49 | void ds_put_device(struct ds_device *); | 46 | void ds_put_device(struct ds_device *); |
50 | 47 | ||
@@ -79,11 +76,11 @@ void ds_put_device(struct ds_device *dev) | |||
79 | static int ds_send_control_cmd(struct ds_device *dev, u16 value, u16 index) | 76 | static int ds_send_control_cmd(struct ds_device *dev, u16 value, u16 index) |
80 | { | 77 | { |
81 | int err; | 78 | int err; |
82 | 79 | ||
83 | err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), | 80 | err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), |
84 | CONTROL_CMD, 0x40, value, index, NULL, 0, 1000); | 81 | CONTROL_CMD, 0x40, value, index, NULL, 0, 1000); |
85 | if (err < 0) { | 82 | if (err < 0) { |
86 | printk(KERN_ERR "Failed to send command control message %x.%x: err=%d.\n", | 83 | printk(KERN_ERR "Failed to send command control message %x.%x: err=%d.\n", |
87 | value, index, err); | 84 | value, index, err); |
88 | return err; | 85 | return err; |
89 | } | 86 | } |
@@ -94,11 +91,11 @@ static int ds_send_control_cmd(struct ds_device *dev, u16 value, u16 index) | |||
94 | static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index) | 91 | static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index) |
95 | { | 92 | { |
96 | int err; | 93 | int err; |
97 | 94 | ||
98 | err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), | 95 | err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), |
99 | MODE_CMD, 0x40, value, index, NULL, 0, 1000); | 96 | MODE_CMD, 0x40, value, index, NULL, 0, 1000); |
100 | if (err < 0) { | 97 | if (err < 0) { |
101 | printk(KERN_ERR "Failed to send mode control message %x.%x: err=%d.\n", | 98 | printk(KERN_ERR "Failed to send mode control message %x.%x: err=%d.\n", |
102 | value, index, err); | 99 | value, index, err); |
103 | return err; | 100 | return err; |
104 | } | 101 | } |
@@ -109,11 +106,11 @@ static int ds_send_control_mode(struct ds_device *dev, u16 value, u16 index) | |||
109 | static int ds_send_control(struct ds_device *dev, u16 value, u16 index) | 106 | static int ds_send_control(struct ds_device *dev, u16 value, u16 index) |
110 | { | 107 | { |
111 | int err; | 108 | int err; |
112 | 109 | ||
113 | err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), | 110 | err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, dev->ep[EP_CONTROL]), |
114 | COMM_CMD, 0x40, value, index, NULL, 0, 1000); | 111 | COMM_CMD, 0x40, value, index, NULL, 0, 1000); |
115 | if (err < 0) { | 112 | if (err < 0) { |
116 | printk(KERN_ERR "Failed to send control message %x.%x: err=%d.\n", | 113 | printk(KERN_ERR "Failed to send control message %x.%x: err=%d.\n", |
117 | value, index, err); | 114 | value, index, err); |
118 | return err; | 115 | return err; |
119 | } | 116 | } |
@@ -126,19 +123,20 @@ static inline void ds_dump_status(unsigned char *buf, unsigned char *str, int of | |||
126 | printk("%45s: %8x\n", str, buf[off]); | 123 | printk("%45s: %8x\n", str, buf[off]); |
127 | } | 124 | } |
128 | 125 | ||
129 | int ds_recv_status_nodump(struct ds_device *dev, struct ds_status *st, unsigned char *buf, int size) | 126 | static int ds_recv_status_nodump(struct ds_device *dev, struct ds_status *st, |
127 | unsigned char *buf, int size) | ||
130 | { | 128 | { |
131 | int count, err; | 129 | int count, err; |
132 | 130 | ||
133 | memset(st, 0, sizeof(st)); | 131 | memset(st, 0, sizeof(st)); |
134 | 132 | ||
135 | count = 0; | 133 | count = 0; |
136 | err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_STATUS]), buf, size, &count, 100); | 134 | err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_STATUS]), buf, size, &count, 100); |
137 | if (err < 0) { | 135 | if (err < 0) { |
138 | printk(KERN_ERR "Failed to read 1-wire data from 0x%x: err=%d.\n", dev->ep[EP_STATUS], err); | 136 | printk(KERN_ERR "Failed to read 1-wire data from 0x%x: err=%d.\n", dev->ep[EP_STATUS], err); |
139 | return err; | 137 | return err; |
140 | } | 138 | } |
141 | 139 | ||
142 | if (count >= sizeof(*st)) | 140 | if (count >= sizeof(*st)) |
143 | memcpy(st, buf, sizeof(*st)); | 141 | memcpy(st, buf, sizeof(*st)); |
144 | 142 | ||
@@ -149,13 +147,13 @@ static int ds_recv_status(struct ds_device *dev, struct ds_status *st) | |||
149 | { | 147 | { |
150 | unsigned char buf[64]; | 148 | unsigned char buf[64]; |
151 | int count, err = 0, i; | 149 | int count, err = 0, i; |
152 | 150 | ||
153 | memcpy(st, buf, sizeof(*st)); | 151 | memcpy(st, buf, sizeof(*st)); |
154 | 152 | ||
155 | count = ds_recv_status_nodump(dev, st, buf, sizeof(buf)); | 153 | count = ds_recv_status_nodump(dev, st, buf, sizeof(buf)); |
156 | if (count < 0) | 154 | if (count < 0) |
157 | return err; | 155 | return err; |
158 | 156 | ||
159 | printk("0x%x: count=%d, status: ", dev->ep[EP_STATUS], count); | 157 | printk("0x%x: count=%d, status: ", dev->ep[EP_STATUS], count); |
160 | for (i=0; i<count; ++i) | 158 | for (i=0; i<count; ++i) |
161 | printk("%02x ", buf[i]); | 159 | printk("%02x ", buf[i]); |
@@ -199,7 +197,7 @@ static int ds_recv_status(struct ds_device *dev, struct ds_status *st) | |||
199 | return err; | 197 | return err; |
200 | } | 198 | } |
201 | #endif | 199 | #endif |
202 | 200 | ||
203 | return err; | 201 | return err; |
204 | } | 202 | } |
205 | 203 | ||
@@ -207,9 +205,9 @@ static int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size) | |||
207 | { | 205 | { |
208 | int count, err; | 206 | int count, err; |
209 | struct ds_status st; | 207 | struct ds_status st; |
210 | 208 | ||
211 | count = 0; | 209 | count = 0; |
212 | err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]), | 210 | err = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, dev->ep[EP_DATA_IN]), |
213 | buf, size, &count, 1000); | 211 | buf, size, &count, 1000); |
214 | if (err < 0) { | 212 | if (err < 0) { |
215 | printk(KERN_INFO "Clearing ep0x%x.\n", dev->ep[EP_DATA_IN]); | 213 | printk(KERN_INFO "Clearing ep0x%x.\n", dev->ep[EP_DATA_IN]); |
@@ -234,7 +232,7 @@ static int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size) | |||
234 | static int ds_send_data(struct ds_device *dev, unsigned char *buf, int len) | 232 | static int ds_send_data(struct ds_device *dev, unsigned char *buf, int len) |
235 | { | 233 | { |
236 | int count, err; | 234 | int count, err; |
237 | 235 | ||
238 | count = 0; | 236 | count = 0; |
239 | err = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, dev->ep[EP_DATA_OUT]), buf, len, &count, 1000); | 237 | err = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, dev->ep[EP_DATA_OUT]), buf, len, &count, 1000); |
240 | if (err < 0) { | 238 | if (err < 0) { |
@@ -245,12 +243,14 @@ static int ds_send_data(struct ds_device *dev, unsigned char *buf, int len) | |||
245 | return err; | 243 | return err; |
246 | } | 244 | } |
247 | 245 | ||
246 | #if 0 | ||
247 | |||
248 | int ds_stop_pulse(struct ds_device *dev, int limit) | 248 | int ds_stop_pulse(struct ds_device *dev, int limit) |
249 | { | 249 | { |
250 | struct ds_status st; | 250 | struct ds_status st; |
251 | int count = 0, err = 0; | 251 | int count = 0, err = 0; |
252 | u8 buf[0x20]; | 252 | u8 buf[0x20]; |
253 | 253 | ||
254 | do { | 254 | do { |
255 | err = ds_send_control(dev, CTL_HALT_EXE_IDLE, 0); | 255 | err = ds_send_control(dev, CTL_HALT_EXE_IDLE, 0); |
256 | if (err) | 256 | if (err) |
@@ -275,7 +275,7 @@ int ds_stop_pulse(struct ds_device *dev, int limit) | |||
275 | int ds_detect(struct ds_device *dev, struct ds_status *st) | 275 | int ds_detect(struct ds_device *dev, struct ds_status *st) |
276 | { | 276 | { |
277 | int err; | 277 | int err; |
278 | 278 | ||
279 | err = ds_send_control_cmd(dev, CTL_RESET_DEVICE, 0); | 279 | err = ds_send_control_cmd(dev, CTL_RESET_DEVICE, 0); |
280 | if (err) | 280 | if (err) |
281 | return err; | 281 | return err; |
@@ -283,11 +283,11 @@ int ds_detect(struct ds_device *dev, struct ds_status *st) | |||
283 | err = ds_send_control(dev, COMM_SET_DURATION | COMM_IM, 0); | 283 | err = ds_send_control(dev, COMM_SET_DURATION | COMM_IM, 0); |
284 | if (err) | 284 | if (err) |
285 | return err; | 285 | return err; |
286 | 286 | ||
287 | err = ds_send_control(dev, COMM_SET_DURATION | COMM_IM | COMM_TYPE, 0x40); | 287 | err = ds_send_control(dev, COMM_SET_DURATION | COMM_IM | COMM_TYPE, 0x40); |
288 | if (err) | 288 | if (err) |
289 | return err; | 289 | return err; |
290 | 290 | ||
291 | err = ds_send_control_mode(dev, MOD_PULSE_EN, PULSE_PROG); | 291 | err = ds_send_control_mode(dev, MOD_PULSE_EN, PULSE_PROG); |
292 | if (err) | 292 | if (err) |
293 | return err; | 293 | return err; |
@@ -297,7 +297,9 @@ int ds_detect(struct ds_device *dev, struct ds_status *st) | |||
297 | return err; | 297 | return err; |
298 | } | 298 | } |
299 | 299 | ||
300 | int ds_wait_status(struct ds_device *dev, struct ds_status *st) | 300 | #endif /* 0 */ |
301 | |||
302 | static int ds_wait_status(struct ds_device *dev, struct ds_status *st) | ||
301 | { | 303 | { |
302 | u8 buf[0x20]; | 304 | u8 buf[0x20]; |
303 | int err, count = 0; | 305 | int err, count = 0; |
@@ -305,7 +307,7 @@ int ds_wait_status(struct ds_device *dev, struct ds_status *st) | |||
305 | do { | 307 | do { |
306 | err = ds_recv_status_nodump(dev, st, buf, sizeof(buf)); | 308 | err = ds_recv_status_nodump(dev, st, buf, sizeof(buf)); |
307 | #if 0 | 309 | #if 0 |
308 | if (err >= 0) { | 310 | if (err >= 0) { |
309 | int i; | 311 | int i; |
310 | printk("0x%x: count=%d, status: ", dev->ep[EP_STATUS], err); | 312 | printk("0x%x: count=%d, status: ", dev->ep[EP_STATUS], err); |
311 | for (i=0; i<err; ++i) | 313 | for (i=0; i<err; ++i) |
@@ -319,10 +321,8 @@ int ds_wait_status(struct ds_device *dev, struct ds_status *st) | |||
319 | if (((err > 16) && (buf[0x10] & 0x01)) || count >= 100 || err < 0) { | 321 | if (((err > 16) && (buf[0x10] & 0x01)) || count >= 100 || err < 0) { |
320 | ds_recv_status(dev, st); | 322 | ds_recv_status(dev, st); |
321 | return -1; | 323 | return -1; |
322 | } | 324 | } else |
323 | else { | ||
324 | return 0; | 325 | return 0; |
325 | } | ||
326 | } | 326 | } |
327 | 327 | ||
328 | int ds_reset(struct ds_device *dev, struct ds_status *st) | 328 | int ds_reset(struct ds_device *dev, struct ds_status *st) |
@@ -345,6 +345,7 @@ int ds_reset(struct ds_device *dev, struct ds_status *st) | |||
345 | return 0; | 345 | return 0; |
346 | } | 346 | } |
347 | 347 | ||
348 | #if 0 | ||
348 | int ds_set_speed(struct ds_device *dev, int speed) | 349 | int ds_set_speed(struct ds_device *dev, int speed) |
349 | { | 350 | { |
350 | int err; | 351 | int err; |
@@ -356,20 +357,21 @@ int ds_set_speed(struct ds_device *dev, int speed) | |||
356 | speed = SPEED_FLEXIBLE; | 357 | speed = SPEED_FLEXIBLE; |
357 | 358 | ||
358 | speed &= 0xff; | 359 | speed &= 0xff; |
359 | 360 | ||
360 | err = ds_send_control_mode(dev, MOD_1WIRE_SPEED, speed); | 361 | err = ds_send_control_mode(dev, MOD_1WIRE_SPEED, speed); |
361 | if (err) | 362 | if (err) |
362 | return err; | 363 | return err; |
363 | 364 | ||
364 | return err; | 365 | return err; |
365 | } | 366 | } |
367 | #endif /* 0 */ | ||
366 | 368 | ||
367 | int ds_start_pulse(struct ds_device *dev, int delay) | 369 | static int ds_start_pulse(struct ds_device *dev, int delay) |
368 | { | 370 | { |
369 | int err; | 371 | int err; |
370 | u8 del = 1 + (u8)(delay >> 4); | 372 | u8 del = 1 + (u8)(delay >> 4); |
371 | struct ds_status st; | 373 | struct ds_status st; |
372 | 374 | ||
373 | #if 0 | 375 | #if 0 |
374 | err = ds_stop_pulse(dev, 10); | 376 | err = ds_stop_pulse(dev, 10); |
375 | if (err) | 377 | if (err) |
@@ -390,7 +392,7 @@ int ds_start_pulse(struct ds_device *dev, int delay) | |||
390 | mdelay(delay); | 392 | mdelay(delay); |
391 | 393 | ||
392 | ds_wait_status(dev, &st); | 394 | ds_wait_status(dev, &st); |
393 | 395 | ||
394 | return err; | 396 | return err; |
395 | } | 397 | } |
396 | 398 | ||
@@ -400,7 +402,7 @@ int ds_touch_bit(struct ds_device *dev, u8 bit, u8 *tbit) | |||
400 | struct ds_status st; | 402 | struct ds_status st; |
401 | u16 value = (COMM_BIT_IO | COMM_IM) | ((bit) ? COMM_D : 0); | 403 | u16 value = (COMM_BIT_IO | COMM_IM) | ((bit) ? COMM_D : 0); |
402 | u16 cmd; | 404 | u16 cmd; |
403 | 405 | ||
404 | err = ds_send_control(dev, value, 0); | 406 | err = ds_send_control(dev, value, 0); |
405 | if (err) | 407 | if (err) |
406 | return err; | 408 | return err; |
@@ -430,7 +432,7 @@ int ds_write_bit(struct ds_device *dev, u8 bit) | |||
430 | { | 432 | { |
431 | int err; | 433 | int err; |
432 | struct ds_status st; | 434 | struct ds_status st; |
433 | 435 | ||
434 | err = ds_send_control(dev, COMM_BIT_IO | COMM_IM | (bit) ? COMM_D : 0, 0); | 436 | err = ds_send_control(dev, COMM_BIT_IO | COMM_IM | (bit) ? COMM_D : 0, 0); |
435 | if (err) | 437 | if (err) |
436 | return err; | 438 | return err; |
@@ -445,7 +447,7 @@ int ds_write_byte(struct ds_device *dev, u8 byte) | |||
445 | int err; | 447 | int err; |
446 | struct ds_status st; | 448 | struct ds_status st; |
447 | u8 rbyte; | 449 | u8 rbyte; |
448 | 450 | ||
449 | err = ds_send_control(dev, COMM_BYTE_IO | COMM_IM | COMM_SPU, byte); | 451 | err = ds_send_control(dev, COMM_BYTE_IO | COMM_IM | COMM_SPU, byte); |
450 | if (err) | 452 | if (err) |
451 | return err; | 453 | return err; |
@@ -453,11 +455,11 @@ int ds_write_byte(struct ds_device *dev, u8 byte) | |||
453 | err = ds_wait_status(dev, &st); | 455 | err = ds_wait_status(dev, &st); |
454 | if (err) | 456 | if (err) |
455 | return err; | 457 | return err; |
456 | 458 | ||
457 | err = ds_recv_data(dev, &rbyte, sizeof(rbyte)); | 459 | err = ds_recv_data(dev, &rbyte, sizeof(rbyte)); |
458 | if (err < 0) | 460 | if (err < 0) |
459 | return err; | 461 | return err; |
460 | 462 | ||
461 | ds_start_pulse(dev, PULLUP_PULSE_DURATION); | 463 | ds_start_pulse(dev, PULLUP_PULSE_DURATION); |
462 | 464 | ||
463 | return !(byte == rbyte); | 465 | return !(byte == rbyte); |
@@ -470,11 +472,11 @@ int ds_read_bit(struct ds_device *dev, u8 *bit) | |||
470 | err = ds_send_control_mode(dev, MOD_PULSE_EN, PULSE_SPUE); | 472 | err = ds_send_control_mode(dev, MOD_PULSE_EN, PULSE_SPUE); |
471 | if (err) | 473 | if (err) |
472 | return err; | 474 | return err; |
473 | 475 | ||
474 | err = ds_send_control(dev, COMM_BIT_IO | COMM_IM | COMM_SPU | COMM_D, 0); | 476 | err = ds_send_control(dev, COMM_BIT_IO | COMM_IM | COMM_SPU | COMM_D, 0); |
475 | if (err) | 477 | if (err) |
476 | return err; | 478 | return err; |
477 | 479 | ||
478 | err = ds_recv_data(dev, bit, sizeof(*bit)); | 480 | err = ds_recv_data(dev, bit, sizeof(*bit)); |
479 | if (err < 0) | 481 | if (err < 0) |
480 | return err; | 482 | return err; |
@@ -492,7 +494,7 @@ int ds_read_byte(struct ds_device *dev, u8 *byte) | |||
492 | return err; | 494 | return err; |
493 | 495 | ||
494 | ds_wait_status(dev, &st); | 496 | ds_wait_status(dev, &st); |
495 | 497 | ||
496 | err = ds_recv_data(dev, byte, sizeof(*byte)); | 498 | err = ds_recv_data(dev, byte, sizeof(*byte)); |
497 | if (err < 0) | 499 | if (err < 0) |
498 | return err; | 500 | return err; |
@@ -509,17 +511,17 @@ int ds_read_block(struct ds_device *dev, u8 *buf, int len) | |||
509 | return -E2BIG; | 511 | return -E2BIG; |
510 | 512 | ||
511 | memset(buf, 0xFF, len); | 513 | memset(buf, 0xFF, len); |
512 | 514 | ||
513 | err = ds_send_data(dev, buf, len); | 515 | err = ds_send_data(dev, buf, len); |
514 | if (err < 0) | 516 | if (err < 0) |
515 | return err; | 517 | return err; |
516 | 518 | ||
517 | err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | COMM_SPU, len); | 519 | err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | COMM_SPU, len); |
518 | if (err) | 520 | if (err) |
519 | return err; | 521 | return err; |
520 | 522 | ||
521 | ds_wait_status(dev, &st); | 523 | ds_wait_status(dev, &st); |
522 | 524 | ||
523 | memset(buf, 0x00, len); | 525 | memset(buf, 0x00, len); |
524 | err = ds_recv_data(dev, buf, len); | 526 | err = ds_recv_data(dev, buf, len); |
525 | 527 | ||
@@ -530,11 +532,11 @@ int ds_write_block(struct ds_device *dev, u8 *buf, int len) | |||
530 | { | 532 | { |
531 | int err; | 533 | int err; |
532 | struct ds_status st; | 534 | struct ds_status st; |
533 | 535 | ||
534 | err = ds_send_data(dev, buf, len); | 536 | err = ds_send_data(dev, buf, len); |
535 | if (err < 0) | 537 | if (err < 0) |
536 | return err; | 538 | return err; |
537 | 539 | ||
538 | ds_wait_status(dev, &st); | 540 | ds_wait_status(dev, &st); |
539 | 541 | ||
540 | err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | COMM_SPU, len); | 542 | err = ds_send_control(dev, COMM_BLOCK_IO | COMM_IM | COMM_SPU, len); |
@@ -548,10 +550,12 @@ int ds_write_block(struct ds_device *dev, u8 *buf, int len) | |||
548 | return err; | 550 | return err; |
549 | 551 | ||
550 | ds_start_pulse(dev, PULLUP_PULSE_DURATION); | 552 | ds_start_pulse(dev, PULLUP_PULSE_DURATION); |
551 | 553 | ||
552 | return !(err == len); | 554 | return !(err == len); |
553 | } | 555 | } |
554 | 556 | ||
557 | #if 0 | ||
558 | |||
555 | int ds_search(struct ds_device *dev, u64 init, u64 *buf, u8 id_number, int conditional_search) | 559 | int ds_search(struct ds_device *dev, u64 init, u64 *buf, u8 id_number, int conditional_search) |
556 | { | 560 | { |
557 | int err; | 561 | int err; |
@@ -559,11 +563,11 @@ int ds_search(struct ds_device *dev, u64 init, u64 *buf, u8 id_number, int condi | |||
559 | struct ds_status st; | 563 | struct ds_status st; |
560 | 564 | ||
561 | memset(buf, 0, sizeof(buf)); | 565 | memset(buf, 0, sizeof(buf)); |
562 | 566 | ||
563 | err = ds_send_data(ds_dev, (unsigned char *)&init, 8); | 567 | err = ds_send_data(ds_dev, (unsigned char *)&init, 8); |
564 | if (err) | 568 | if (err) |
565 | return err; | 569 | return err; |
566 | 570 | ||
567 | ds_wait_status(ds_dev, &st); | 571 | ds_wait_status(ds_dev, &st); |
568 | 572 | ||
569 | value = COMM_SEARCH_ACCESS | COMM_IM | COMM_SM | COMM_F | COMM_RTS; | 573 | value = COMM_SEARCH_ACCESS | COMM_IM | COMM_SM | COMM_F | COMM_RTS; |
@@ -589,7 +593,7 @@ int ds_match_access(struct ds_device *dev, u64 init) | |||
589 | err = ds_send_data(dev, (unsigned char *)&init, sizeof(init)); | 593 | err = ds_send_data(dev, (unsigned char *)&init, sizeof(init)); |
590 | if (err) | 594 | if (err) |
591 | return err; | 595 | return err; |
592 | 596 | ||
593 | ds_wait_status(dev, &st); | 597 | ds_wait_status(dev, &st); |
594 | 598 | ||
595 | err = ds_send_control(dev, COMM_MATCH_ACCESS | COMM_IM | COMM_RST, 0x0055); | 599 | err = ds_send_control(dev, COMM_MATCH_ACCESS | COMM_IM | COMM_RST, 0x0055); |
@@ -609,11 +613,11 @@ int ds_set_path(struct ds_device *dev, u64 init) | |||
609 | 613 | ||
610 | memcpy(buf, &init, 8); | 614 | memcpy(buf, &init, 8); |
611 | buf[8] = BRANCH_MAIN; | 615 | buf[8] = BRANCH_MAIN; |
612 | 616 | ||
613 | err = ds_send_data(dev, buf, sizeof(buf)); | 617 | err = ds_send_data(dev, buf, sizeof(buf)); |
614 | if (err) | 618 | if (err) |
615 | return err; | 619 | return err; |
616 | 620 | ||
617 | ds_wait_status(dev, &st); | 621 | ds_wait_status(dev, &st); |
618 | 622 | ||
619 | err = ds_send_control(dev, COMM_SET_PATH | COMM_IM | COMM_RST, 0); | 623 | err = ds_send_control(dev, COMM_SET_PATH | COMM_IM | COMM_RST, 0); |
@@ -625,7 +629,10 @@ int ds_set_path(struct ds_device *dev, u64 init) | |||
625 | return 0; | 629 | return 0; |
626 | } | 630 | } |
627 | 631 | ||
628 | int ds_probe(struct usb_interface *intf, const struct usb_device_id *udev_id) | 632 | #endif /* 0 */ |
633 | |||
634 | static int ds_probe(struct usb_interface *intf, | ||
635 | const struct usb_device_id *udev_id) | ||
629 | { | 636 | { |
630 | struct usb_device *udev = interface_to_usbdev(intf); | 637 | struct usb_device *udev = interface_to_usbdev(intf); |
631 | struct usb_endpoint_descriptor *endpoint; | 638 | struct usb_endpoint_descriptor *endpoint; |
@@ -653,7 +660,7 @@ int ds_probe(struct usb_interface *intf, const struct usb_device_id *udev_id) | |||
653 | printk(KERN_ERR "Failed to reset configuration: err=%d.\n", err); | 660 | printk(KERN_ERR "Failed to reset configuration: err=%d.\n", err); |
654 | return err; | 661 | return err; |
655 | } | 662 | } |
656 | 663 | ||
657 | iface_desc = &intf->altsetting[0]; | 664 | iface_desc = &intf->altsetting[0]; |
658 | if (iface_desc->desc.bNumEndpoints != NUM_EP-1) { | 665 | if (iface_desc->desc.bNumEndpoints != NUM_EP-1) { |
659 | printk(KERN_INFO "Num endpoints=%d. It is not DS9490R.\n", iface_desc->desc.bNumEndpoints); | 666 | printk(KERN_INFO "Num endpoints=%d. It is not DS9490R.\n", iface_desc->desc.bNumEndpoints); |
@@ -662,37 +669,37 @@ int ds_probe(struct usb_interface *intf, const struct usb_device_id *udev_id) | |||
662 | 669 | ||
663 | atomic_set(&ds_dev->refcnt, 0); | 670 | atomic_set(&ds_dev->refcnt, 0); |
664 | memset(ds_dev->ep, 0, sizeof(ds_dev->ep)); | 671 | memset(ds_dev->ep, 0, sizeof(ds_dev->ep)); |
665 | 672 | ||
666 | /* | 673 | /* |
667 | * This loop doesn'd show control 0 endpoint, | 674 | * This loop doesn'd show control 0 endpoint, |
668 | * so we will fill only 1-3 endpoints entry. | 675 | * so we will fill only 1-3 endpoints entry. |
669 | */ | 676 | */ |
670 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { | 677 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { |
671 | endpoint = &iface_desc->endpoint[i].desc; | 678 | endpoint = &iface_desc->endpoint[i].desc; |
672 | 679 | ||
673 | ds_dev->ep[i+1] = endpoint->bEndpointAddress; | 680 | ds_dev->ep[i+1] = endpoint->bEndpointAddress; |
674 | 681 | ||
675 | printk("%d: addr=%x, size=%d, dir=%s, type=%x\n", | 682 | printk("%d: addr=%x, size=%d, dir=%s, type=%x\n", |
676 | i, endpoint->bEndpointAddress, le16_to_cpu(endpoint->wMaxPacketSize), | 683 | i, endpoint->bEndpointAddress, le16_to_cpu(endpoint->wMaxPacketSize), |
677 | (endpoint->bEndpointAddress & USB_DIR_IN)?"IN":"OUT", | 684 | (endpoint->bEndpointAddress & USB_DIR_IN)?"IN":"OUT", |
678 | endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); | 685 | endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK); |
679 | } | 686 | } |
680 | 687 | ||
681 | #if 0 | 688 | #if 0 |
682 | { | 689 | { |
683 | int err, i; | 690 | int err, i; |
684 | u64 buf[3]; | 691 | u64 buf[3]; |
685 | u64 init=0xb30000002078ee81ull; | 692 | u64 init=0xb30000002078ee81ull; |
686 | struct ds_status st; | 693 | struct ds_status st; |
687 | 694 | ||
688 | ds_reset(ds_dev, &st); | 695 | ds_reset(ds_dev, &st); |
689 | err = ds_search(ds_dev, init, buf, 3, 0); | 696 | err = ds_search(ds_dev, init, buf, 3, 0); |
690 | if (err < 0) | 697 | if (err < 0) |
691 | return err; | 698 | return err; |
692 | for (i=0; i<err; ++i) | 699 | for (i=0; i<err; ++i) |
693 | printk("%d: %llx\n", i, buf[i]); | 700 | printk("%d: %llx\n", i, buf[i]); |
694 | 701 | ||
695 | printk("Resetting...\n"); | 702 | printk("Resetting...\n"); |
696 | ds_reset(ds_dev, &st); | 703 | ds_reset(ds_dev, &st); |
697 | printk("Setting path for %llx.\n", init); | 704 | printk("Setting path for %llx.\n", init); |
698 | err = ds_set_path(ds_dev, init); | 705 | err = ds_set_path(ds_dev, init); |
@@ -707,12 +714,12 @@ int ds_probe(struct usb_interface *intf, const struct usb_device_id *udev_id) | |||
707 | err = ds_search(ds_dev, init, buf, 3, 0); | 714 | err = ds_search(ds_dev, init, buf, 3, 0); |
708 | 715 | ||
709 | printk("ds_search() returned %d\n", err); | 716 | printk("ds_search() returned %d\n", err); |
710 | 717 | ||
711 | if (err < 0) | 718 | if (err < 0) |
712 | return err; | 719 | return err; |
713 | for (i=0; i<err; ++i) | 720 | for (i=0; i<err; ++i) |
714 | printk("%d: %llx\n", i, buf[i]); | 721 | printk("%d: %llx\n", i, buf[i]); |
715 | 722 | ||
716 | return 0; | 723 | return 0; |
717 | } | 724 | } |
718 | #endif | 725 | #endif |
@@ -720,10 +727,10 @@ int ds_probe(struct usb_interface *intf, const struct usb_device_id *udev_id) | |||
720 | return 0; | 727 | return 0; |
721 | } | 728 | } |
722 | 729 | ||
723 | void ds_disconnect(struct usb_interface *intf) | 730 | static void ds_disconnect(struct usb_interface *intf) |
724 | { | 731 | { |
725 | struct ds_device *dev; | 732 | struct ds_device *dev; |
726 | 733 | ||
727 | dev = usb_get_intfdata(intf); | 734 | dev = usb_get_intfdata(intf); |
728 | usb_set_intfdata(intf, NULL); | 735 | usb_set_intfdata(intf, NULL); |
729 | 736 | ||
@@ -740,7 +747,7 @@ void ds_disconnect(struct usb_interface *intf) | |||
740 | ds_dev = NULL; | 747 | ds_dev = NULL; |
741 | } | 748 | } |
742 | 749 | ||
743 | int ds_init(void) | 750 | static int ds_init(void) |
744 | { | 751 | { |
745 | int err; | 752 | int err; |
746 | 753 | ||
@@ -753,7 +760,7 @@ int ds_init(void) | |||
753 | return 0; | 760 | return 0; |
754 | } | 761 | } |
755 | 762 | ||
756 | void ds_fini(void) | 763 | static void ds_fini(void) |
757 | { | 764 | { |
758 | usb_deregister(&ds_driver); | 765 | usb_deregister(&ds_driver); |
759 | } | 766 | } |
@@ -776,8 +783,8 @@ EXPORT_SYMBOL(ds_get_device); | |||
776 | EXPORT_SYMBOL(ds_put_device); | 783 | EXPORT_SYMBOL(ds_put_device); |
777 | 784 | ||
778 | /* | 785 | /* |
779 | * This functions can be used for EEPROM programming, | 786 | * This functions can be used for EEPROM programming, |
780 | * when driver will be included into mainline this will | 787 | * when driver will be included into mainline this will |
781 | * require uncommenting. | 788 | * require uncommenting. |
782 | */ | 789 | */ |
783 | #if 0 | 790 | #if 0 |