2005-04-17 00:20:36 +02:00
|
|
|
/*
|
|
|
|
* pnpacpi -- PnP ACPI driver
|
|
|
|
*
|
|
|
|
* Copyright (c) 2004 Matthieu Castet <castet.matthieu@free.fr>
|
|
|
|
* Copyright (c) 2004 Li Shaohua <shaohua.li@intel.com>
|
2007-05-08 09:28:35 +02:00
|
|
|
*
|
2005-04-17 00:20:36 +02:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* 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; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
2007-05-08 09:28:35 +02:00
|
|
|
|
2011-10-27 00:06:20 +02:00
|
|
|
#include <linux/export.h>
|
2005-04-17 00:20:36 +02:00
|
|
|
#include <linux/acpi.h>
|
|
|
|
#include <linux/pnp.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 09:04:11 +01:00
|
|
|
#include <linux/slab.h>
|
2007-07-23 14:43:51 +02:00
|
|
|
#include <linux/mod_devicetable.h>
|
|
|
|
|
2008-04-29 00:33:51 +02:00
|
|
|
#include "../base.h"
|
2005-04-17 00:20:36 +02:00
|
|
|
#include "pnpacpi.h"
|
|
|
|
|
2010-09-18 19:11:09 +02:00
|
|
|
static int num;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Compatible Device IDs
|
|
|
|
*/
|
|
|
|
#define TEST_HEX(c) \
|
|
|
|
if (!(('0' <= (c) && (c) <= '9') || ('A' <= (c) && (c) <= 'F'))) \
|
|
|
|
return 0
|
|
|
|
#define TEST_ALPHA(c) \
|
2012-12-07 23:11:14 +01:00
|
|
|
if (!('A' <= (c) && (c) <= 'Z')) \
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0
|
2010-10-01 10:54:00 +02:00
|
|
|
static int __init ispnpidacpi(const char *id)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
TEST_ALPHA(id[0]);
|
|
|
|
TEST_ALPHA(id[1]);
|
|
|
|
TEST_ALPHA(id[2]);
|
|
|
|
TEST_HEX(id[3]);
|
|
|
|
TEST_HEX(id[4]);
|
|
|
|
TEST_HEX(id[5]);
|
|
|
|
TEST_HEX(id[6]);
|
|
|
|
if (id[7] != '\0')
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2008-04-29 00:34:05 +02:00
|
|
|
static int pnpacpi_get_resources(struct pnp_dev *dev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2008-08-20 00:53:47 +02:00
|
|
|
pnp_dbg(&dev->dev, "get resources\n");
|
2008-04-29 00:34:39 +02:00
|
|
|
return pnpacpi_parse_allocated_resource(dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2008-04-29 00:34:05 +02:00
|
|
|
static int pnpacpi_set_resources(struct pnp_dev *dev)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
2011-01-10 21:23:16 +01:00
|
|
|
struct acpi_device *acpi_dev;
|
|
|
|
acpi_handle handle;
|
2014-04-30 22:36:33 +02:00
|
|
|
int ret = 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-08-20 00:53:47 +02:00
|
|
|
pnp_dbg(&dev->dev, "set resources\n");
|
2011-01-10 21:23:16 +01:00
|
|
|
|
2014-07-23 01:03:06 +02:00
|
|
|
acpi_dev = ACPI_COMPANION(&dev->dev);
|
|
|
|
if (!acpi_dev) {
|
2011-01-10 21:23:16 +01:00
|
|
|
dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2012-11-30 13:05:05 +01:00
|
|
|
if (WARN_ON_ONCE(acpi_dev != dev->data))
|
|
|
|
dev->data = acpi_dev;
|
|
|
|
|
2014-07-23 01:03:06 +02:00
|
|
|
handle = acpi_dev->handle;
|
2014-04-30 22:36:33 +02:00
|
|
|
if (acpi_has_method(handle, METHOD_NAME__SRS)) {
|
|
|
|
struct acpi_buffer buffer;
|
|
|
|
|
|
|
|
ret = pnpacpi_build_resource_template(dev, &buffer);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = pnpacpi_encode_resources(dev, &buffer);
|
|
|
|
if (!ret) {
|
|
|
|
acpi_status status;
|
|
|
|
|
|
|
|
status = acpi_set_current_resources(handle, &buffer);
|
|
|
|
if (ACPI_FAILURE(status))
|
|
|
|
ret = -EIO;
|
|
|
|
}
|
2005-04-17 00:20:36 +02:00
|
|
|
kfree(buffer.pointer);
|
|
|
|
}
|
2014-07-23 01:03:06 +02:00
|
|
|
if (!ret && acpi_device_power_manageable(acpi_dev))
|
|
|
|
ret = acpi_device_set_power(acpi_dev, ACPI_STATE_D0);
|
2014-04-30 22:36:33 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pnpacpi_disable_resources(struct pnp_dev *dev)
|
|
|
|
{
|
2011-01-10 21:23:16 +01:00
|
|
|
struct acpi_device *acpi_dev;
|
2014-04-30 22:36:33 +02:00
|
|
|
acpi_status status;
|
Enable PNPACPI _PSx Support, v3
(This is an update to the patch presented earlier in
http://lkml.org/lkml/2008/12/8/284, with new error handling.)
This patch sets the power of PnP ACPI devices to D0 when they
are activated and to D3 when they are disabled. The latter is
in correspondence with the ACPI 3.0 specification, whereas the
former is added in order to be able to power up a device after
it has been previously disabled (or when booting up a system).
(As a consequence, the patch makes the PnP ACPI code more ACPI
compliant.)
Section 6.2.2 of the ACPI Specification (at least versions 1.0b
and 3.0a) states: "Prior to running this control method [_DIS],
the OS[PM] will have already put the device in the D3 state."
Unfortunately, there is no clear statement as to when to put
a device in the D0 state. :-( Therefore, the patch executes the
method calls as _PS3/_DIS and _SRS/_PS0. What is clear: "If the
device is disabled, _SRS enables the device at the specified
resources." (From the ACPI 3.0a Specification.)
The patch fixes a problem with some IBM ThinkPads (at least the
600E and the 600X) where the serial ports have a dedicated
power source that needs to be brought up before the serial port
can be used. Without this patch, the serial port is enabled
but has no power. (In the past, the tpctl utility had to be
utilized to turn on the power, but support for this feature
stopped with version 5.9 as it did not support the more recent
kernel versions.)
The error handlers that handle any errors that can occur during
the power up/power down phases return the error codes to the
caller directly. Comments welcome! :-)
No regressions were observed on hardware that does not require
this patch.
The patch is applied against 2.6.27.x.
Signed-off-by: Witold Szczeponik <Witold.Szczeponik@gmx.net>
Acked-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2009-03-30 19:31:06 +02:00
|
|
|
|
|
|
|
dev_dbg(&dev->dev, "disable resources\n");
|
2007-05-08 09:28:35 +02:00
|
|
|
|
2014-07-23 01:03:06 +02:00
|
|
|
acpi_dev = ACPI_COMPANION(&dev->dev);
|
|
|
|
if (!acpi_dev) {
|
2011-01-10 21:23:16 +01:00
|
|
|
dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
/* acpi_unregister_gsi(pnp_irq(dev, 0)); */
|
2014-07-23 01:03:06 +02:00
|
|
|
if (acpi_device_power_manageable(acpi_dev))
|
|
|
|
acpi_device_set_power(acpi_dev, ACPI_STATE_D3_COLD);
|
2014-04-30 22:36:33 +02:00
|
|
|
|
2014-07-23 01:03:06 +02:00
|
|
|
/* continue even if acpi_device_set_power() fails */
|
|
|
|
status = acpi_evaluate_object(acpi_dev->handle, "_DIS", NULL, NULL);
|
2014-04-30 22:36:33 +02:00
|
|
|
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND)
|
|
|
|
return -ENODEV;
|
|
|
|
|
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
2007-07-28 09:33:16 +02:00
|
|
|
#ifdef CONFIG_ACPI_SLEEP
|
2010-06-29 22:49:24 +02:00
|
|
|
static bool pnpacpi_can_wakeup(struct pnp_dev *dev)
|
|
|
|
{
|
2014-07-23 01:03:06 +02:00
|
|
|
struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev);
|
2011-01-10 21:23:16 +01:00
|
|
|
|
2014-07-23 01:03:06 +02:00
|
|
|
if (!acpi_dev) {
|
2011-01-10 21:23:16 +01:00
|
|
|
dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
|
|
|
|
return false;
|
|
|
|
}
|
2010-06-29 22:49:24 +02:00
|
|
|
|
2014-07-23 01:03:06 +02:00
|
|
|
return acpi_bus_can_wakeup(acpi_dev->handle);
|
2010-06-29 22:49:24 +02:00
|
|
|
}
|
|
|
|
|
2007-07-20 04:03:20 +02:00
|
|
|
static int pnpacpi_suspend(struct pnp_dev *dev, pm_message_t state)
|
|
|
|
{
|
2014-07-23 01:03:06 +02:00
|
|
|
struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev);
|
2011-01-10 21:23:16 +01:00
|
|
|
int error = 0;
|
|
|
|
|
2014-07-23 01:03:06 +02:00
|
|
|
if (!acpi_dev) {
|
2011-01-10 21:23:16 +01:00
|
|
|
dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
|
|
|
|
return 0;
|
|
|
|
}
|
2007-10-17 08:31:06 +02:00
|
|
|
|
2010-06-29 22:49:24 +02:00
|
|
|
if (device_can_wakeup(&dev->dev)) {
|
2017-06-24 01:54:39 +02:00
|
|
|
error = acpi_pm_set_device_wakeup(&dev->dev,
|
|
|
|
device_may_wakeup(&dev->dev));
|
2011-01-10 21:23:16 +01:00
|
|
|
if (error)
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2014-07-23 01:03:06 +02:00
|
|
|
if (acpi_device_power_manageable(acpi_dev)) {
|
2012-06-23 04:23:48 +02:00
|
|
|
int power_state = acpi_pm_device_sleep_state(&dev->dev, NULL,
|
2013-07-30 14:36:20 +02:00
|
|
|
ACPI_STATE_D3_COLD);
|
2011-01-10 21:23:16 +01:00
|
|
|
if (power_state < 0)
|
|
|
|
power_state = (state.event == PM_EVENT_ON) ?
|
2013-07-30 14:36:20 +02:00
|
|
|
ACPI_STATE_D0 : ACPI_STATE_D3_COLD;
|
2011-01-10 21:23:16 +01:00
|
|
|
|
|
|
|
/*
|
2014-07-23 01:03:06 +02:00
|
|
|
* acpi_device_set_power() can fail (keyboard port can't be
|
2011-01-10 21:23:16 +01:00
|
|
|
* powered-down?), and in any case, our return value is ignored
|
|
|
|
* by pnp_bus_suspend(). Hence we don't revert the wakeup
|
|
|
|
* setting if the set_power fails.
|
|
|
|
*/
|
2014-07-23 01:03:06 +02:00
|
|
|
error = acpi_device_set_power(acpi_dev, power_state);
|
2010-06-29 22:49:24 +02:00
|
|
|
}
|
2011-01-10 21:23:16 +01:00
|
|
|
|
|
|
|
return error;
|
2007-07-20 04:03:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int pnpacpi_resume(struct pnp_dev *dev)
|
|
|
|
{
|
2014-07-23 01:03:06 +02:00
|
|
|
struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev);
|
2011-01-10 21:23:16 +01:00
|
|
|
int error = 0;
|
|
|
|
|
2014-07-23 01:03:06 +02:00
|
|
|
if (!acpi_dev) {
|
2011-01-10 21:23:16 +01:00
|
|
|
dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2009-11-18 01:05:14 +01:00
|
|
|
|
2010-06-29 22:49:24 +02:00
|
|
|
if (device_may_wakeup(&dev->dev))
|
2017-06-24 01:54:39 +02:00
|
|
|
acpi_pm_set_device_wakeup(&dev->dev, false);
|
2011-01-10 21:23:16 +01:00
|
|
|
|
2014-07-23 01:03:06 +02:00
|
|
|
if (acpi_device_power_manageable(acpi_dev))
|
|
|
|
error = acpi_device_set_power(acpi_dev, ACPI_STATE_D0);
|
2011-01-10 21:23:16 +01:00
|
|
|
|
|
|
|
return error;
|
2007-07-20 04:03:20 +02:00
|
|
|
}
|
2007-07-28 09:33:16 +02:00
|
|
|
#endif
|
2007-07-20 04:03:20 +02:00
|
|
|
|
2009-11-18 01:05:19 +01:00
|
|
|
struct pnp_protocol pnpacpi_protocol = {
|
2007-07-26 19:41:21 +02:00
|
|
|
.name = "Plug and Play ACPI",
|
|
|
|
.get = pnpacpi_get_resources,
|
|
|
|
.set = pnpacpi_set_resources,
|
2005-04-17 00:20:36 +02:00
|
|
|
.disable = pnpacpi_disable_resources,
|
2007-07-28 09:33:16 +02:00
|
|
|
#ifdef CONFIG_ACPI_SLEEP
|
2010-06-29 22:49:24 +02:00
|
|
|
.can_wakeup = pnpacpi_can_wakeup,
|
2007-07-20 04:03:20 +02:00
|
|
|
.suspend = pnpacpi_suspend,
|
|
|
|
.resume = pnpacpi_resume,
|
2007-07-28 09:33:16 +02:00
|
|
|
#endif
|
2005-04-17 00:20:36 +02:00
|
|
|
};
|
2009-11-18 01:05:19 +01:00
|
|
|
EXPORT_SYMBOL(pnpacpi_protocol);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2015-09-09 23:59:42 +02:00
|
|
|
static const char *__init pnpacpi_get_id(struct acpi_device *device)
|
2010-09-18 19:11:09 +02:00
|
|
|
{
|
|
|
|
struct acpi_hardware_id *id;
|
|
|
|
|
|
|
|
list_for_each_entry(id, &device->pnp.ids, list) {
|
|
|
|
if (ispnpidacpi(id->id))
|
|
|
|
return id->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
static int __init pnpacpi_add_device(struct acpi_device *device)
|
|
|
|
{
|
|
|
|
struct pnp_dev *dev;
|
2015-09-09 23:59:42 +02:00
|
|
|
const char *pnpid;
|
2009-09-21 21:35:19 +02:00
|
|
|
struct acpi_hardware_id *id;
|
2013-12-15 13:10:11 +01:00
|
|
|
int error;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2012-11-23 21:07:12 +01:00
|
|
|
/* Skip devices that are already bound */
|
|
|
|
if (device->physical_node_count)
|
|
|
|
return 0;
|
|
|
|
|
2008-08-11 07:40:22 +02:00
|
|
|
/*
|
|
|
|
* If a PnPacpi device is not present , the device
|
|
|
|
* driver should not be loaded.
|
|
|
|
*/
|
2013-09-03 02:32:08 +02:00
|
|
|
if (!acpi_has_method(device->handle, "_CRS"))
|
2010-09-18 19:11:09 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
pnpid = pnpacpi_get_id(device);
|
|
|
|
if (!pnpid)
|
|
|
|
return 0;
|
|
|
|
|
ACPI / PNP: use device ID list for PNPACPI device enumeration
ACPI can be used to enumerate PNP devices, but the code does not
handle this in the right way currently. Namely, if an ACPI device
object
1. Has a _CRS method,
2. Has an identification of
"three capital characters followed by four hex digits",
3. Is not in the excluded IDs list,
it will be enumerated to PNP bus (that is, a PNP device object will
be create for it). This means that, actually, the PNP bus type is
used as the default bus type for enumerating _HID devices in ACPI.
However, more and more _HID devices need to be enumerated to the
platform bus instead (that is, platform device objects need to be
created for them). As a result, the device ID list in acpi_platform.c
is used to enforce creating platform device objects rather than PNP
device objects for matching devices. That list has been continuously
growing recently, unfortunately, and it is pretty much guaranteed to
grow even more in the future.
To address that problem it is better to enumerate _HID devices
as platform devices by default. To this end, change the way of
enumerating PNP devices by adding a PNP ACPI scan handler that
will use a device ID list to create PNP devices for the ACPI
device objects whose device IDs are present in that list.
The initial device ID list in the PNP ACPI scan handler contains
all of the pnp_device_id strings from all the existing PNP drivers,
so this change should be transparent to the PNP core and all of the
PNP drivers. Still, in the future it should be possible to reduce
its size by converting PNP drivers that need not be PNP for any
technical reasons into platform drivers.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[rjw: Rewrote the changelog, modified the PNP ACPI scan handler code]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2014-05-30 04:23:01 +02:00
|
|
|
if (!device->status.present)
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
|
2010-09-18 19:11:09 +02:00
|
|
|
dev = pnp_alloc_dev(&pnpacpi_protocol, num, pnpid);
|
2008-04-29 00:33:54 +02:00
|
|
|
if (!dev)
|
2005-04-17 00:20:36 +02:00
|
|
|
return -ENOMEM;
|
2008-04-29 00:33:54 +02:00
|
|
|
|
2015-03-13 01:45:49 +01:00
|
|
|
ACPI_COMPANION_SET(&dev->dev, device);
|
2009-11-18 01:05:14 +01:00
|
|
|
dev->data = device;
|
2007-07-26 19:41:21 +02:00
|
|
|
/* .enabled means the device can decode the resources */
|
2005-04-17 00:20:36 +02:00
|
|
|
dev->active = device->status.enabled;
|
2013-09-03 02:32:08 +02:00
|
|
|
if (acpi_has_method(device->handle, "_SRS"))
|
2005-04-17 00:20:36 +02:00
|
|
|
dev->capabilities |= PNP_CONFIGURABLE;
|
|
|
|
dev->capabilities |= PNP_READ;
|
2008-01-13 01:37:49 +01:00
|
|
|
if (device->flags.dynamic_status && (dev->capabilities & PNP_CONFIGURABLE))
|
2005-04-17 00:20:36 +02:00
|
|
|
dev->capabilities |= PNP_WRITE;
|
|
|
|
if (device->flags.removable)
|
|
|
|
dev->capabilities |= PNP_REMOVABLE;
|
2013-09-03 02:32:08 +02:00
|
|
|
if (acpi_has_method(device->handle, "_DIS"))
|
2005-04-17 00:20:36 +02:00
|
|
|
dev->capabilities |= PNP_DISABLE;
|
|
|
|
|
|
|
|
if (strlen(acpi_device_name(device)))
|
|
|
|
strncpy(dev->name, acpi_device_name(device), sizeof(dev->name));
|
|
|
|
else
|
|
|
|
strncpy(dev->name, acpi_device_bid(device), sizeof(dev->name));
|
|
|
|
|
2008-04-29 00:34:39 +02:00
|
|
|
if (dev->active)
|
|
|
|
pnpacpi_parse_allocated_resource(dev);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2008-04-29 00:34:39 +02:00
|
|
|
if (dev->capabilities & PNP_CONFIGURABLE)
|
|
|
|
pnpacpi_parse_resource_option_data(dev);
|
2007-05-08 09:28:35 +02:00
|
|
|
|
2009-09-21 21:35:19 +02:00
|
|
|
list_for_each_entry(id, &device->pnp.ids, list) {
|
2010-09-18 19:11:09 +02:00
|
|
|
if (!strcmp(id->id, pnpid))
|
2009-09-21 21:35:19 +02:00
|
|
|
continue;
|
|
|
|
if (!ispnpidacpi(id->id))
|
|
|
|
continue;
|
|
|
|
pnp_add_id(dev, id->id);
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clear out the damaged flags */
|
|
|
|
if (!dev->active)
|
2008-04-29 00:34:09 +02:00
|
|
|
pnp_init_resources(dev);
|
2013-12-15 13:10:11 +01:00
|
|
|
|
|
|
|
error = pnp_add_device(dev);
|
|
|
|
if (error) {
|
|
|
|
put_device(&dev->dev);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2007-07-26 19:41:20 +02:00
|
|
|
num++;
|
2005-04-17 00:20:36 +02:00
|
|
|
|
2015-03-13 01:45:49 +01:00
|
|
|
return 0;
|
2005-04-17 00:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle,
|
2007-07-26 19:41:20 +02:00
|
|
|
u32 lvl, void *context,
|
|
|
|
void **rv)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
struct acpi_device *device;
|
|
|
|
|
ACPI / PNP: use device ID list for PNPACPI device enumeration
ACPI can be used to enumerate PNP devices, but the code does not
handle this in the right way currently. Namely, if an ACPI device
object
1. Has a _CRS method,
2. Has an identification of
"three capital characters followed by four hex digits",
3. Is not in the excluded IDs list,
it will be enumerated to PNP bus (that is, a PNP device object will
be create for it). This means that, actually, the PNP bus type is
used as the default bus type for enumerating _HID devices in ACPI.
However, more and more _HID devices need to be enumerated to the
platform bus instead (that is, platform device objects need to be
created for them). As a result, the device ID list in acpi_platform.c
is used to enforce creating platform device objects rather than PNP
device objects for matching devices. That list has been continuously
growing recently, unfortunately, and it is pretty much guaranteed to
grow even more in the future.
To address that problem it is better to enumerate _HID devices
as platform devices by default. To this end, change the way of
enumerating PNP devices by adding a PNP ACPI scan handler that
will use a device ID list to create PNP devices for the ACPI
device objects whose device IDs are present in that list.
The initial device ID list in the PNP ACPI scan handler contains
all of the pnp_device_id strings from all the existing PNP drivers,
so this change should be transparent to the PNP core and all of the
PNP drivers. Still, in the future it should be possible to reduce
its size by converting PNP drivers that need not be PNP for any
technical reasons into platform drivers.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[rjw: Rewrote the changelog, modified the PNP ACPI scan handler code]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2014-05-30 04:23:01 +02:00
|
|
|
if (acpi_bus_get_device(handle, &device))
|
2005-04-17 00:20:36 +02:00
|
|
|
return AE_CTRL_DEPTH;
|
ACPI / PNP: use device ID list for PNPACPI device enumeration
ACPI can be used to enumerate PNP devices, but the code does not
handle this in the right way currently. Namely, if an ACPI device
object
1. Has a _CRS method,
2. Has an identification of
"three capital characters followed by four hex digits",
3. Is not in the excluded IDs list,
it will be enumerated to PNP bus (that is, a PNP device object will
be create for it). This means that, actually, the PNP bus type is
used as the default bus type for enumerating _HID devices in ACPI.
However, more and more _HID devices need to be enumerated to the
platform bus instead (that is, platform device objects need to be
created for them). As a result, the device ID list in acpi_platform.c
is used to enforce creating platform device objects rather than PNP
device objects for matching devices. That list has been continuously
growing recently, unfortunately, and it is pretty much guaranteed to
grow even more in the future.
To address that problem it is better to enumerate _HID devices
as platform devices by default. To this end, change the way of
enumerating PNP devices by adding a PNP ACPI scan handler that
will use a device ID list to create PNP devices for the ACPI
device objects whose device IDs are present in that list.
The initial device ID list in the PNP ACPI scan handler contains
all of the pnp_device_id strings from all the existing PNP drivers,
so this change should be transparent to the PNP core and all of the
PNP drivers. Still, in the future it should be possible to reduce
its size by converting PNP drivers that need not be PNP for any
technical reasons into platform drivers.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
[rjw: Rewrote the changelog, modified the PNP ACPI scan handler code]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
2014-05-30 04:23:01 +02:00
|
|
|
if (acpi_is_pnp_device(device))
|
|
|
|
pnpacpi_add_device(device);
|
2005-04-17 00:20:36 +02:00
|
|
|
return AE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pnpacpi_disabled __initdata;
|
2005-11-07 10:01:48 +01:00
|
|
|
static int __init pnpacpi_init(void)
|
2005-04-17 00:20:36 +02:00
|
|
|
{
|
|
|
|
if (acpi_disabled || pnpacpi_disabled) {
|
2008-08-20 00:53:26 +02:00
|
|
|
printk(KERN_INFO "pnp: PnP ACPI: disabled\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2008-08-20 00:53:26 +02:00
|
|
|
printk(KERN_INFO "pnp: PnP ACPI init\n");
|
2005-04-17 00:20:36 +02:00
|
|
|
pnp_register_protocol(&pnpacpi_protocol);
|
|
|
|
acpi_get_devices(NULL, pnpacpi_add_device_handler, NULL, NULL);
|
2008-08-20 00:53:26 +02:00
|
|
|
printk(KERN_INFO "pnp: PnP ACPI: found %d devices\n", num);
|
2007-05-08 09:35:54 +02:00
|
|
|
pnp_platform_devices = 1;
|
2005-04-17 00:20:36 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2007-07-26 19:41:20 +02:00
|
|
|
|
2008-10-10 17:00:17 +02:00
|
|
|
fs_initcall(pnpacpi_init);
|
2005-04-17 00:20:36 +02:00
|
|
|
|
|
|
|
static int __init pnpacpi_setup(char *str)
|
|
|
|
{
|
|
|
|
if (str == NULL)
|
|
|
|
return 1;
|
|
|
|
if (!strncmp(str, "off", 3))
|
|
|
|
pnpacpi_disabled = 1;
|
|
|
|
return 1;
|
|
|
|
}
|
2007-07-26 19:41:20 +02:00
|
|
|
|
2005-04-17 00:20:36 +02:00
|
|
|
__setup("pnpacpi=", pnpacpi_setup);
|