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.c94
1 files changed, 94 insertions, 0 deletions
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 207c836aec64..df715cd89105 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -52,6 +52,100 @@
52 52
53/******************************************************************************* 53/*******************************************************************************
54 * 54 *
55 * FUNCTION: acpi_ut_allocate_owner_id
56 *
57 * PARAMETERS: owner_id - Where the new owner ID is returned
58 *
59 * DESCRIPTION: Allocate a table or method owner id
60 *
61 ******************************************************************************/
62
63acpi_status
64acpi_ut_allocate_owner_id (
65 acpi_owner_id *owner_id)
66{
67 acpi_native_uint i;
68 acpi_status status;
69
70
71 ACPI_FUNCTION_TRACE ("ut_allocate_owner_id");
72
73
74 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
75 if (ACPI_FAILURE (status)) {
76 return_ACPI_STATUS (status);
77 }
78
79 /* Find a free owner ID */
80
81 for (i = 0; i < 32; i++) {
82 if (!(acpi_gbl_owner_id_mask & (1 << i))) {
83 acpi_gbl_owner_id_mask |= (1 << i);
84 *owner_id = (acpi_owner_id) i;
85 goto exit;
86 }
87 }
88
89 /*
90 * If we are here, all owner_ids have been allocated. This probably should
91 * not happen since the IDs are reused after deallocation. The IDs are
92 * allocated upon table load (one per table) and method execution, and
93 * they are released when a table is unloaded or a method completes
94 * execution.
95 */
96 status = AE_OWNER_ID_LIMIT;
97 ACPI_REPORT_ERROR ((
98 "Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n"));
99
100exit:
101 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
102 return_ACPI_STATUS (status);
103}
104
105
106/*******************************************************************************
107 *
108 * FUNCTION: acpi_ut_release_owner_id
109 *
110 * PARAMETERS: owner_id - A previously allocated owner ID
111 *
112 * DESCRIPTION: Release a table or method owner id
113 *
114 ******************************************************************************/
115
116acpi_status
117acpi_ut_release_owner_id (
118 acpi_owner_id owner_id)
119{
120 acpi_status status;
121
122
123 ACPI_FUNCTION_TRACE ("ut_release_owner_id");
124
125
126 status = acpi_ut_acquire_mutex (ACPI_MTX_CACHES);
127 if (ACPI_FAILURE (status)) {
128 return_ACPI_STATUS (status);
129 }
130
131 /* Free the owner ID */
132
133 if (acpi_gbl_owner_id_mask & (1 << owner_id)) {
134 acpi_gbl_owner_id_mask ^= (1 << owner_id);
135 }
136 else {
137 /* This owner_id has not been allocated */
138
139 status = AE_NOT_EXIST;
140 }
141
142 (void) acpi_ut_release_mutex (ACPI_MTX_CACHES);
143 return_ACPI_STATUS (status);
144}
145
146
147/*******************************************************************************
148 *
55 * FUNCTION: acpi_ut_strupr (strupr) 149 * FUNCTION: acpi_ut_strupr (strupr)
56 * 150 *
57 * PARAMETERS: src_string - The source string to convert 151 * PARAMETERS: src_string - The source string to convert