| @@ -1,34 +1,34 @@ | | | @@ -1,34 +1,34 @@ |
1 | /* $NetBSD: onewire.c,v 1.11 2009/03/18 16:00:19 cegger Exp $ */ | | 1 | /* $NetBSD: onewire.c,v 1.12 2009/05/12 14:39:51 cegger Exp $ */ |
2 | /* $OpenBSD: onewire.c,v 1.1 2006/03/04 16:27:03 grange Exp $ */ | | 2 | /* $OpenBSD: onewire.c,v 1.1 2006/03/04 16:27:03 grange Exp $ */ |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org> | | 5 | * Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org> |
6 | * | | 6 | * |
7 | * Permission to use, copy, modify, and distribute this software for any | | 7 | * Permission to use, copy, modify, and distribute this software for any |
8 | * purpose with or without fee is hereby granted, provided that the above | | 8 | * purpose with or without fee is hereby granted, provided that the above |
9 | * copyright notice and this permission notice appear in all copies. | | 9 | * copyright notice and this permission notice appear in all copies. |
10 | * | | 10 | * |
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
18 | */ | | 18 | */ |
19 | | | 19 | |
20 | #include <sys/cdefs.h> | | 20 | #include <sys/cdefs.h> |
21 | __KERNEL_RCSID(0, "$NetBSD: onewire.c,v 1.11 2009/03/18 16:00:19 cegger Exp $"); | | 21 | __KERNEL_RCSID(0, "$NetBSD: onewire.c,v 1.12 2009/05/12 14:39:51 cegger Exp $"); |
22 | | | 22 | |
23 | /* | | 23 | /* |
24 | * 1-Wire bus driver. | | 24 | * 1-Wire bus driver. |
25 | */ | | 25 | */ |
26 | | | 26 | |
27 | #include <sys/param.h> | | 27 | #include <sys/param.h> |
28 | #include <sys/systm.h> | | 28 | #include <sys/systm.h> |
29 | #include <sys/conf.h> | | 29 | #include <sys/conf.h> |
30 | #include <sys/device.h> | | 30 | #include <sys/device.h> |
31 | #include <sys/kernel.h> | | 31 | #include <sys/kernel.h> |
32 | #include <sys/kthread.h> | | 32 | #include <sys/kthread.h> |
33 | #include <sys/rwlock.h> | | 33 | #include <sys/rwlock.h> |
34 | #include <sys/malloc.h> | | 34 | #include <sys/malloc.h> |
| @@ -313,27 +313,27 @@ onewire_thread(void *arg) | | | @@ -313,27 +313,27 @@ onewire_thread(void *arg) |
313 | tsleep(sc->sc_thread, PWAIT, "owidle", ONEWIRE_SCANTIME * hz); | | 313 | tsleep(sc->sc_thread, PWAIT, "owidle", ONEWIRE_SCANTIME * hz); |
314 | } | | 314 | } |
315 | | | 315 | |
316 | sc->sc_thread = NULL; | | 316 | sc->sc_thread = NULL; |
317 | wakeup(&sc->sc_dying); | | 317 | wakeup(&sc->sc_dying); |
318 | kthread_exit(0); | | 318 | kthread_exit(0); |
319 | } | | 319 | } |
320 | | | 320 | |
321 | static void | | 321 | static void |
322 | onewire_scan(struct onewire_softc *sc) | | 322 | onewire_scan(struct onewire_softc *sc) |
323 | { | | 323 | { |
324 | struct onewire_device *d, *next, *nd; | | 324 | struct onewire_device *d, *next, *nd; |
325 | struct onewire_attach_args oa; | | 325 | struct onewire_attach_args oa; |
326 | struct device *dev; | | 326 | device_t dev; |
327 | int search = 1, count = 0, present; | | 327 | int search = 1, count = 0, present; |
328 | int dir, rv; | | 328 | int dir, rv; |
329 | uint64_t mask, rom = 0, lastrom; | | 329 | uint64_t mask, rom = 0, lastrom; |
330 | uint8_t data[8]; | | 330 | uint8_t data[8]; |
331 | int i, i0 = -1, lastd = -1; | | 331 | int i, i0 = -1, lastd = -1; |
332 | | | 332 | |
333 | TAILQ_FOREACH(d, &sc->sc_devs, d_list) | | 333 | TAILQ_FOREACH(d, &sc->sc_devs, d_list) |
334 | d->d_present = 0; | | 334 | d->d_present = 0; |
335 | | | 335 | |
336 | while (search && count++ < ONEWIRE_MAXDEVS) { | | 336 | while (search && count++ < ONEWIRE_MAXDEVS) { |
337 | /* XXX: yield processor */ | | 337 | /* XXX: yield processor */ |
338 | tsleep(sc, PWAIT, "owscan", hz / 10); | | 338 | tsleep(sc, PWAIT, "owscan", hz / 10); |
339 | | | 339 | |