Tue Jun 13 00:49:05 2017 UTC ()
Remove dying ftom vb_args and use sc_dying instead.


(nat)
diff -r1.5 -r1.6 src/sys/dev/wscons/wsbell.c
diff -r1.1 -r1.2 src/sys/dev/wscons/wsbellvar.h

cvs diff -r1.5 -r1.6 src/sys/dev/wscons/wsbell.c (expand / switch to unified diff)

--- src/sys/dev/wscons/wsbell.c 2017/06/13 00:42:27 1.5
+++ src/sys/dev/wscons/wsbell.c 2017/06/13 00:49:05 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: wsbell.c,v 1.5 2017/06/13 00:42:27 nat Exp $ */ 1/* $NetBSD: wsbell.c,v 1.6 2017/06/13 00:49:05 nat Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2017 Nathanial Sloss <nathanialsloss@yahoo.com.au> 4 * Copyright (c) 2017 Nathanial Sloss <nathanialsloss@yahoo.com.au>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Copyright (c) 2006 The NetBSD Foundation, Inc. 7 * Copyright (c) 2006 The NetBSD Foundation, Inc.
8 * All rights reserved. 8 * All rights reserved.
9 * 9 *
10 * This code is derived from software contributed to The NetBSD Foundation 10 * This code is derived from software contributed to The NetBSD Foundation
11 * by Julio M. Merino Vidal. 11 * by Julio M. Merino Vidal.
12 * 12 *
13 * Redistribution and use in source and binary forms, with or without 13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions 14 * modification, are permitted provided that the following conditions
@@ -97,27 +97,27 @@ @@ -97,27 +97,27 @@
97 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 97 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
98 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 98 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
99 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 99 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
100 * SUCH DAMAGE. 100 * SUCH DAMAGE.
101 * 101 *
102 * @(#)ms.c 8.1 (Berkeley) 6/11/93 102 * @(#)ms.c 8.1 (Berkeley) 6/11/93
103 */ 103 */
104 104
105/* 105/*
106 * Keyboard Bell driver. 106 * Keyboard Bell driver.
107 */ 107 */
108 108
109#include <sys/cdefs.h> 109#include <sys/cdefs.h>
110__KERNEL_RCSID(0, "$NetBSD: wsbell.c,v 1.5 2017/06/13 00:42:27 nat Exp $"); 110__KERNEL_RCSID(0, "$NetBSD: wsbell.c,v 1.6 2017/06/13 00:49:05 nat Exp $");
111 111
112#if defined(_KERNEL_OPT) 112#if defined(_KERNEL_OPT)
113#include "wsmux.h" 113#include "wsmux.h"
114#endif 114#endif
115 115
116#include <sys/param.h> 116#include <sys/param.h>
117#include <sys/conf.h> 117#include <sys/conf.h>
118#include <sys/ioctl.h> 118#include <sys/ioctl.h>
119#include <sys/poll.h> 119#include <sys/poll.h>
120#include <sys/fcntl.h> 120#include <sys/fcntl.h>
121#include <sys/kernel.h> 121#include <sys/kernel.h>
122#include <sys/condvar.h> 122#include <sys/condvar.h>
123#include <sys/mutex.h> 123#include <sys/mutex.h>
@@ -295,27 +295,27 @@ wsbell_detach(device_t self, int flags) @@ -295,27 +295,27 @@ wsbell_detach(device_t self, int flags)
295 device_xname(self)); 295 device_xname(self));
296 } 296 }
297 splx(s); 297 splx(s);
298 } 298 }
299 299
300 /* locate the major number */ 300 /* locate the major number */
301 maj = cdevsw_lookup_major(&wsbell_cdevsw); 301 maj = cdevsw_lookup_major(&wsbell_cdevsw);
302 302
303 /* Nuke the vnodes for any open instances (calls close). */ 303 /* Nuke the vnodes for any open instances (calls close). */
304 mn = device_unit(self); 304 mn = device_unit(self);
305 vdevgone(maj, mn, mn, VCHR); 305 vdevgone(maj, mn, mn, VCHR);
306 306
307 mutex_enter(&sc->sc_bellock); 307 mutex_enter(&sc->sc_bellock);
308 sc->sc_bell_args.dying = true; 308 sc->sc_dying = 1;
309 309
310 cv_broadcast(&sc->sc_bellcv); 310 cv_broadcast(&sc->sc_bellcv);
311 mutex_exit(&sc->sc_bellock); 311 mutex_exit(&sc->sc_bellock);
312 312
313 kthread_join(sc->sc_bellthread); 313 kthread_join(sc->sc_bellthread);
314 cv_destroy(&sc->sc_bellcv); 314 cv_destroy(&sc->sc_bellcv);
315 mutex_destroy(&sc->sc_bellock); 315 mutex_destroy(&sc->sc_bellock);
316 316
317 return (0); 317 return (0);
318} 318}
319 319
320#if NWSMUX > 0 320#if NWSMUX > 0
321int 321int
@@ -390,50 +390,49 @@ wsbell_do_ioctl(struct wsbell_softc *sc, @@ -390,50 +390,49 @@ wsbell_do_ioctl(struct wsbell_softc *sc,
390 390
391static void 391static void
392bell_thread(void *arg) 392bell_thread(void *arg)
393{ 393{
394 struct wsbell_softc *sc = arg; 394 struct wsbell_softc *sc = arg;
395 struct vbell_args *vb = &sc->sc_bell_args; 395 struct vbell_args *vb = &sc->sc_bell_args;
396 tone_t tone; 396 tone_t tone;
397 u_int vol; 397 u_int vol;
398  398
399 for (;;) { 399 for (;;) {
400 mutex_enter(&sc->sc_bellock); 400 mutex_enter(&sc->sc_bellock);
401 cv_wait_sig(&sc->sc_bellcv, &sc->sc_bellock); 401 cv_wait_sig(&sc->sc_bellcv, &sc->sc_bellock);
402  402
403 if (vb->dying == true) { 403 if (sc->sc_dying) {
404 mutex_exit(&sc->sc_bellock); 404 mutex_exit(&sc->sc_bellock);
405 kthread_exit(0); 405 kthread_exit(0);
406 } 406 }
407  407
408 tone.frequency = vb->pitch; 408 tone.frequency = vb->pitch;
409 tone.duration = vb->period; 409 tone.duration = vb->period;
410 vol = vb->volume; 410 vol = vb->volume;
411 mutex_exit(&sc->sc_bellock); 411 mutex_exit(&sc->sc_bellock);
412 412
413 if (spkropen(sc->sc_spkr, FWRITE, 0, NULL) != 0) 413 if (spkropen(sc->sc_spkr, FWRITE, 0, NULL) != 0)
414 continue; 414 continue;
415 spkrioctl(sc->sc_spkr, SPKRSETVOL, &vol, 0, curlwp); 415 spkrioctl(sc->sc_spkr, SPKRSETVOL, &vol, 0, curlwp);
416 spkrioctl(sc->sc_spkr, SPKRTONE, &tone, 0, curlwp); 416 spkrioctl(sc->sc_spkr, SPKRTONE, &tone, 0, curlwp);
417 spkrclose(sc->sc_spkr, FWRITE, 0, curlwp); 417 spkrclose(sc->sc_spkr, FWRITE, 0, curlwp);
418 } 418 }
419} 419}
420 420
421static inline void 421static inline void
422spkr_audio_play(struct wsbell_softc *sc, u_int pitch, u_int period, u_int volume) 422spkr_audio_play(struct wsbell_softc *sc, u_int pitch, u_int period, u_int volume)
423{ 423{
424 424
425 mutex_enter(&sc->sc_bellock); 425 mutex_enter(&sc->sc_bellock);
426 sc->sc_bell_args.dying = false; 
427 sc->sc_bell_args.pitch = pitch; 426 sc->sc_bell_args.pitch = pitch;
428 sc->sc_bell_args.period = period / 5; 427 sc->sc_bell_args.period = period / 5;
429 sc->sc_bell_args.volume = volume; 428 sc->sc_bell_args.volume = volume;
430 429
431 cv_broadcast(&sc->sc_bellcv); 430 cv_broadcast(&sc->sc_bellcv);
432 mutex_exit(&sc->sc_bellock); 431 mutex_exit(&sc->sc_bellock);
433} 432}
434 433
435#if NWSMUX > 0 434#if NWSMUX > 0
436int 435int
437wsbell_mux_open(struct wsevsrc *me, struct wseventvar *evp) 436wsbell_mux_open(struct wsevsrc *me, struct wseventvar *evp)
438{ 437{
439 struct wsbell_softc *sc = (struct wsbell_softc *)me; 438 struct wsbell_softc *sc = (struct wsbell_softc *)me;

cvs diff -r1.1 -r1.2 src/sys/dev/wscons/wsbellvar.h (expand / switch to unified diff)

--- src/sys/dev/wscons/wsbellvar.h 2017/06/11 03:55:56 1.1
+++ src/sys/dev/wscons/wsbellvar.h 2017/06/13 00:49:05 1.2
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: wsbellvar.h,v 1.1 2017/06/11 03:55:56 nat Exp $ */ 1/* $NetBSD: wsbellvar.h,v 1.2 2017/06/13 00:49:05 nat Exp $ */
2/*- 2/*-
3 * Copyright (c) 2017 Nathanial Sloss <nathanialsloss@yahoo.com.au> 3 * Copyright (c) 2017 Nathanial Sloss <nathanialsloss@yahoo.com.au>
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
@@ -25,27 +25,26 @@ @@ -25,27 +25,26 @@
25 * POSSIBILITY OF SUCH DAMAGE. 25 * POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28#include "locators.h" 28#include "locators.h"
29#include <dev/wscons/wseventvar.h> 29#include <dev/wscons/wseventvar.h>
30#include <dev/wscons/wsmuxvar.h> 30#include <dev/wscons/wsmuxvar.h>
31 31
32#define wsbelldevcf_mux cf_loc[WSBELLDEVCF_MUX] 32#define wsbelldevcf_mux cf_loc[WSBELLDEVCF_MUX]
33 33
34struct vbell_args { 34struct vbell_args {
35 u_int pitch; 35 u_int pitch;
36 u_int period; 36 u_int period;
37 u_int volume; 37 u_int volume;
38 bool dying; 
39}; 38};
40 39
41struct wsbell_softc { 40struct wsbell_softc {
42 struct wsevsrc sc_base; 41 struct wsevsrc sc_base;
43 dev_t sc_spkr; /* our spkr device */ 42 dev_t sc_spkr; /* our spkr device */
44 struct wskbd_bell_data sc_bell_data; 43 struct wskbd_bell_data sc_bell_data;
45 44
46 void *sc_accesscookie; 45 void *sc_accesscookie;
47 46
48 int sc_refcnt; 47 int sc_refcnt;
49 u_char sc_dying; /* device is being detached */ 48 u_char sc_dying; /* device is being detached */
50 49
51 lwp_t *sc_bellthread; 50 lwp_t *sc_bellthread;