| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: sysmon_envsys_events.c,v 1.101 2012/07/16 13:55:01 pgoyette Exp $ */ | | 1 | /* $NetBSD: sysmon_envsys_events.c,v 1.102 2012/07/18 20:50:40 pgoyette Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2007, 2008 Juan Romero Pardines. | | 4 | * Copyright (c) 2007, 2008 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. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 21 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 22 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 23 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 25 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | | 26 | */ |
27 | | | 27 | |
28 | /* | | 28 | /* |
29 | * sysmon_envsys(9) events framework. | | 29 | * sysmon_envsys(9) events framework. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.101 2012/07/16 13:55:01 pgoyette Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.102 2012/07/18 20:50:40 pgoyette Exp $"); |
34 | | | 34 | |
35 | #include <sys/param.h> | | 35 | #include <sys/param.h> |
36 | #include <sys/types.h> | | 36 | #include <sys/types.h> |
37 | #include <sys/conf.h> | | 37 | #include <sys/conf.h> |
38 | #include <sys/errno.h> | | 38 | #include <sys/errno.h> |
39 | #include <sys/kernel.h> | | 39 | #include <sys/kernel.h> |
40 | #include <sys/systm.h> | | 40 | #include <sys/systm.h> |
41 | #include <sys/proc.h> | | 41 | #include <sys/proc.h> |
42 | #include <sys/mutex.h> | | 42 | #include <sys/mutex.h> |
43 | #include <sys/kmem.h> | | 43 | #include <sys/kmem.h> |
44 | #include <sys/callout.h> | | 44 | #include <sys/callout.h> |
45 | | | 45 | |
46 | /* #define ENVSYS_DEBUG */ | | 46 | /* #define ENVSYS_DEBUG */ |
| @@ -176,28 +176,30 @@ sme_event_register(prop_dictionary_t sdi | | | @@ -176,28 +176,30 @@ sme_event_register(prop_dictionary_t sdi |
176 | error = EEXIST; | | 176 | error = EEXIST; |
177 | props &= ~(PROP_WARNMIN | PROP_BATTWARN); | | 177 | props &= ~(PROP_WARNMIN | PROP_BATTWARN); |
178 | } | | 178 | } |
179 | } | | 179 | } |
180 | if (props & edata->upropset & (PROP_CRITMIN | PROP_BATTCAP)) { | | 180 | if (props & edata->upropset & (PROP_CRITMIN | PROP_BATTCAP)) { |
181 | if (lims->sel_critmin == edata->limits.sel_critmin) { | | 181 | if (lims->sel_critmin == edata->limits.sel_critmin) { |
182 | DPRINTF(("%s: critmin exists\n", __func__)); | | 182 | DPRINTF(("%s: critmin exists\n", __func__)); |
183 | error = EEXIST; | | 183 | error = EEXIST; |
184 | props &= ~(PROP_CRITMIN | PROP_BATTCAP); | | 184 | props &= ~(PROP_CRITMIN | PROP_BATTCAP); |
185 | } | | 185 | } |
186 | } | | 186 | } |
187 | break; | | 187 | break; |
188 | } | | 188 | } |
189 | if (crittype == PENVSYS_EVENT_NULL && see != NULL) | | 189 | if (crittype == PENVSYS_EVENT_NULL && see != NULL) { |
| | | 190 | mutex_exit(&sme->sme_mtx); |
190 | return EEXIST; | | 191 | return EEXIST; |
| | | 192 | } |
191 | | | 193 | |
192 | if (see == NULL) { | | 194 | if (see == NULL) { |
193 | /* | | 195 | /* |
194 | * New event requested - allocate a sysmon_envsys event. | | 196 | * New event requested - allocate a sysmon_envsys event. |
195 | */ | | 197 | */ |
196 | see = kmem_zalloc(sizeof(*see), KM_SLEEP); | | 198 | see = kmem_zalloc(sizeof(*see), KM_SLEEP); |
197 | if (see == NULL) | | 199 | if (see == NULL) |
198 | return ENOMEM; | | 200 | return ENOMEM; |
199 | | | 201 | |
200 | DPRINTF(("%s: dev %s sensor %s: new event\n", | | 202 | DPRINTF(("%s: dev %s sensor %s: new event\n", |
201 | __func__, sme->sme_name, edata->desc)); | | 203 | __func__, sme->sme_name, edata->desc)); |
202 | | | 204 | |
203 | see->see_type = crittype; | | 205 | see->see_type = crittype; |