]> err.no Git - linux-2.6/blob - drivers/acpi/events/evxfevnt.c
Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm
[linux-2.6] / 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 - 2007, 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 <acpi/acpi.h>
45 #include <acpi/acevents.h>
46 #include <acpi/acnamesp.h>
47 #include <acpi/actables.h>
48
49 #define _COMPONENT          ACPI_EVENTS
50 ACPI_MODULE_NAME("evxfevnt")
51
52 /*******************************************************************************
53  *
54  * FUNCTION:    acpi_enable
55  *
56  * PARAMETERS:  None
57  *
58  * RETURN:      Status
59  *
60  * DESCRIPTION: Transfers the system into ACPI mode.
61  *
62  ******************************************************************************/
63 acpi_status acpi_enable(void)
64 {
65         acpi_status status = AE_OK;
66
67         ACPI_FUNCTION_TRACE(acpi_enable);
68
69         /* ACPI tables must be present */
70
71         if (!acpi_tb_tables_loaded()) {
72                 return_ACPI_STATUS(AE_NO_ACPI_TABLES);
73         }
74
75         /* Check current mode */
76
77         if (acpi_hw_get_mode() == ACPI_SYS_MODE_ACPI) {
78                 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
79                                   "System is already in ACPI mode\n"));
80         } else {
81                 /* Transition to ACPI mode */
82
83                 status = acpi_hw_set_mode(ACPI_SYS_MODE_ACPI);
84                 if (ACPI_FAILURE(status)) {
85                         ACPI_ERROR((AE_INFO,
86                                     "Could not transition to ACPI mode"));
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 ACPI_EXPORT_SYMBOL(acpi_enable)
98
99 /*******************************************************************************
100  *
101  * FUNCTION:    acpi_disable
102  *
103  * PARAMETERS:  None
104  *
105  * RETURN:      Status
106  *
107  * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
108  *
109  ******************************************************************************/
110 acpi_status acpi_disable(void)
111 {
112         acpi_status status = AE_OK;
113
114         ACPI_FUNCTION_TRACE(acpi_disable);
115
116         if (acpi_hw_get_mode() == ACPI_SYS_MODE_LEGACY) {
117                 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
118                                   "System is already in legacy (non-ACPI) mode\n"));
119         } else {
120                 /* Transition to LEGACY mode */
121
122                 status = acpi_hw_set_mode(ACPI_SYS_MODE_LEGACY);
123
124                 if (ACPI_FAILURE(status)) {
125                         ACPI_ERROR((AE_INFO,
126                                     "Could not exit ACPI mode to legacy mode"));
127                         return_ACPI_STATUS(status);
128                 }
129
130                 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI mode disabled\n"));
131         }
132
133         return_ACPI_STATUS(status);
134 }
135
136 ACPI_EXPORT_SYMBOL(acpi_disable)
137
138 /*******************************************************************************
139  *
140  * FUNCTION:    acpi_enable_event
141  *
142  * PARAMETERS:  Event           - The fixed eventto be enabled
143  *              Flags           - Reserved
144  *
145  * RETURN:      Status
146  *
147  * DESCRIPTION: Enable an ACPI event (fixed)
148  *
149  ******************************************************************************/
150 acpi_status acpi_enable_event(u32 event, u32 flags)
151 {
152         acpi_status status = AE_OK;
153         u32 value;
154
155         ACPI_FUNCTION_TRACE(acpi_enable_event);
156
157         /* Decode the Fixed Event */
158
159         if (event > ACPI_EVENT_MAX) {
160                 return_ACPI_STATUS(AE_BAD_PARAMETER);
161         }
162
163         /*
164          * Enable the requested fixed event (by writing a one to the
165          * enable register bit)
166          */
167         status =
168             acpi_set_register(acpi_gbl_fixed_event_info[event].
169                               enable_register_id, 1);
170         if (ACPI_FAILURE(status)) {
171                 return_ACPI_STATUS(status);
172         }
173
174         /* Make sure that the hardware responded */
175
176         status =
177             acpi_get_register(acpi_gbl_fixed_event_info[event].
178                               enable_register_id, &value);
179         if (ACPI_FAILURE(status)) {
180                 return_ACPI_STATUS(status);
181         }
182
183         if (value != 1) {
184                 ACPI_ERROR((AE_INFO,
185                             "Could not enable %s event",
186                             acpi_ut_get_event_name(event)));
187                 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
188         }
189
190         return_ACPI_STATUS(status);
191 }
192
193 ACPI_EXPORT_SYMBOL(acpi_enable_event)
194
195 /*******************************************************************************
196  *
197  * FUNCTION:    acpi_set_gpe_type
198  *
199  * PARAMETERS:  gpe_device      - Parent GPE Device
200  *              gpe_number      - GPE level within the GPE block
201  *              Type            - New GPE type
202  *
203  * RETURN:      Status
204  *
205  * DESCRIPTION: Set the type of an individual GPE
206  *
207  ******************************************************************************/
208 acpi_status acpi_set_gpe_type(acpi_handle gpe_device, u32 gpe_number, u8 type)
209 {
210         acpi_status status = AE_OK;
211         struct acpi_gpe_event_info *gpe_event_info;
212
213         ACPI_FUNCTION_TRACE(acpi_set_gpe_type);
214
215         /* Ensure that we have a valid GPE number */
216
217         gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
218         if (!gpe_event_info) {
219                 status = AE_BAD_PARAMETER;
220                 goto unlock_and_exit;
221         }
222
223         if ((gpe_event_info->flags & ACPI_GPE_TYPE_MASK) == type) {
224                 return_ACPI_STATUS(AE_OK);
225         }
226
227         /* Set the new type (will disable GPE if currently enabled) */
228
229         status = acpi_ev_set_gpe_type(gpe_event_info, type);
230
231       unlock_and_exit:
232         return_ACPI_STATUS(status);
233 }
234
235 ACPI_EXPORT_SYMBOL(acpi_set_gpe_type)
236
237 /*******************************************************************************
238  *
239  * FUNCTION:    acpi_enable_gpe
240  *
241  * PARAMETERS:  gpe_device      - Parent GPE Device
242  *              gpe_number      - GPE level within the GPE block
243  *              Flags           - Just enable, or also wake enable?
244  *                                Called from ISR or not
245  *
246  * RETURN:      Status
247  *
248  * DESCRIPTION: Enable an ACPI event (general purpose)
249  *
250  ******************************************************************************/
251 acpi_status acpi_enable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
252 {
253         acpi_status status = AE_OK;
254         struct acpi_gpe_event_info *gpe_event_info;
255
256         ACPI_FUNCTION_TRACE(acpi_enable_gpe);
257
258         /* Use semaphore lock if not executing at interrupt level */
259
260         if (flags & ACPI_NOT_ISR) {
261                 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
262                 if (ACPI_FAILURE(status)) {
263                         return_ACPI_STATUS(status);
264                 }
265         }
266
267         /* Ensure that we have a valid GPE number */
268
269         gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
270         if (!gpe_event_info) {
271                 status = AE_BAD_PARAMETER;
272                 goto unlock_and_exit;
273         }
274
275         /* Perform the enable */
276
277         status = acpi_ev_enable_gpe(gpe_event_info, TRUE);
278
279       unlock_and_exit:
280         if (flags & ACPI_NOT_ISR) {
281                 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
282         }
283         return_ACPI_STATUS(status);
284 }
285
286 ACPI_EXPORT_SYMBOL(acpi_enable_gpe)
287
288 /*******************************************************************************
289  *
290  * FUNCTION:    acpi_disable_gpe
291  *
292  * PARAMETERS:  gpe_device      - Parent GPE Device
293  *              gpe_number      - GPE level within the GPE block
294  *              Flags           - Just disable, or also wake disable?
295  *                                Called from ISR or not
296  *
297  * RETURN:      Status
298  *
299  * DESCRIPTION: Disable an ACPI event (general purpose)
300  *
301  ******************************************************************************/
302 acpi_status acpi_disable_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
303 {
304         acpi_status status = AE_OK;
305         struct acpi_gpe_event_info *gpe_event_info;
306
307         ACPI_FUNCTION_TRACE(acpi_disable_gpe);
308
309         /* Use semaphore lock if not executing at interrupt level */
310
311         if (flags & ACPI_NOT_ISR) {
312                 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
313                 if (ACPI_FAILURE(status)) {
314                         return_ACPI_STATUS(status);
315                 }
316         }
317
318         /* Ensure that we have a valid GPE number */
319
320         gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
321         if (!gpe_event_info) {
322                 status = AE_BAD_PARAMETER;
323                 goto unlock_and_exit;
324         }
325
326         status = acpi_ev_disable_gpe(gpe_event_info);
327
328       unlock_and_exit:
329         if (flags & ACPI_NOT_ISR) {
330                 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
331         }
332         return_ACPI_STATUS(status);
333 }
334
335 ACPI_EXPORT_SYMBOL(acpi_disable_gpe)
336
337 /*******************************************************************************
338  *
339  * FUNCTION:    acpi_disable_event
340  *
341  * PARAMETERS:  Event           - The fixed eventto be enabled
342  *              Flags           - Reserved
343  *
344  * RETURN:      Status
345  *
346  * DESCRIPTION: Disable an ACPI event (fixed)
347  *
348  ******************************************************************************/
349 acpi_status acpi_disable_event(u32 event, u32 flags)
350 {
351         acpi_status status = AE_OK;
352         u32 value;
353
354         ACPI_FUNCTION_TRACE(acpi_disable_event);
355
356         /* Decode the Fixed Event */
357
358         if (event > ACPI_EVENT_MAX) {
359                 return_ACPI_STATUS(AE_BAD_PARAMETER);
360         }
361
362         /*
363          * Disable the requested fixed event (by writing a zero to the
364          * enable register bit)
365          */
366         status =
367             acpi_set_register(acpi_gbl_fixed_event_info[event].
368                               enable_register_id, 0);
369         if (ACPI_FAILURE(status)) {
370                 return_ACPI_STATUS(status);
371         }
372
373         status =
374             acpi_get_register(acpi_gbl_fixed_event_info[event].
375                               enable_register_id, &value);
376         if (ACPI_FAILURE(status)) {
377                 return_ACPI_STATUS(status);
378         }
379
380         if (value != 0) {
381                 ACPI_ERROR((AE_INFO,
382                             "Could not disable %s events",
383                             acpi_ut_get_event_name(event)));
384                 return_ACPI_STATUS(AE_NO_HARDWARE_RESPONSE);
385         }
386
387         return_ACPI_STATUS(status);
388 }
389
390 ACPI_EXPORT_SYMBOL(acpi_disable_event)
391
392 /*******************************************************************************
393  *
394  * FUNCTION:    acpi_clear_event
395  *
396  * PARAMETERS:  Event           - The fixed event to be cleared
397  *
398  * RETURN:      Status
399  *
400  * DESCRIPTION: Clear an ACPI event (fixed)
401  *
402  ******************************************************************************/
403 acpi_status acpi_clear_event(u32 event)
404 {
405         acpi_status status = AE_OK;
406
407         ACPI_FUNCTION_TRACE(acpi_clear_event);
408
409         /* Decode the Fixed Event */
410
411         if (event > ACPI_EVENT_MAX) {
412                 return_ACPI_STATUS(AE_BAD_PARAMETER);
413         }
414
415         /*
416          * Clear the requested fixed event (By writing a one to the
417          * status register bit)
418          */
419         status =
420             acpi_set_register(acpi_gbl_fixed_event_info[event].
421                               status_register_id, 1);
422
423         return_ACPI_STATUS(status);
424 }
425
426 ACPI_EXPORT_SYMBOL(acpi_clear_event)
427
428 /*******************************************************************************
429  *
430  * FUNCTION:    acpi_clear_gpe
431  *
432  * PARAMETERS:  gpe_device      - Parent GPE Device
433  *              gpe_number      - GPE level within the GPE block
434  *              Flags           - Called from an ISR or not
435  *
436  * RETURN:      Status
437  *
438  * DESCRIPTION: Clear an ACPI event (general purpose)
439  *
440  ******************************************************************************/
441 acpi_status acpi_clear_gpe(acpi_handle gpe_device, u32 gpe_number, u32 flags)
442 {
443         acpi_status status = AE_OK;
444         struct acpi_gpe_event_info *gpe_event_info;
445
446         ACPI_FUNCTION_TRACE(acpi_clear_gpe);
447
448         /* Use semaphore lock if not executing at interrupt level */
449
450         if (flags & ACPI_NOT_ISR) {
451                 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
452                 if (ACPI_FAILURE(status)) {
453                         return_ACPI_STATUS(status);
454                 }
455         }
456
457         /* Ensure that we have a valid GPE number */
458
459         gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
460         if (!gpe_event_info) {
461                 status = AE_BAD_PARAMETER;
462                 goto unlock_and_exit;
463         }
464
465         status = acpi_hw_clear_gpe(gpe_event_info);
466
467       unlock_and_exit:
468         if (flags & ACPI_NOT_ISR) {
469                 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
470         }
471         return_ACPI_STATUS(status);
472 }
473
474 ACPI_EXPORT_SYMBOL(acpi_clear_gpe)
475
476 #ifdef ACPI_FUTURE_USAGE
477 /*******************************************************************************
478  *
479  * FUNCTION:    acpi_get_event_status
480  *
481  * PARAMETERS:  Event           - The fixed event
482  *              event_status    - Where the current status of the event will
483  *                                be returned
484  *
485  * RETURN:      Status
486  *
487  * DESCRIPTION: Obtains and returns the current status of the event
488  *
489  ******************************************************************************/
490 acpi_status acpi_get_event_status(u32 event, acpi_event_status * event_status)
491 {
492         acpi_status status = AE_OK;
493
494         ACPI_FUNCTION_TRACE(acpi_get_event_status);
495
496         if (!event_status) {
497                 return_ACPI_STATUS(AE_BAD_PARAMETER);
498         }
499
500         /* Decode the Fixed Event */
501
502         if (event > ACPI_EVENT_MAX) {
503                 return_ACPI_STATUS(AE_BAD_PARAMETER);
504         }
505
506         /* Get the status of the requested fixed event */
507
508         status =
509             acpi_get_register(acpi_gbl_fixed_event_info[event].
510                               status_register_id, event_status);
511
512         return_ACPI_STATUS(status);
513 }
514
515 ACPI_EXPORT_SYMBOL(acpi_get_event_status)
516
517 /*******************************************************************************
518  *
519  * FUNCTION:    acpi_get_gpe_status
520  *
521  * PARAMETERS:  gpe_device      - Parent GPE Device
522  *              gpe_number      - GPE level within the GPE block
523  *              Flags           - Called from an ISR or not
524  *              event_status    - Where the current status of the event will
525  *                                be returned
526  *
527  * RETURN:      Status
528  *
529  * DESCRIPTION: Get status of an event (general purpose)
530  *
531  ******************************************************************************/
532 acpi_status
533 acpi_get_gpe_status(acpi_handle gpe_device,
534                     u32 gpe_number, u32 flags, acpi_event_status * event_status)
535 {
536         acpi_status status = AE_OK;
537         struct acpi_gpe_event_info *gpe_event_info;
538
539         ACPI_FUNCTION_TRACE(acpi_get_gpe_status);
540
541         /* Use semaphore lock if not executing at interrupt level */
542
543         if (flags & ACPI_NOT_ISR) {
544                 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
545                 if (ACPI_FAILURE(status)) {
546                         return_ACPI_STATUS(status);
547                 }
548         }
549
550         /* Ensure that we have a valid GPE number */
551
552         gpe_event_info = acpi_ev_get_gpe_event_info(gpe_device, gpe_number);
553         if (!gpe_event_info) {
554                 status = AE_BAD_PARAMETER;
555                 goto unlock_and_exit;
556         }
557
558         /* Obtain status on the requested GPE number */
559
560         status = acpi_hw_get_gpe_status(gpe_event_info, event_status);
561
562       unlock_and_exit:
563         if (flags & ACPI_NOT_ISR) {
564                 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
565         }
566         return_ACPI_STATUS(status);
567 }
568
569 ACPI_EXPORT_SYMBOL(acpi_get_gpe_status)
570 #endif                          /*  ACPI_FUTURE_USAGE  */
571
572 /*******************************************************************************
573  *
574  * FUNCTION:    acpi_install_gpe_block
575  *
576  * PARAMETERS:  gpe_device          - Handle to the parent GPE Block Device
577  *              gpe_block_address   - Address and space_iD
578  *              register_count      - Number of GPE register pairs in the block
579  *              interrupt_number    - H/W interrupt for the block
580  *
581  * RETURN:      Status
582  *
583  * DESCRIPTION: Create and Install a block of GPE registers
584  *
585  ******************************************************************************/
586 acpi_status
587 acpi_install_gpe_block(acpi_handle gpe_device,
588                        struct acpi_generic_address *gpe_block_address,
589                        u32 register_count, u32 interrupt_number)
590 {
591         acpi_status status;
592         union acpi_operand_object *obj_desc;
593         struct acpi_namespace_node *node;
594         struct acpi_gpe_block_info *gpe_block;
595
596         ACPI_FUNCTION_TRACE(acpi_install_gpe_block);
597
598         if ((!gpe_device) || (!gpe_block_address) || (!register_count)) {
599                 return_ACPI_STATUS(AE_BAD_PARAMETER);
600         }
601
602         status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
603         if (ACPI_FAILURE(status)) {
604                 return (status);
605         }
606
607         node = acpi_ns_map_handle_to_node(gpe_device);
608         if (!node) {
609                 status = AE_BAD_PARAMETER;
610                 goto unlock_and_exit;
611         }
612
613         /*
614          * For user-installed GPE Block Devices, the gpe_block_base_number
615          * is always zero
616          */
617         status =
618             acpi_ev_create_gpe_block(node, gpe_block_address, register_count, 0,
619                                      interrupt_number, &gpe_block);
620         if (ACPI_FAILURE(status)) {
621                 goto unlock_and_exit;
622         }
623
624         /* Run the _PRW methods and enable the GPEs */
625
626         status = acpi_ev_initialize_gpe_block(node, gpe_block);
627         if (ACPI_FAILURE(status)) {
628                 goto unlock_and_exit;
629         }
630
631         /* Get the device_object attached to the node */
632
633         obj_desc = acpi_ns_get_attached_object(node);
634         if (!obj_desc) {
635
636                 /* No object, create a new one */
637
638                 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_DEVICE);
639                 if (!obj_desc) {
640                         status = AE_NO_MEMORY;
641                         goto unlock_and_exit;
642                 }
643
644                 status =
645                     acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_DEVICE);
646
647                 /* Remove local reference to the object */
648
649                 acpi_ut_remove_reference(obj_desc);
650
651                 if (ACPI_FAILURE(status)) {
652                         goto unlock_and_exit;
653                 }
654         }
655
656         /* Install the GPE block in the device_object */
657
658         obj_desc->device.gpe_block = gpe_block;
659
660       unlock_and_exit:
661         (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
662         return_ACPI_STATUS(status);
663 }
664
665 ACPI_EXPORT_SYMBOL(acpi_install_gpe_block)
666
667 /*******************************************************************************
668  *
669  * FUNCTION:    acpi_remove_gpe_block
670  *
671  * PARAMETERS:  gpe_device          - Handle to the parent GPE Block Device
672  *
673  * RETURN:      Status
674  *
675  * DESCRIPTION: Remove a previously installed block of GPE registers
676  *
677  ******************************************************************************/
678 acpi_status acpi_remove_gpe_block(acpi_handle gpe_device)
679 {
680         union acpi_operand_object *obj_desc;
681         acpi_status status;
682         struct acpi_namespace_node *node;
683
684         ACPI_FUNCTION_TRACE(acpi_remove_gpe_block);
685
686         if (!gpe_device) {
687                 return_ACPI_STATUS(AE_BAD_PARAMETER);
688         }
689
690         status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
691         if (ACPI_FAILURE(status)) {
692                 return (status);
693         }
694
695         node = acpi_ns_map_handle_to_node(gpe_device);
696         if (!node) {
697                 status = AE_BAD_PARAMETER;
698                 goto unlock_and_exit;
699         }
700
701         /* Get the device_object attached to the node */
702
703         obj_desc = acpi_ns_get_attached_object(node);
704         if (!obj_desc || !obj_desc->device.gpe_block) {
705                 return_ACPI_STATUS(AE_NULL_OBJECT);
706         }
707
708         /* Delete the GPE block (but not the device_object) */
709
710         status = acpi_ev_delete_gpe_block(obj_desc->device.gpe_block);
711         if (ACPI_SUCCESS(status)) {
712                 obj_desc->device.gpe_block = NULL;
713         }
714
715       unlock_and_exit:
716         (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
717         return_ACPI_STATUS(status);
718 }
719
720 ACPI_EXPORT_SYMBOL(acpi_remove_gpe_block)