22 #include <linux/export.h>
25 #include <linux/slab.h>
49 static inline int __init is_exclusive_device(
struct acpi_device *
dev)
58 if (!(('0' <= (c) && (c) <= '9') || ('A' <= (c) && (c) <= 'F'))) \
60 #define TEST_ALPHA(c) \
61 if (!('@' <= (c) || (c) <= 'Z')) \
63 static int __init ispnpidacpi(
const char *
id)
77 static int pnpacpi_get_resources(
struct pnp_dev *dev)
83 static int pnpacpi_set_resources(
struct pnp_dev *dev)
85 struct acpi_device *acpi_dev;
92 handle = DEVICE_ACPI_HANDLE(&dev->
dev);
94 dev_dbg(&dev->
dev,
"ACPI device not found in %s!\n", __func__);
117 static int pnpacpi_disable_resources(
struct pnp_dev *dev)
119 struct acpi_device *acpi_dev;
125 handle = DEVICE_ACPI_HANDLE(&dev->
dev);
127 dev_dbg(&dev->
dev,
"ACPI device not found in %s!\n", __func__);
141 #ifdef CONFIG_ACPI_SLEEP
142 static bool pnpacpi_can_wakeup(
struct pnp_dev *dev)
144 struct acpi_device *acpi_dev;
147 handle = DEVICE_ACPI_HANDLE(&dev->
dev);
149 dev_dbg(&dev->
dev,
"ACPI device not found in %s!\n", __func__);
158 struct acpi_device *acpi_dev;
162 handle = DEVICE_ACPI_HANDLE(&dev->
dev);
164 dev_dbg(&dev->
dev,
"ACPI device not found in %s!\n", __func__);
168 if (device_can_wakeup(&dev->
dev)) {
169 error = acpi_pm_device_sleep_wake(&dev->
dev,
170 device_may_wakeup(&dev->
dev));
194 static int pnpacpi_resume(
struct pnp_dev *dev)
196 struct acpi_device *acpi_dev;
201 dev_dbg(&dev->
dev,
"ACPI device not found in %s!\n", __func__);
205 if (device_may_wakeup(&dev->
dev))
206 acpi_pm_device_sleep_wake(&dev->
dev,
false);
216 .name =
"Plug and Play ACPI",
217 .get = pnpacpi_get_resources,
218 .set = pnpacpi_set_resources,
219 .disable = pnpacpi_disable_resources,
220 #ifdef CONFIG_ACPI_SLEEP
221 .can_wakeup = pnpacpi_can_wakeup,
222 .suspend = pnpacpi_suspend,
223 .resume = pnpacpi_resume,
228 static char *
__init pnpacpi_get_id(
struct acpi_device *
device)
230 struct acpi_hardware_id *
id;
233 if (ispnpidacpi(id->id))
240 static int __init pnpacpi_add_device(
struct acpi_device *device)
246 struct acpi_hardware_id *
id;
256 pnpid = pnpacpi_get_id(device);
260 if (is_exclusive_device(device) || !device->status.present)
269 dev->
active = device->status.enabled;
276 if (device->flags.removable)
282 if (
strlen(acpi_device_name(device)))
294 if (!
strcmp(id->id, pnpid))
296 if (!ispnpidacpi(id->id))
314 struct acpi_device *device;
317 pnpacpi_add_device(device);
323 static int __init acpi_pnp_match(
struct device *dev,
void *_pnp)
325 struct acpi_device *acpi = to_acpi_device(dev);
329 return !acpi->physical_node_count
336 struct acpi_device *acpi;
343 acpi = to_acpi_device(adev);
344 *handle = acpi->handle;
354 .find_device = acpi_pnp_find_device,
358 static int __init pnpacpi_init(
void)
376 static int __init pnpacpi_setup(
char *
str)
381 pnpacpi_disabled = 1;
385 __setup(
"pnpacpi=", pnpacpi_setup);