[ACPI] ACPICA 20051102
[sfrench/cifs-2.6.git] / drivers / acpi / events / evxfevnt.c
1 /******************************************************************************
2  *
3  * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
4  *
5  *****************************************************************************/
6
7 /*
8  * Copyright (C) 2000 - 2005, R. Byron Moore
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43
44 #include <linux/module.h>
45
46 #include <acpi/acpi.h>
47 #include <acpi/acevents.h>
48 #include <acpi/acnamesp.h>
49
50 #define _COMPONENT          ACPI_EVENTS
51 ACPI_MODULE_NAME("evxfevnt")
52
53 /*******************************************************************************
54  *
55  * FUNCTION:    acpi_enable
56  *
57  * PARAMETERS:  None
58  *
59  * RETURN:      Status
60  *
61  * DESCRIPTION: Transfers the system into ACPI mode.
62  *
63  ******************************************************************************/
64 acpi_status acpi_enable(void)
65 {
66         acpi_status status = AE_OK;
67
68         ACPI_FUNCTION_TRACE("acpi_enable");
69
70         /* Make sure we have the FADT */
71
72         if (!acpi_gbl_FADT) {
73                 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
74                                   "No FADT information present!\n"));
75                 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
76         }
77
78         if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
79                 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
80                                   "System is already in ACPI mode\n"));
81         } else {
82                 /* Transition to ACPI mode */
83
84                 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
85                 if (ACPI_FAILURE(status)) {
86                         ACPI_REPORT_ERROR(("Could not transition to ACPI mode.\n"));
87                         return_ACPI_STATUS(status);
88                 }
89
90                 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
91                                   "Transition to ACPI mode successful\n"));
92         }
93
94         return_ACPI_STATUS(status);
95 }
96
97 /*******************************************************************************
98  *
99  * FUNCTION:    acpi_disable
100  *
101  * PARAMETERS:  None
102  *
103  * RETURN:      Status
104  *
105  * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
106  *
107  ******************************************************************************/
108
109 acpi_status acpi_disable(void)
110 {
111         acpi_status status = AE_OK;
112
113         ACPI_FUNCTION_TRACE("acpi_disable");
114
115         if (!acpi_gbl_FADT) {
116                 ACPI_DEBUG_PRINT((ACPI_DB_WARN,
117                                   "No FADT information present!\n"));
118                 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
119         }
120
121         if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
122                 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
123                                   "System is already in legacy (non-ACPI) mode\n"));
124         } else {
125                 /* Transition to LEGACY mode */
126
127                 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
128
129                 if (ACPI_FAILURE(status)) {
130                         ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
131                                           "Could not exit ACPI mode to legacy mode"));
132                         return_ACPI_STATUS(status);
133                 }
134
135                 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
136         }
137
138         return_ACPI_STATUS(status);
139 }
140
141 /*******************************************************************************
142  *
143  * FUNCTION:    acpi_enable_event
144  *
145  * PARAMETERS:  Event           - The fixed eventto be enabled
146  *              Flags           - Reserved
147  *
148  * RETURN:      Status
149  *
150  * DESCRIPTION: Enable an ACPI event (fixed)
151  *
152  ******************************************************************************/
153
154 acpi_status acpi_enable_event(u32 event, u32 flags)
155 {
156         acpi_status status = AE_OK;
157         u32 value;
158
159         ACPI_FUNCTION_TRACE("acpi_enable_event");
160
161         /* Decode the Fixed Event */
162
163         if (event > ACPI_EVENT_MAX) {
164                 return_ACPI_STATUS(AE_BAD_PARAMETER);
165         }
166
167         /*
168          * Enable the requested fixed event (by writing a one to the
169          * enable register bit)
170          */
171         status =
172             acpi_set_register(acpi_gbl_fixed_event_info[event].
173                               enable_register_id, 1, ACPI_MTX_LOCK);
174         if (ACPI_FAILURE(status)) {
175                 return_ACPI_STATUS(status);
176         }
177
178         /* Make sure that the hardware responded */
179
180         status =
181             acpi_get_register(acpi_gbl_fixed_event_info[event].
182                               enable_register_id, &value, ACPI_MTX_LOCK);
183         if (ACPI_FAILURE(status)) {
184                 return_ACPI_STATUS(status);
185         }
186
187         if (value != 1) {
188                 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
189                                   "Could not enable %s event\n",
190                                   acpi_ut_get_event_name(event)));
191                 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
192         }
193
194         return_ACPI_STATUS(status);
195 }
196
197 EXPORT_SYMBOL(acpi_enable_event);
198
199 /*******************************************************************************
200  *
201  * FUNCTION:    acpi_set_gpe_type
202  *
203  * PARAMETERS:  gpe_device      - Parent GPE Device
204  *              gpe_number      - GPE level within the GPE block
205  *              Type            - New GPE type
206  *
207  * RETURN:      Status
208  *
209  * DESCRIPTION: Set the type of an individual GPE
210  *
211  ******************************************************************************/
212
213 acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type)
214 {
215         acpi_status status = AE_OK;
216         struct acpi_gpe_event_info *gpe_event_info;
217
218         ACPI_FUNCTION_TRACE("acpi_set_gpe_type");
219
220         /* Ensure that we have a valid GPE number */
221
222         gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
223         if (!gpe_event_info) {
224                 status = AE_BAD_PARAMETER;
225                 goto unlock_and_exit;
226         }
227
228         if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) {
229                 return_ACPI_STATUS(AE_OK);
230         }
231
232         /* Set the new type (will disable GPE if currently enabled) */
233
234         status = acpi_ev_set_gpe_type(gpe_event_info, type);
235
236       unlock_and_exit:
237         return_ACPI_STATUS(status);
238 }
239
240 EXPORT_SYMBOL(acpi_set_gpe_type);
241
242 /*******************************************************************************
243  *
244  * FUNCTION:    acpi_enable_gpe
245  *
246  * PARAMETERS:  gpe_device      - Parent GPE Device
247  *              gpe_number      - GPE level within the GPE block
248  *              Flags           - Just enable, or also wake enable?
249  *                                Called from ISR or not
250  *
251  * RETURN:      Status
252  *
253  * DESCRIPTION: Enable an ACPI event (general purpose)
254  *
255  ******************************************************************************/
256
257 acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
258 {
259         acpi_status status = AE_OK;
260         struct acpi_gpe_event_info *gpe_event_info;
261
262         ACPI_FUNCTION_TRACE("acpi_enable_gpe");
263
264         /* Use semaphore lock if not executing at interrupt level */
265
266         if (flags & ACPI_NOT_ISR) {
267                 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
268                 if (ACPI_FAILURE(status)) {
269                         return_ACPI_STATUS(status);
270                 }
271         }
272
273         /* Ensure that we have a valid GPE number */
274
275         gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
276         if (!gpe_event_info) {
277                 status = AE_BAD_PARAMETER;
278                 goto unlock_and_exit;
279         }
280
281         /* Perform the enable */
282
283         status = acpi_ev_enable_gpe(gpe_event_info, TRUE);
284
285       unlock_and_exit:
286         if (flags & ACPI_NOT_ISR) {
287                 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
288         }
289         return_ACPI_STATUS(status);
290 }
291
292 EXPORT_SYMBOL(acpi_enable_gpe);
293
294 /*******************************************************************************
295  *
296  * FUNCTION:    acpi_disable_gpe
297  *
298  * PARAMETERS:  gpe_device      - Parent GPE Device
299  *              gpe_number      - GPE level within the GPE block
300  *              Flags           - Just disable, or also wake disable?
301  *                                Called from ISR or not
302  *
303  * RETURN:      Status
304  *
305  * DESCRIPTION: Disable an ACPI event (general purpose)
306  *
307  ******************************************************************************/
308
309 acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
310 {
311         acpi_status status = AE_OK;
312         struct acpi_gpe_event_info *gpe_event_info;
313
314         ACPI_FUNCTION_TRACE("acpi_disable_gpe");
315
316         /* Use semaphore lock if not executing at interrupt level */
317
318         if (flags & ACPI_NOT_ISR) {
319                 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
320                 if (ACPI_FAILURE(status)) {
321                         return_ACPI_STATUS(status);
322                 }
323         }
324
325         /* Ensure that we have a valid GPE number */
326
327         gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
328         if (!gpe_event_info) {
329                 status = AE_BAD_PARAMETER;
330                 goto unlock_and_exit;
331         }
332
333         status = acpi_ev_disable_gpe(gpe_event_info);
334
335       unlock_and_exit:
336         if (flags & ACPI_NOT_ISR) {
337                 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
338         }
339         return_ACPI_STATUS(status);
340 }
341
342 /*******************************************************************************
343  *
344  * FUNCTION:    acpi_disable_event
345  *
346  * PARAMETERS:  Event           - The fixed eventto be enabled
347  *              Flags           - Reserved
348  *
349  * RETURN:      Status
350  *
351  * DESCRIPTION: Disable an ACPI event (fixed)
352  *
353  ******************************************************************************/
354
355 acpi_status acpi_disable_event(u32 event, u32 flags)
356 {
357         acpi_status status = AE_OK;
358         u32 value;
359
360         ACPI_FUNCTION_TRACE("acpi_disable_event");
361
362         /* Decode the Fixed Event */
363
364         if (event > ACPI_EVENT_MAX) {
365                 return_ACPI_STATUS(AE_BAD_PARAMETER);
366         }
367
368         /*
369          * Disable the requested fixed event (by writing a zero to the
370          * enable register bit)
371          */
372         status =
373             acpi_set_register(acpi_gbl_fixed_event_info[event].
374                               enable_register_id, 0, ACPI_MTX_LOCK);
375         if (ACPI_FAILURE(status)) {
376                 return_ACPI_STATUS(status);
377         }
378
379         status =
380             acpi_get_register(acpi_gbl_fixed_event_info[event].
381                               enable_register_id, &value, ACPI_MTX_LOCK);
382         if (ACPI_FAILURE(status)) {
383                 return_ACPI_STATUS(status);
384         }
385
386         if (value != 0) {
387                 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
388                                   "Could not disable %s events\n",
389                                   acpi_ut_get_event_name(event)));
390                 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
391         }
392
393         return_ACPI_STATUS(status);
394 }
395
396 EXPORT_SYMBOL(acpi_disable_event);
397
398 /*******************************************************************************
399  *
400  * FUNCTION:    acpi_clear_event
401  *
402  * PARAMETERS:  Event           - The fixed event to be cleared
403  *
404  * RETURN:      Status
405  *
406  * DESCRIPTION: Clear an ACPI event (fixed)
407  *
408  ******************************************************************************/
409
410 acpi_status acpi_clear_event(u32 event)
411 {
412         acpi_status status = AE_OK;
413
414         ACPI_FUNCTION_TRACE("acpi_clear_event");
415
416         /* Decode the Fixed Event */
417
418         if (event > ACPI_EVENT_MAX) {
419                 return_ACPI_STATUS(AE_BAD_PARAMETER);
420         }
421
422         /*
423          * Clear the requested fixed event (By writing a one to the
424          * status register bit)
425          */
426         status =
427             acpi_set_register(acpi_gbl_fixed_event_info[event].
428                               status_register_id, 1, ACPI_MTX_LOCK);
429
430         return_ACPI_STATUS(status);
431 }
432
433 EXPORT_SYMBOL(acpi_clear_event);
434
435 /*******************************************************************************
436  *
437  * FUNCTION:    acpi_clear_gpe
438  *
439  * PARAMETERS:  gpe_device      - Parent GPE Device
440  *              gpe_number      - GPE level within the GPE block
441  *              Flags           - Called from an ISR or not
442  *
443  * RETURN:      Status
444  *
445  * DESCRIPTION: Clear an ACPI event (general purpose)
446  *
447  ******************************************************************************/
448
449 acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
450 {
451         acpi_status status = AE_OK;
452         struct acpi_gpe_event_info *gpe_event_info;
453
454         ACPI_FUNCTION_TRACE("acpi_clear_gpe");
455
456         /* Use semaphore lock if not executing at interrupt level */
457
458         if (flags & ACPI_NOT_ISR) {
459                 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
460                 if (ACPI_FAILURE(status)) {
461                         return_ACPI_STATUS(status);
462                 }
463         }
464
465         /* Ensure that we have a valid GPE number */
466
467         gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
468         if (!gpe_event_info) {
469                 status = AE_BAD_PARAMETER;
470                 goto unlock_and_exit;
471         }
472
473         status = acpi_hw_clear_gpe(gpe_event_info);
474
475       unlock_and_exit:
476         if (flags & ACPI_NOT_ISR) {
477                 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
478         }
479         return_ACPI_STATUS(status);
480 }
481
482 #ifdef ACPI_FUTURE_USAGE
483 /*******************************************************************************
484  *
485  * FUNCTION:    acpi_get_event_status
486  *
487  * PARAMETERS:  Event           - The fixed event
488  *              event_status    - Where the current status of the event will
489  *                                be returned
490  *
491  * RETURN:      Status
492  *
493  * DESCRIPTION: Obtains and returns the current status of the event
494  *
495  ******************************************************************************/
496
497 acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
498 {
499         acpi_status status = AE_OK;
500
501         ACPI_FUNCTION_TRACE("acpi_get_event_status");
502
503         if (!event_status) {
504                 return_ACPI_STATUS(AE_BAD_PARAMETER);
505         }
506
507         /* Decode the Fixed Event */
508
509         if (event > ACPI_EVENT_MAX) {
510                 return_ACPI_STATUS(AE_BAD_PARAMETER);
511         }
512
513         /* Get the status of the requested fixed event */
514
515         status =
516             acpi_get_register(acpi_gbl_fixed_event_info[event].
517                               status_register_id, event_status, ACPI_MTX_LOCK);
518
519         return_ACPI_STATUS(status);
520 }
521
522 /*******************************************************************************
523  *
524  * FUNCTION:    acpi_get_gpe_status
525  *
526  * PARAMETERS:  gpe_device      - Parent GPE Device
527  *              gpe_number      - GPE level within the GPE block
528  *              Flags           - Called from an ISR or not
529  *              event_status    - Where the current status of the event will
530  *                                be returned
531  *
532  * RETURN:      Status
533  *
534  * DESCRIPTION: Get status of an event (general purpose)
535  *
536  ******************************************************************************/
537
538 acpi_status
539 acpi_get_gpe_status(acpi_handle gpe_device,
540                     u32 gpe_number, u32 flags, acpi_event_status * event_status)
541 {
542         acpi_status status = AE_OK;
543         struct acpi_gpe_event_info *gpe_event_info;
544
545         ACPI_FUNCTION_TRACE("acpi_get_gpe_status");
546
547         /* Use semaphore lock if not executing at interrupt level */
548
549         if (flags & ACPI_NOT_ISR) {
550                 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
551                 if (ACPI_FAILURE(status)) {
552                         return_ACPI_STATUS(status);
553                 }
554         }
555
556         /* Ensure that we have a valid GPE number */
557
558         gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
559         if (!gpe_event_info) {
560                 status = AE_BAD_PARAMETER;
561                 goto unlock_and_exit;
562         }
563
564         /* Obtain status on the requested GPE number */
565
566         status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
567
568       unlock_and_exit:
569         if (flags & ACPI_NOT_ISR) {
570                 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
571         }
572         return_ACPI_STATUS(status);
573 }
574 #endif                          /*  ACPI_FUTURE_USAGE  */
575
576 /*******************************************************************************
577  *
578  * FUNCTION:    acpi_install_gpe_block
579  *
580  * PARAMETERS:  gpe_device          - Handle to the parent GPE Block Device
581  *              gpe_block_address   - Address and space_iD
582  *              register_count      - Number of GPE register pairs in the block
583  *              interrupt_number    - H/W interrupt for the block
584  *
585  * RETURN:      Status
586  *
587  * DESCRIPTION: Create and Install a block of GPE registers
588  *
589  ******************************************************************************/
590
591 acpi_status
592 acpi_install_gpe_block(acpi_handle gpe_device,
593                        struct acpi_generic_address *gpe_block_address,
594                        u32 register_count, u32 interrupt_number)
595 {
596         acpi_status status;
597         union acpi_operand_object *obj_desc;
598         struct acpi_namespace_node *node;
599         struct acpi_gpe_block_info *gpe_block;
600
601         ACPI_FUNCTION_TRACE("acpi_install_gpe_block");
602
603         if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
604                 return_ACPI_STATUS(AE_BAD_PARAMETER);
605         }
606
607         status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
608         if (ACPI_FAILURE(status)) {
609                 return (status);
610         }
611
612         node = acpi_ns_map_handle_to_node(gpe_device);
613         if (!node) {
614                 status = AE_BAD_PARAMETER;
615                 goto unlock_and_exit;
616         }
617
618         /*
619          * For user-installed GPE Block Devices, the gpe_block_base_number
620          * is always zero
621          */
622         status =
623             acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
624                                      interrupt_number, &gpe_block);
625         if (ACPI_FAILURE(status)) {
626                 goto unlock_and_exit;
627         }
628
629         /* Run the _PRW methods and enable the GPEs */
630
631         status = acpi_ev_initialize_gpe_block(node, gpe_block);
632         if (ACPI_FAILURE(status)) {
633                 goto unlock_and_exit;
634         }
635
636         /* Get the device_object attached to the node */
637
638         obj_desc = acpi_ns_get_attached_object(node);
639         if (!obj_desc) {
640                 /* No object, create a new one */
641
642                 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
643                 if (!obj_desc) {
644                         status = AE_NO_MEMORY;
645                         goto unlock_and_exit;
646                 }
647
648                 status =
649                     acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
650
651                 /* Remove local reference to the object */
652
653                 acpi_ut_remove_reference(obj_desc);
654
655                 if (ACPI_FAILURE(status)) {
656                         goto unlock_and_exit;
657                 }
658         }
659
660         /* Install the GPE block in the device_object */
661
662         obj_desc->device.gpe_block = gpe_block;
663
664       unlock_and_exit:
665         (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
666         return_ACPI_STATUS(status);
667 }
668
669 EXPORT_SYMBOL(acpi_install_gpe_block);
670
671 /*******************************************************************************
672  *
673  * FUNCTION:    acpi_remove_gpe_block
674  *
675  * PARAMETERS:  gpe_device          - Handle to the parent GPE Block Device
676  *
677  * RETURN:      Status
678  *
679  * DESCRIPTION: Remove a previously installed block of GPE registers
680  *
681  ******************************************************************************/
682
683 acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
684 {
685         union acpi_operand_object *obj_desc;
686         acpi_status status;
687         struct acpi_namespace_node *node;
688
689         ACPI_FUNCTION_TRACE("acpi_remove_gpe_block");
690
691         if (!gpe_device) {
692                 return_ACPI_STATUS(AE_BAD_PARAMETER);
693         }
694
695         status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
696         if (ACPI_FAILURE(status)) {
697                 return (status);
698         }
699
700         node = acpi_ns_map_handle_to_node(gpe_device);
701         if (!node) {
702                 status = AE_BAD_PARAMETER;
703                 goto unlock_and_exit;
704         }
705
706         /* Get the device_object attached to the node */
707
708         obj_desc = acpi_ns_get_attached_object(node);
709         if (!obj_desc || !obj_desc->device.gpe_block) {
710                 return_ACPI_STATUS(AE_NULL_OBJECT);
711         }
712
713         /* Delete the GPE block (but not the device_object) */
714
715         status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
716         if (ACPI_SUCCESS(status)) {
717                 obj_desc->device.gpe_block = NULL;
718         }
719
720       unlock_and_exit:
721         (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
722         return_ACPI_STATUS(status);
723 }
724
725 EXPORT_SYMBOL(acpi_remove_gpe_block);