diff options
Diffstat (limited to 'drivers/acpi/osl.c')
-rw-r--r-- | drivers/acpi/osl.c | 196 |
1 files changed, 148 insertions, 48 deletions
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c index bdd9f37f8101..56e7cedba919 100644 --- a/drivers/acpi/osl.c +++ b/drivers/acpi/osl.c | |||
@@ -778,54 +778,6 @@ acpi_os_delete_lock ( | |||
778 | return_VOID; | 778 | return_VOID; |
779 | } | 779 | } |
780 | 780 | ||
781 | /* | ||
782 | * Acquire a spinlock. | ||
783 | * | ||
784 | * handle is a pointer to the spinlock_t. | ||
785 | * flags is *not* the result of save_flags - it is an ACPI-specific flag variable | ||
786 | * that indicates whether we are at interrupt level. | ||
787 | */ | ||
788 | void | ||
789 | acpi_os_acquire_lock ( | ||
790 | acpi_handle handle, | ||
791 | u32 flags) | ||
792 | { | ||
793 | ACPI_FUNCTION_TRACE ("os_acquire_lock"); | ||
794 | |||
795 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Acquiring spinlock[%p] from %s level\n", handle, | ||
796 | ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt"))); | ||
797 | |||
798 | if (flags & ACPI_NOT_ISR) | ||
799 | ACPI_DISABLE_IRQS(); | ||
800 | |||
801 | spin_lock((spinlock_t *)handle); | ||
802 | |||
803 | return_VOID; | ||
804 | } | ||
805 | |||
806 | |||
807 | /* | ||
808 | * Release a spinlock. See above. | ||
809 | */ | ||
810 | void | ||
811 | acpi_os_release_lock ( | ||
812 | acpi_handle handle, | ||
813 | u32 flags) | ||
814 | { | ||
815 | ACPI_FUNCTION_TRACE ("os_release_lock"); | ||
816 | |||
817 | ACPI_DEBUG_PRINT ((ACPI_DB_MUTEX, "Releasing spinlock[%p] from %s level\n", handle, | ||
818 | ((flags & ACPI_NOT_ISR) ? "non-interrupt" : "interrupt"))); | ||
819 | |||
820 | spin_unlock((spinlock_t *)handle); | ||
821 | |||
822 | if (flags & ACPI_NOT_ISR) | ||
823 | ACPI_ENABLE_IRQS(); | ||
824 | |||
825 | return_VOID; | ||
826 | } | ||
827 | |||
828 | |||
829 | acpi_status | 781 | acpi_status |
830 | acpi_os_create_semaphore( | 782 | acpi_os_create_semaphore( |
831 | u32 max_units, | 783 | u32 max_units, |
@@ -1172,3 +1124,151 @@ unsigned int max_cstate = ACPI_PROCESSOR_MAX_POWER; | |||
1172 | 1124 | ||
1173 | 1125 | ||
1174 | EXPORT_SYMBOL(max_cstate); | 1126 | EXPORT_SYMBOL(max_cstate); |
1127 | |||
1128 | /* | ||
1129 | * Acquire a spinlock. | ||
1130 | * | ||
1131 | * handle is a pointer to the spinlock_t. | ||
1132 | * flags is *not* the result of save_flags - it is an ACPI-specific flag variable | ||
1133 | * that indicates whether we are at interrupt level. | ||
1134 | */ | ||
1135 | |||
1136 | unsigned long | ||
1137 | acpi_os_acquire_lock ( | ||
1138 | acpi_handle handle) | ||
1139 | { | ||
1140 | unsigned long flags; | ||
1141 | spin_lock_irqsave((spinlock_t *)handle, flags); | ||
1142 | return flags; | ||
1143 | } | ||
1144 | |||
1145 | /* | ||
1146 | * Release a spinlock. See above. | ||
1147 | */ | ||
1148 | |||
1149 | void | ||
1150 | acpi_os_release_lock ( | ||
1151 | acpi_handle handle, | ||
1152 | unsigned long flags) | ||
1153 | { | ||
1154 | spin_unlock_irqrestore((spinlock_t *)handle, flags); | ||
1155 | } | ||
1156 | |||
1157 | |||
1158 | #ifndef ACPI_USE_LOCAL_CACHE | ||
1159 | |||
1160 | /******************************************************************************* | ||
1161 | * | ||
1162 | * FUNCTION: acpi_os_create_cache | ||
1163 | * | ||
1164 | * PARAMETERS: CacheName - Ascii name for the cache | ||
1165 | * ObjectSize - Size of each cached object | ||
1166 | * MaxDepth - Maximum depth of the cache (in objects) | ||
1167 | * ReturnCache - Where the new cache object is returned | ||
1168 | * | ||
1169 | * RETURN: Status | ||
1170 | * | ||
1171 | * DESCRIPTION: Create a cache object | ||
1172 | * | ||
1173 | ******************************************************************************/ | ||
1174 | |||
1175 | acpi_status | ||
1176 | acpi_os_create_cache ( | ||
1177 | char *name, | ||
1178 | u16 size, | ||
1179 | u16 depth, | ||
1180 | acpi_cache_t **cache) | ||
1181 | { | ||
1182 | *cache = kmem_cache_create (name, size, 0, 0, NULL, NULL); | ||
1183 | return AE_OK; | ||
1184 | } | ||
1185 | |||
1186 | /******************************************************************************* | ||
1187 | * | ||
1188 | * FUNCTION: acpi_os_purge_cache | ||
1189 | * | ||
1190 | * PARAMETERS: Cache - Handle to cache object | ||
1191 | * | ||
1192 | * RETURN: Status | ||
1193 | * | ||
1194 | * DESCRIPTION: Free all objects within the requested cache. | ||
1195 | * | ||
1196 | ******************************************************************************/ | ||
1197 | |||
1198 | acpi_status | ||
1199 | acpi_os_purge_cache ( | ||
1200 | acpi_cache_t *cache) | ||
1201 | { | ||
1202 | (void) kmem_cache_shrink(cache); | ||
1203 | return (AE_OK); | ||
1204 | } | ||
1205 | |||
1206 | /******************************************************************************* | ||
1207 | * | ||
1208 | * FUNCTION: acpi_os_delete_cache | ||
1209 | * | ||
1210 | * PARAMETERS: Cache - Handle to cache object | ||
1211 | * | ||
1212 | * RETURN: Status | ||
1213 | * | ||
1214 | * DESCRIPTION: Free all objects within the requested cache and delete the | ||
1215 | * cache object. | ||
1216 | * | ||
1217 | ******************************************************************************/ | ||
1218 | |||
1219 | acpi_status | ||
1220 | acpi_os_delete_cache ( | ||
1221 | acpi_cache_t *cache) | ||
1222 | { | ||
1223 | (void)kmem_cache_destroy(cache); | ||
1224 | return (AE_OK); | ||
1225 | } | ||
1226 | |||
1227 | /******************************************************************************* | ||
1228 | * | ||
1229 | * FUNCTION: acpi_os_release_object | ||
1230 | * | ||
1231 | * PARAMETERS: Cache - Handle to cache object | ||
1232 | * Object - The object to be released | ||
1233 | * | ||
1234 | * RETURN: None | ||
1235 | * | ||
1236 | * DESCRIPTION: Release an object to the specified cache. If cache is full, | ||
1237 | * the object is deleted. | ||
1238 | * | ||
1239 | ******************************************************************************/ | ||
1240 | |||
1241 | acpi_status | ||
1242 | acpi_os_release_object ( | ||
1243 | acpi_cache_t *cache, | ||
1244 | void *object) | ||
1245 | { | ||
1246 | kmem_cache_free(cache, object); | ||
1247 | return (AE_OK); | ||
1248 | } | ||
1249 | |||
1250 | /******************************************************************************* | ||
1251 | * | ||
1252 | * FUNCTION: acpi_os_acquire_object | ||
1253 | * | ||
1254 | * PARAMETERS: Cache - Handle to cache object | ||
1255 | * ReturnObject - Where the object is returned | ||
1256 | * | ||
1257 | * RETURN: Status | ||
1258 | * | ||
1259 | * DESCRIPTION: Get an object from the specified cache. If cache is empty, | ||
1260 | * the object is allocated. | ||
1261 | * | ||
1262 | ******************************************************************************/ | ||
1263 | |||
1264 | void * | ||
1265 | acpi_os_acquire_object ( | ||
1266 | acpi_cache_t *cache) | ||
1267 | { | ||
1268 | void *object = kmem_cache_alloc(cache, GFP_KERNEL); | ||
1269 | WARN_ON(!object); | ||
1270 | return object; | ||
1271 | } | ||
1272 | |||
1273 | #endif | ||
1274 | |||