static int int340x_thermal_handler_attach(struct acpi_device *adev, const struct acpi_device_id *id) { if (IS_ENABLED(CONFIG_INT340X_THERMAL)) acpi_create_platform_device(adev, NULL); /* Intel SoC DTS thermal driver needs INT3401 to set IRQ descriptor */ else if (IS_ENABLED(CONFIG_INTEL_SOC_DTS_THERMAL) && id->driver_data == INT3401_DEVICE) acpi_create_platform_device(adev, NULL); return 1; }
static int int340x_thermal_handler_attach(struct acpi_device *adev, const struct acpi_device_id *id) { #if defined(CONFIG_INT340X_THERMAL) || defined(CONFIG_INT340X_THERMAL_MODULE) acpi_create_platform_device(adev); #elif defined(INTEL_SOC_DTS_THERMAL) || defined(INTEL_SOC_DTS_THERMAL_MODULE) /* Intel SoC DTS thermal driver needs INT3401 to set IRQ descriptor */ if (id->driver_data == INT3401_DEVICE) acpi_create_platform_device(adev); #endif return 1; }
/** * Create platform device during acpi scan attach handle. * Return value > 0 on success of creating device. */ static int acpi_apd_create_device(struct acpi_device *adev, const struct acpi_device_id *id) { const struct apd_device_desc *dev_desc = (void *)id->driver_data; struct apd_private_data *pdata; struct platform_device *pdev; int ret; if (!dev_desc) { pdev = acpi_create_platform_device(adev); return IS_ERR_OR_NULL(pdev) ? PTR_ERR(pdev) : 1; } pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); if (!pdata) return -ENOMEM; pdata->adev = adev; pdata->dev_desc = dev_desc; if (dev_desc->setup) { ret = dev_desc->setup(pdata); if (ret) goto err_out; } if (dev_desc->properties) { ret = device_add_properties(&adev->dev, dev_desc->properties); if (ret) goto err_out; } adev->driver_data = pdata; pdev = acpi_create_platform_device(adev); if (!IS_ERR_OR_NULL(pdev)) return 1; ret = PTR_ERR(pdev); adev->driver_data = NULL; err_out: kfree(pdata); return ret; }
/* * Unfortunately, some laptops provide a _HID="INT33D5" device with * _CID="PNP0C02". This causes the pnpacpi scan driver to claim the * ACPI node, so no platform device will be created. The pnpacpi * driver rejects this device in subsequent processing, so no physical * node is created at all. * * As a workaround until the ACPI core figures out how to handle * this corner case, manually ask the ACPI platform device code to * claim the ACPI node. */ static acpi_status __init check_acpi_dev(acpi_handle handle, u32 lvl, void *context, void **rv) { const struct acpi_device_id *ids = context; struct acpi_device *dev; if (acpi_bus_get_device(handle, &dev) != 0) return AE_OK; if (acpi_match_device_ids(dev, ids) == 0) if (acpi_create_platform_device(dev, NULL)) dev_info(&dev->dev, "intel-hid: created platform device\n"); return AE_OK; }
static int acpi_mid_lpss_create_device(struct acpi_device *adev, const struct acpi_device_id *id) { return acpi_create_platform_device(adev, id); }
/** * acpi_parse_trt - Thermal Relationship Table _TRT for passive cooling * * @handle: ACPI handle of the device contains _TRT * @art_count: the number of valid entries resulted from parsing _TRT * @artp: pointer to pointer of array of art entries in parsing result * @create_dev: whether to create platform devices for target and source * */ int acpi_parse_trt(acpi_handle handle, int *trt_count, struct trt **trtp, bool create_dev) { acpi_status status; int result = 0; int i; int nr_bad_entries = 0; struct trt *trts; struct acpi_device *adev; union acpi_object *p; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer element = { 0, NULL }; struct acpi_buffer trt_format = { sizeof("RRNNNNNN"), "RRNNNNNN" }; if (!acpi_has_method(handle, "_TRT")) return 0; status = acpi_evaluate_object(handle, "_TRT", NULL, &buffer); if (ACPI_FAILURE(status)) return -ENODEV; p = buffer.pointer; if (!p || (p->type != ACPI_TYPE_PACKAGE)) { pr_err("Invalid _TRT data\n"); result = -EFAULT; goto end; } *trt_count = p->package.count; trts = kzalloc(*trt_count * sizeof(struct trt), GFP_KERNEL); if (!trts) { result = -ENOMEM; goto end; } for (i = 0; i < *trt_count; i++) { struct trt *trt = &trts[i - nr_bad_entries]; element.length = sizeof(struct trt); element.pointer = trt; status = acpi_extract_package(&(p->package.elements[i]), &trt_format, &element); if (ACPI_FAILURE(status)) { nr_bad_entries++; pr_warn("_TRT package %d is invalid, ignored\n", i); continue; } if (!create_dev) continue; result = acpi_bus_get_device(trt->source, &adev); if (!result) acpi_create_platform_device(adev); else pr_warn("Failed to get source ACPI device\n"); result = acpi_bus_get_device(trt->target, &adev); if (!result) acpi_create_platform_device(adev); else pr_warn("Failed to get target ACPI device\n"); } result = 0; *trtp = trts; /* don't count bad entries */ *trt_count -= nr_bad_entries; end: kfree(buffer.pointer); return result; }