Lines Matching +full:device +full:- +full:handle

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * pnpacpi -- PnP ACPI driver
21 * Compatible Device IDs
45 pnp_dbg(&dev->dev, "get resources\n"); in pnpacpi_get_resources()
52 acpi_handle handle; in pnpacpi_set_resources() local
55 pnp_dbg(&dev->dev, "set resources\n"); in pnpacpi_set_resources()
57 acpi_dev = ACPI_COMPANION(&dev->dev); in pnpacpi_set_resources()
59 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); in pnpacpi_set_resources()
60 return -ENODEV; in pnpacpi_set_resources()
63 if (WARN_ON_ONCE(acpi_dev != dev->data)) in pnpacpi_set_resources()
64 dev->data = acpi_dev; in pnpacpi_set_resources()
66 handle = acpi_dev->handle; in pnpacpi_set_resources()
67 if (acpi_has_method(handle, METHOD_NAME__SRS)) { in pnpacpi_set_resources()
78 status = acpi_set_current_resources(handle, &buffer); in pnpacpi_set_resources()
80 ret = -EIO; in pnpacpi_set_resources()
95 dev_dbg(&dev->dev, "disable resources\n"); in pnpacpi_disable_resources()
97 acpi_dev = ACPI_COMPANION(&dev->dev); in pnpacpi_disable_resources()
99 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); in pnpacpi_disable_resources()
108 status = acpi_evaluate_object(acpi_dev->handle, "_DIS", NULL, NULL); in pnpacpi_disable_resources()
110 return -ENODEV; in pnpacpi_disable_resources()
118 struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev); in pnpacpi_can_wakeup()
121 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); in pnpacpi_can_wakeup()
125 return acpi_bus_can_wakeup(acpi_dev->handle); in pnpacpi_can_wakeup()
130 struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev); in pnpacpi_suspend()
134 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); in pnpacpi_suspend()
138 if (device_can_wakeup(&dev->dev)) { in pnpacpi_suspend()
139 error = acpi_pm_set_device_wakeup(&dev->dev, in pnpacpi_suspend()
140 device_may_wakeup(&dev->dev)); in pnpacpi_suspend()
146 int power_state = acpi_pm_device_sleep_state(&dev->dev, NULL, in pnpacpi_suspend()
154 * powered-down?), and in any case, our return value is ignored in pnpacpi_suspend()
166 struct acpi_device *acpi_dev = ACPI_COMPANION(&dev->dev); in pnpacpi_resume()
170 dev_dbg(&dev->dev, "ACPI device not found in %s!\n", __func__); in pnpacpi_resume()
171 return -ENODEV; in pnpacpi_resume()
174 if (device_may_wakeup(&dev->dev)) in pnpacpi_resume()
175 acpi_pm_set_device_wakeup(&dev->dev, false); in pnpacpi_resume()
197 static const char *__init pnpacpi_get_id(struct acpi_device *device) in pnpacpi_get_id() argument
201 list_for_each_entry(id, &device->pnp.ids, list) { in pnpacpi_get_id()
202 if (ispnpidacpi(id->id)) in pnpacpi_get_id()
203 return id->id; in pnpacpi_get_id()
209 static int __init pnpacpi_add_device(struct acpi_device *device) in pnpacpi_add_device() argument
217 if (device->physical_node_count) in pnpacpi_add_device()
221 * If a PnPacpi device is not present , the device in pnpacpi_add_device()
224 if (!acpi_has_method(device->handle, "_CRS")) in pnpacpi_add_device()
227 pnpid = pnpacpi_get_id(device); in pnpacpi_add_device()
231 if (!device->status.present) in pnpacpi_add_device()
236 return -ENOMEM; in pnpacpi_add_device()
238 ACPI_COMPANION_SET(&dev->dev, device); in pnpacpi_add_device()
239 dev->data = device; in pnpacpi_add_device()
240 /* .enabled means the device can decode the resources */ in pnpacpi_add_device()
241 dev->active = device->status.enabled; in pnpacpi_add_device()
242 if (acpi_has_method(device->handle, "_SRS")) in pnpacpi_add_device()
243 dev->capabilities |= PNP_CONFIGURABLE; in pnpacpi_add_device()
244 dev->capabilities |= PNP_READ; in pnpacpi_add_device()
245 if (device->flags.dynamic_status && (dev->capabilities & PNP_CONFIGURABLE)) in pnpacpi_add_device()
246 dev->capabilities |= PNP_WRITE; in pnpacpi_add_device()
247 if (device->flags.removable) in pnpacpi_add_device()
248 dev->capabilities |= PNP_REMOVABLE; in pnpacpi_add_device()
249 if (acpi_has_method(device->handle, "_DIS")) in pnpacpi_add_device()
250 dev->capabilities |= PNP_DISABLE; in pnpacpi_add_device()
252 if (strlen(acpi_device_name(device))) in pnpacpi_add_device()
253 strscpy(dev->name, acpi_device_name(device), sizeof(dev->name)); in pnpacpi_add_device()
255 strscpy(dev->name, acpi_device_bid(device), sizeof(dev->name)); in pnpacpi_add_device()
257 if (dev->active) in pnpacpi_add_device()
260 if (dev->capabilities & PNP_CONFIGURABLE) in pnpacpi_add_device()
263 list_for_each_entry(id, &device->pnp.ids, list) { in pnpacpi_add_device()
264 if (!strcmp(id->id, pnpid)) in pnpacpi_add_device()
266 if (!ispnpidacpi(id->id)) in pnpacpi_add_device()
268 pnp_add_id(dev, id->id); in pnpacpi_add_device()
272 if (!dev->active) in pnpacpi_add_device()
277 put_device(&dev->dev); in pnpacpi_add_device()
286 static acpi_status __init pnpacpi_add_device_handler(acpi_handle handle, in pnpacpi_add_device_handler() argument
290 struct acpi_device *device = acpi_fetch_acpi_dev(handle); in pnpacpi_add_device_handler() local
292 if (!device) in pnpacpi_add_device_handler()
294 if (acpi_is_pnp_device(device)) in pnpacpi_add_device_handler()
295 pnpacpi_add_device(device); in pnpacpi_add_device_handler()