Move duplicate definition of SETBELL macro into wsbelldata.h.diff -r1.4 -r1.5 src/sys/dev/wscons/wsbell.c
(nat)
--- src/sys/dev/wscons/wsbell.c 2017/06/12 07:12:49 1.4
+++ src/sys/dev/wscons/wsbell.c 2017/06/13 00:42:27 1.5
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: wsbell.c,v 1.4 2017/06/12 07:12:49 pgoyette Exp $ */ | 1 | /* $NetBSD: wsbell.c,v 1.5 2017/06/13 00:42:27 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.4 2017/06/12 07:12:49 pgoyette Exp $"); | 110 | __KERNEL_RCSID(0, "$NetBSD: wsbell.c,v 1.5 2017/06/13 00:42:27 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> | |
@@ -341,37 +341,26 @@ wsbelldoioctl(device_t dv, u_long cmd, v | @@ -341,37 +341,26 @@ wsbelldoioctl(device_t dv, u_long cmd, v | |||
341 | 341 | |||
342 | int | 342 | int | |
343 | wsbell_do_ioctl(struct wsbell_softc *sc, u_long cmd, void *data, | 343 | wsbell_do_ioctl(struct wsbell_softc *sc, u_long cmd, void *data, | |
344 | int flag, struct lwp *l) | 344 | int flag, struct lwp *l) | |
345 | { | 345 | { | |
346 | struct wskbd_bell_data *ubdp, *kbdp; | 346 | struct wskbd_bell_data *ubdp, *kbdp; | |
347 | if (sc->sc_dying) | 347 | if (sc->sc_dying) | |
348 | return (EIO); | 348 | return (EIO); | |
349 | 349 | |||
350 | /* | 350 | /* | |
351 | * Try the wsbell specific ioctls. | 351 | * Try the wsbell specific ioctls. | |
352 | */ | 352 | */ | |
353 | switch (cmd) { | 353 | switch (cmd) { | |
354 | #define SETBELL(dstp, srcp, dfltp) \ | |||
355 | do { \ | |||
356 | (dstp)->pitch = ((srcp)->which & WSKBD_BELL_DOPITCH) ? \ | |||
357 | (srcp)->pitch : (dfltp)->pitch; \ | |||
358 | (dstp)->period = ((srcp)->which & WSKBD_BELL_DOPERIOD) ? \ | |||
359 | (srcp)->period : (dfltp)->period; \ | |||
360 | (dstp)->volume = ((srcp)->which & WSKBD_BELL_DOVOLUME) ? \ | |||
361 | (srcp)->volume : (dfltp)->volume; \ | |||
362 | (dstp)->which = WSKBD_BELL_DOALL; \ | |||
363 | } while (0) | |||
364 | ||||
365 | case WSKBDIO_SETBELL: | 354 | case WSKBDIO_SETBELL: | |
366 | if ((flag & FWRITE) == 0) | 355 | if ((flag & FWRITE) == 0) | |
367 | return (EACCES); | 356 | return (EACCES); | |
368 | kbdp = &sc->sc_bell_data; | 357 | kbdp = &sc->sc_bell_data; | |
369 | ubdp = (struct wskbd_bell_data *)data; | 358 | ubdp = (struct wskbd_bell_data *)data; | |
370 | SETBELL(kbdp, ubdp, kbdp); | 359 | SETBELL(kbdp, ubdp, kbdp); | |
371 | return (0); | 360 | return (0); | |
372 | 361 | |||
373 | case WSKBDIO_GETBELL: | 362 | case WSKBDIO_GETBELL: | |
374 | kbdp = &sc->sc_bell_data; | 363 | kbdp = &sc->sc_bell_data; | |
375 | ubdp = (struct wskbd_bell_data *)data; | 364 | ubdp = (struct wskbd_bell_data *)data; | |
376 | SETBELL(ubdp, kbdp, kbdp); | 365 | SETBELL(ubdp, kbdp, kbdp); | |
377 | return (0); | 366 | return (0); |
--- src/sys/dev/wscons/wsbelldata.h 2017/06/11 03:38:12 1.1
+++ src/sys/dev/wscons/wsbelldata.h 2017/06/13 00:42:27 1.2
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: wsbelldata.h,v 1.1 2017/06/11 03:38:12 nat Exp $ */ | 1 | /* $NetBSD: wsbelldata.h,v 1.2 2017/06/13 00:42:27 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,19 +25,30 @@ | @@ -25,19 +25,30 @@ | |||
25 | * POSSIBILITY OF SUCH DAMAGE. | 25 | * POSSIBILITY OF SUCH DAMAGE. | |
26 | */ | 26 | */ | |
27 | 27 | |||
28 | #ifndef WSKBD_DEFAULT_BELL_PITCH | 28 | #ifndef WSKBD_DEFAULT_BELL_PITCH | |
29 | #define WSKBD_DEFAULT_BELL_PITCH 1500 /* 1500Hz */ | 29 | #define WSKBD_DEFAULT_BELL_PITCH 1500 /* 1500Hz */ | |
30 | #endif | 30 | #endif | |
31 | #ifndef WSKBD_DEFAULT_BELL_PERIOD | 31 | #ifndef WSKBD_DEFAULT_BELL_PERIOD | |
32 | #define WSKBD_DEFAULT_BELL_PERIOD 100 /* 100ms */ | 32 | #define WSKBD_DEFAULT_BELL_PERIOD 100 /* 100ms */ | |
33 | #endif | 33 | #endif | |
34 | #ifndef WSKBD_DEFAULT_BELL_VOLUME | 34 | #ifndef WSKBD_DEFAULT_BELL_VOLUME | |
35 | #define WSKBD_DEFAULT_BELL_VOLUME 50 /* 50% volume */ | 35 | #define WSKBD_DEFAULT_BELL_VOLUME 50 /* 50% volume */ | |
36 | #endif | 36 | #endif | |
37 | 37 | |||
38 | #define SETBELL(dstp, srcp, dfltp) \ | |||
39 | do { \ | |||
40 | (dstp)->pitch = ((srcp)->which & WSKBD_BELL_DOPITCH) ? \ | |||
41 | (srcp)->pitch : (dfltp)->pitch; \ | |||
42 | (dstp)->period = ((srcp)->which & WSKBD_BELL_DOPERIOD) ? \ | |||
43 | (srcp)->period : (dfltp)->period; \ | |||
44 | (dstp)->volume = ((srcp)->which & WSKBD_BELL_DOVOLUME) ? \ | |||
45 | (srcp)->volume : (dfltp)->volume; \ | |||
46 | (dstp)->which = WSKBD_BELL_DOALL; \ | |||
47 | } while (0) | |||
48 | ||||
38 | static struct wskbd_bell_data wskbd_default_bell_data = { | 49 | static struct wskbd_bell_data wskbd_default_bell_data = { | |
39 | WSKBD_BELL_DOALL, | 50 | WSKBD_BELL_DOALL, | |
40 | WSKBD_DEFAULT_BELL_PITCH, | 51 | WSKBD_DEFAULT_BELL_PITCH, | |
41 | WSKBD_DEFAULT_BELL_PERIOD, | 52 | WSKBD_DEFAULT_BELL_PERIOD, | |
42 | WSKBD_DEFAULT_BELL_VOLUME, | 53 | WSKBD_DEFAULT_BELL_VOLUME, | |
43 | }; | 54 | }; |
--- src/sys/dev/wscons/wskbd.c 2017/06/11 03:38:12 1.139
+++ src/sys/dev/wscons/wskbd.c 2017/06/13 00:42:27 1.140
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: wskbd.c,v 1.139 2017/06/11 03:38:12 nat Exp $ */ | 1 | /* $NetBSD: wskbd.c,v 1.140 2017/06/13 00:42:27 nat Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. | 4 | * Copyright (c) 1996, 1997 Christopher G. Demetriou. 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 | * 3. All advertising materials mentioning features or use of this software | 14 | * 3. All advertising materials mentioning features or use of this software | |
@@ -95,27 +95,27 @@ | @@ -95,27 +95,27 @@ | |||
95 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 95 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
96 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 96 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
97 | * SUCH DAMAGE. | 97 | * SUCH DAMAGE. | |
98 | * | 98 | * | |
99 | * @(#)kbd.c 8.2 (Berkeley) 10/30/93 | 99 | * @(#)kbd.c 8.2 (Berkeley) 10/30/93 | |
100 | */ | 100 | */ | |
101 | 101 | |||
102 | /* | 102 | /* | |
103 | * Keyboard driver (/dev/wskbd*). Translates incoming bytes to ASCII or | 103 | * Keyboard driver (/dev/wskbd*). Translates incoming bytes to ASCII or | |
104 | * to `wscons_events' and passes them up to the appropriate reader. | 104 | * to `wscons_events' and passes them up to the appropriate reader. | |
105 | */ | 105 | */ | |
106 | 106 | |||
107 | #include <sys/cdefs.h> | 107 | #include <sys/cdefs.h> | |
108 | __KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.139 2017/06/11 03:38:12 nat Exp $"); | 108 | __KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.140 2017/06/13 00:42:27 nat Exp $"); | |
109 | 109 | |||
110 | #ifdef _KERNEL_OPT | 110 | #ifdef _KERNEL_OPT | |
111 | #include "opt_ddb.h" | 111 | #include "opt_ddb.h" | |
112 | #include "opt_kgdb.h" | 112 | #include "opt_kgdb.h" | |
113 | #include "opt_wsdisplay_compat.h" | 113 | #include "opt_wsdisplay_compat.h" | |
114 | #endif | 114 | #endif | |
115 | 115 | |||
116 | #include "wsdisplay.h" | 116 | #include "wsdisplay.h" | |
117 | #include "wskbd.h" | 117 | #include "wskbd.h" | |
118 | #include "wsmux.h" | 118 | #include "wsmux.h" | |
119 | 119 | |||
120 | #include <sys/param.h> | 120 | #include <sys/param.h> | |
121 | #include <sys/conf.h> | 121 | #include <sys/conf.h> | |
@@ -1049,37 +1049,26 @@ wskbd_displayioctl(device_t dev, u_long | @@ -1049,37 +1049,26 @@ wskbd_displayioctl(device_t dev, u_long | |||
1049 | #ifdef WSDISPLAY_SCROLLSUPPORT | 1049 | #ifdef WSDISPLAY_SCROLLSUPPORT | |
1050 | struct wskbd_scroll_data *usdp, *ksdp; | 1050 | struct wskbd_scroll_data *usdp, *ksdp; | |
1051 | #endif | 1051 | #endif | |
1052 | struct wskbd_softc *sc = device_private(dev); | 1052 | struct wskbd_softc *sc = device_private(dev); | |
1053 | struct wskbd_bell_data *ubdp, *kbdp; | 1053 | struct wskbd_bell_data *ubdp, *kbdp; | |
1054 | struct wskbd_keyrepeat_data *ukdp, *kkdp; | 1054 | struct wskbd_keyrepeat_data *ukdp, *kkdp; | |
1055 | struct wskbd_map_data *umdp; | 1055 | struct wskbd_map_data *umdp; | |
1056 | struct wskbd_mapdata md; | 1056 | struct wskbd_mapdata md; | |
1057 | kbd_t enc; | 1057 | kbd_t enc; | |
1058 | void *tbuf; | 1058 | void *tbuf; | |
1059 | int len, error; | 1059 | int len, error; | |
1060 | 1060 | |||
1061 | switch (cmd) { | 1061 | switch (cmd) { | |
1062 | #define SETBELL(dstp, srcp, dfltp) \ | |||
1063 | do { \ | |||
1064 | (dstp)->pitch = ((srcp)->which & WSKBD_BELL_DOPITCH) ? \ | |||
1065 | (srcp)->pitch : (dfltp)->pitch; \ | |||
1066 | (dstp)->period = ((srcp)->which & WSKBD_BELL_DOPERIOD) ? \ | |||
1067 | (srcp)->period : (dfltp)->period; \ | |||
1068 | (dstp)->volume = ((srcp)->which & WSKBD_BELL_DOVOLUME) ? \ | |||
1069 | (srcp)->volume : (dfltp)->volume; \ | |||
1070 | (dstp)->which = WSKBD_BELL_DOALL; \ | |||
1071 | } while (0) | |||
1072 | ||||
1073 | case WSKBDIO_BELL: | 1062 | case WSKBDIO_BELL: | |
1074 | if ((flag & FWRITE) == 0) | 1063 | if ((flag & FWRITE) == 0) | |
1075 | return (EACCES); | 1064 | return (EACCES); | |
1076 | return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie, | 1065 | return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie, | |
1077 | WSKBDIO_COMPLEXBELL, (void *)&sc->sc_bell_data, flag, l)); | 1066 | WSKBDIO_COMPLEXBELL, (void *)&sc->sc_bell_data, flag, l)); | |
1078 | 1067 | |||
1079 | case WSKBDIO_COMPLEXBELL: | 1068 | case WSKBDIO_COMPLEXBELL: | |
1080 | if ((flag & FWRITE) == 0) | 1069 | if ((flag & FWRITE) == 0) | |
1081 | return (EACCES); | 1070 | return (EACCES); | |
1082 | ubdp = (struct wskbd_bell_data *)data; | 1071 | ubdp = (struct wskbd_bell_data *)data; | |
1083 | SETBELL(ubdp, ubdp, &sc->sc_bell_data); | 1072 | SETBELL(ubdp, ubdp, &sc->sc_bell_data); | |
1084 | return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie, | 1073 | return ((*sc->sc_accessops->ioctl)(sc->sc_accesscookie, | |
1085 | WSKBDIO_COMPLEXBELL, (void *)ubdp, flag, l)); | 1074 | WSKBDIO_COMPLEXBELL, (void *)ubdp, flag, l)); |