| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sysmon_power.c,v 1.60 2019/03/01 11:06:56 pgoyette Exp $ */ | | 1 | /* $NetBSD: sysmon_power.c,v 1.60.4.1 2019/09/01 10:57:53 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2007 Juan Romero Pardines. | | 4 | * Copyright (c) 2007 Juan Romero Pardines. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -59,27 +59,27 @@ | | | @@ -59,27 +59,27 @@ |
59 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 59 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
60 | * POSSIBILITY OF SUCH DAMAGE. | | 60 | * POSSIBILITY OF SUCH DAMAGE. |
61 | */ | | 61 | */ |
62 | | | 62 | |
63 | /* | | 63 | /* |
64 | * Power management framework for sysmon. | | 64 | * Power management framework for sysmon. |
65 | * | | 65 | * |
66 | * We defer to a power management daemon running in userspace, since | | 66 | * We defer to a power management daemon running in userspace, since |
67 | * power management is largely a policy issue. This merely provides | | 67 | * power management is largely a policy issue. This merely provides |
68 | * for power management event notification to that daemon. | | 68 | * for power management event notification to that daemon. |
69 | */ | | 69 | */ |
70 | | | 70 | |
71 | #include <sys/cdefs.h> | | 71 | #include <sys/cdefs.h> |
72 | __KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.60 2019/03/01 11:06:56 pgoyette Exp $"); | | 72 | __KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.60.4.1 2019/09/01 10:57:53 martin Exp $"); |
73 | | | 73 | |
74 | #ifdef _KERNEL_OPT | | 74 | #ifdef _KERNEL_OPT |
75 | #include "opt_compat_netbsd.h" | | 75 | #include "opt_compat_netbsd.h" |
76 | #endif | | 76 | #endif |
77 | | | 77 | |
78 | #include <sys/param.h> | | 78 | #include <sys/param.h> |
79 | #include <sys/reboot.h> | | 79 | #include <sys/reboot.h> |
80 | #include <sys/systm.h> | | 80 | #include <sys/systm.h> |
81 | #include <sys/poll.h> | | 81 | #include <sys/poll.h> |
82 | #include <sys/select.h> | | 82 | #include <sys/select.h> |
83 | #include <sys/vnode.h> | | 83 | #include <sys/vnode.h> |
84 | #include <sys/condvar.h> | | 84 | #include <sys/condvar.h> |
85 | #include <sys/mutex.h> | | 85 | #include <sys/mutex.h> |
| @@ -321,26 +321,28 @@ sysmon_power_event_queue_flush(void) | | | @@ -321,26 +321,28 @@ sysmon_power_event_queue_flush(void) |
321 | * Assign required power event members and sends a signal | | 321 | * Assign required power event members and sends a signal |
322 | * to the process to notify that an event was enqueued successfully. | | 322 | * to the process to notify that an event was enqueued successfully. |
323 | */ | | 323 | */ |
324 | static int | | 324 | static int |
325 | sysmon_power_daemon_task(struct power_event_dictionary *ped, | | 325 | sysmon_power_daemon_task(struct power_event_dictionary *ped, |
326 | void *pev_data, int event) | | 326 | void *pev_data, int event) |
327 | { | | 327 | { |
328 | power_event_t pev; | | 328 | power_event_t pev; |
329 | int rv, error = 0; | | 329 | int rv, error = 0; |
330 | | | 330 | |
331 | if (!ped || !ped->dict || !pev_data) | | 331 | if (!ped || !ped->dict || !pev_data) |
332 | return EINVAL; | | 332 | return EINVAL; |
333 | | | 333 | |
| | | 334 | memset(&pev, 0, sizeof(pev)); |
| | | 335 | |
334 | mutex_enter(&sysmon_power_event_queue_mtx); | | 336 | mutex_enter(&sysmon_power_event_queue_mtx); |
335 | | | 337 | |
336 | switch (event) { | | 338 | switch (event) { |
337 | /* | | 339 | /* |
338 | * Power switch events. | | 340 | * Power switch events. |
339 | */ | | 341 | */ |
340 | case PSWITCH_EVENT_PRESSED: | | 342 | case PSWITCH_EVENT_PRESSED: |
341 | case PSWITCH_EVENT_RELEASED: | | 343 | case PSWITCH_EVENT_RELEASED: |
342 | { | | 344 | { |
343 | | | 345 | |
344 | struct sysmon_pswitch *pswitch = | | 346 | struct sysmon_pswitch *pswitch = |
345 | (struct sysmon_pswitch *)pev_data; | | 347 | (struct sysmon_pswitch *)pev_data; |
346 | | | 348 | |