forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iwlwifi: acpi: add common code to read from ACPI
There are many places where the same process of invoking a method from ACPI is used, causing a lot of duplicate code. To improve this, introduce a new function to get an ACPI object by invoking an ACPI method that can be reused. Additionally, since this function needs to be called when we only have the trans, the opmode or the device, introduce a new debug macro that gets the device as a parameter so it can be used in the new function. Signed-off-by: Luca Coelho <[email protected]>
- Loading branch information
1 parent
417795a
commit 813df5c
Showing
7 changed files
with
211 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/****************************************************************************** | ||
* | ||
* This file is provided under a dual BSD/GPLv2 license. When using or | ||
* redistributing this file, you may do so under either license. | ||
* | ||
* GPL LICENSE SUMMARY | ||
* | ||
* Copyright(c) 2017 Intel Deutschland GmbH | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of version 2 of the GNU General Public License as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; | ||
* | ||
* The full GNU General Public License is included in this distribution | ||
* in the file called COPYING. | ||
* | ||
* Contact Information: | ||
* Intel Linux Wireless <[email protected]> | ||
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
* | ||
* BSD LICENSE | ||
* | ||
* Copyright(c) 2017 Intel Deutschland GmbH | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* * Neither the name Intel Corporation nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
*****************************************************************************/ | ||
|
||
#include "iwl-drv.h" | ||
#include "iwl-debug.h" | ||
#include "acpi.h" | ||
|
||
void *iwl_acpi_get_object(struct device *dev, acpi_string method) | ||
{ | ||
acpi_handle root_handle; | ||
acpi_handle handle; | ||
struct acpi_buffer buf = {ACPI_ALLOCATE_BUFFER, NULL}; | ||
acpi_status status; | ||
|
||
root_handle = ACPI_HANDLE(dev); | ||
if (!root_handle) { | ||
IWL_DEBUG_DEV_RADIO(dev, | ||
"Could not retrieve root port ACPI handle\n"); | ||
return ERR_PTR(-ENOENT); | ||
} | ||
|
||
/* Get the method's handle */ | ||
status = acpi_get_handle(root_handle, method, &handle); | ||
if (ACPI_FAILURE(status)) { | ||
IWL_DEBUG_DEV_RADIO(dev, "%s method not found\n", method); | ||
return ERR_PTR(-ENOENT); | ||
} | ||
|
||
/* Call the method with no arguments */ | ||
status = acpi_evaluate_object(handle, NULL, NULL, &buf); | ||
if (ACPI_FAILURE(status)) { | ||
IWL_DEBUG_DEV_RADIO(dev, "%s invocation failed (0x%x)\n", | ||
method, status); | ||
return ERR_PTR(-ENOENT); | ||
} | ||
|
||
return buf.pointer; | ||
} | ||
IWL_EXPORT_SYMBOL(iwl_acpi_get_object); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/****************************************************************************** | ||
* | ||
* This file is provided under a dual BSD/GPLv2 license. When using or | ||
* redistributing this file, you may do so under either license. | ||
* | ||
* GPL LICENSE SUMMARY | ||
* | ||
* Copyright(c) 2017 Intel Deutschland GmbH | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of version 2 of the GNU General Public License as | ||
* published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; | ||
* | ||
* The full GNU General Public License is included in this distribution | ||
* in the file called COPYING. | ||
* | ||
* Contact Information: | ||
* Intel Linux Wireless <[email protected]> | ||
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | ||
* | ||
* BSD LICENSE | ||
* | ||
* Copyright(c) 2017 Intel Deutschland GmbH | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* | ||
* * Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* * Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in | ||
* the documentation and/or other materials provided with the | ||
* distribution. | ||
* * Neither the name Intel Corporation nor the names of its | ||
* contributors may be used to endorse or promote products derived | ||
* from this software without specific prior written permission. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
* | ||
*****************************************************************************/ | ||
#ifndef __iwl_fw_acpi__ | ||
#define __iwl_fw_acpi__ | ||
|
||
#include <linux/acpi.h> | ||
|
||
#ifdef CONFIG_ACPI | ||
|
||
void *iwl_acpi_get_object(struct device *dev, acpi_string method); | ||
|
||
#else /* CONFIG_ACPI */ | ||
|
||
static inline void *iwl_acpi_get_object(struct device *dev, acpi_string method) | ||
{ | ||
return ERR_PTR(-ENOENT); | ||
} | ||
|
||
#endif /* CONFIG_ACPI */ | ||
#endif /* __iwl_fw_acpi__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.