aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utilities/utmisc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/utilities/utmisc.c')
-rw-r--r--drivers/acpi/utilities/utmisc.c58
1 files changed, 40 insertions, 18 deletions
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index df715cd89105..1d350b302a34 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -56,7 +56,11 @@
56 * 56 *
57 * PARAMETERS: owner_id - Where the new owner ID is returned 57 * PARAMETERS: owner_id - Where the new owner ID is returned
58 * 58 *
59 * DESCRIPTION: Allocate a table or method owner id 59 * RETURN: Status
60 *
61 * DESCRIPTION: Allocate a table or method owner ID. The owner ID is used to
62 * track objects created by the table or method, to be deleted
63 * when the method exits or the table is unloaded.
60 * 64 *
61 ******************************************************************************/ 65 ******************************************************************************/
62 66
@@ -71,6 +75,8 @@ acpi_ut_allocate_owner_id (
71 ACPI_FUNCTION_TRACE ("ut_allocate_owner_id"); 75 ACPI_FUNCTION_TRACE ("ut_allocate_owner_id");
72 76
73 77
78 /* Mutex for the global ID mask */
79
74 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); 80 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
75 if (ACPI_FAILURE (status)) { 81 if (ACPI_FAILURE (status)) {
76 return_ACPI_STATUS (status); 82 return_ACPI_STATUS (status);
@@ -81,7 +87,7 @@ acpi_ut_allocate_owner_id (
81 for (i = 0; i < 32; i++) { 87 for (i = 0; i < 32; i++) {
82 if (!(acpi_gbl_owner_id_mask & (1 << i))) { 88 if (!(acpi_gbl_owner_id_mask & (1 << i))) {
83 acpi_gbl_owner_id_mask |= (1 << i); 89 acpi_gbl_owner_id_mask |= (1 << i);
84 *owner_id = (acpi_owner_id) i; 90 *owner_id = (acpi_owner_id) (i + 1);
85 goto exit; 91 goto exit;
86 } 92 }
87 } 93 }
@@ -93,6 +99,7 @@ acpi_ut_allocate_owner_id (
93 * they are released when a table is unloaded or a method completes 99 * they are released when a table is unloaded or a method completes
94 * execution. 100 * execution.
95 */ 101 */
102 *owner_id = 0;
96 status = AE_OWNER_ID_LIMIT; 103 status = AE_OWNER_ID_LIMIT;
97 ACPI_REPORT_ERROR (( 104 ACPI_REPORT_ERROR ((
98 "Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); 105 "Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n"));
@@ -107,40 +114,55 @@ exit:
107 * 114 *
108 * FUNCTION: acpi_ut_release_owner_id 115 * FUNCTION: acpi_ut_release_owner_id
109 * 116 *
110 * PARAMETERS: owner_id - A previously allocated owner ID 117 * PARAMETERS: owner_id_ptr - Pointer to a previously allocated owner_iD
111 * 118 *
112 * DESCRIPTION: Release a table or method owner id 119 * RETURN: None. No error is returned because we are either exiting a
120 * control method or unloading a table. Either way, we would
121 * ignore any error anyway.
122 *
123 * DESCRIPTION: Release a table or method owner ID. Valid IDs are 1 - 32
113 * 124 *
114 ******************************************************************************/ 125 ******************************************************************************/
115 126
116acpi_status 127void
117acpi_ut_release_owner_id ( 128acpi_ut_release_owner_id (
118 acpi_owner_id owner_id) 129 acpi_owner_id *owner_id_ptr)
119{ 130{
131 acpi_owner_id owner_id = *owner_id_ptr;
120 acpi_status status; 132 acpi_status status;
121 133
122 134
123 ACPI_FUNCTION_TRACE ("ut_release_owner_id"); 135 ACPI_FUNCTION_TRACE ("ut_release_owner_id");
124 136
125 137
138 /* Always clear the input owner_id (zero is an invalid ID) */
139
140 *owner_id_ptr = 0;
141
142 /* Zero is not a valid owner_iD */
143
144 if ((owner_id == 0) || (owner_id > 32)) {
145 ACPI_REPORT_ERROR (("Invalid owner_id: %2.2X\n", owner_id));
146 return_VOID;
147 }
148
149 /* Mutex for the global ID mask */
150
126 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES); 151 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
127 if (ACPI_FAILURE (status)) { 152 if (ACPI_FAILURE (status)) {
128 return_ACPI_STATUS (status); 153 return_VOID;
129 } 154 }
130 155
131 /* Free the owner ID */ 156 owner_id--; /* Normalize to zero */
157
158 /* Free the owner ID only if it is valid */
132 159
133 if (acpi_gbl_owner_id_mask & (1 << owner_id)) { 160 if (acpi_gbl_owner_id_mask & (1 << owner_id)) {
134 acpi_gbl_owner_id_mask ^= (1 << owner_id); 161 acpi_gbl_owner_id_mask ^= (1 << owner_id);
135 } 162 }
136 else {
137 /* This owner_id has not been allocated */
138
139 status = AE_NOT_EXIST;
140 }
141 163
142 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES); 164 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
143 return_ACPI_STATUS (status); 165 return_VOID;
144} 166}
145 167
146 168
@@ -150,7 +172,7 @@ acpi_ut_release_owner_id (
150 * 172 *
151 * PARAMETERS: src_string - The source string to convert 173 * PARAMETERS: src_string - The source string to convert
152 * 174 *
153 * RETURN: Converted src_string (same as input pointer) 175 * RETURN: None
154 * 176 *
155 * DESCRIPTION: Convert string to uppercase 177 * DESCRIPTION: Convert string to uppercase
156 * 178 *
@@ -158,7 +180,7 @@ acpi_ut_release_owner_id (
158 * 180 *
159 ******************************************************************************/ 181 ******************************************************************************/
160 182
161char * 183void
162acpi_ut_strupr ( 184acpi_ut_strupr (
163 char *src_string) 185 char *src_string)
164{ 186{
@@ -169,7 +191,7 @@ acpi_ut_strupr (
169 191
170 192
171 if (!src_string) { 193 if (!src_string) {
172 return (NULL); 194 return;
173 } 195 }
174 196
175 /* Walk entire string, uppercasing the letters */ 197 /* Walk entire string, uppercasing the letters */
@@ -178,7 +200,7 @@ acpi_ut_strupr (
178 *string = (char) ACPI_TOUPPER (*string); 200 *string = (char) ACPI_TOUPPER (*string);
179 } 201 }
180 202
181 return (src_string); 203 return;
182} 204}
183 205
184 206