Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3842375iog; Tue, 28 Jun 2022 04:03:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tvZJUAvcGU2OEECeC22wPCuPfQO0H/aPusd+npk3WXiK+lCPi1GvRgD2ffg2bhYftiirvL X-Received: by 2002:a17:907:6e06:b0:726:29f0:78d5 with SMTP id sd6-20020a1709076e0600b0072629f078d5mr17539247ejc.186.1656414237284; Tue, 28 Jun 2022 04:03:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656414237; cv=none; d=google.com; s=arc-20160816; b=dQOzuqhIZZVhkztmdH6FHEWhSo+HVzPYv83fEaL3s1uLJUauGp8BY0siSssdMG3dAn S1mxkCbmCs+aLoyjep2/FUYBAmtGy2FlBq/DoeF16E1AHrHq6gBA0fCzTJfYxACB47lx +gAFAlLTrogH+z5nc57jTrahLXa1EGDeYuA42JPR8k99xPDFSrz+EhueCOg+WpFPJyOF MzteI+7bw6vCwr1WsnBHuskAzy2KIXfo/HnZzbjKWIqWJQelen7tOjnyojDiHEXgUM/s ap/SR0ejGlo+/JwvkphT32JXak5uIenVpF/uG7D4VEZZvq4z9jcakO0D/gCs+4iWp5gN MGgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=lUL13hlG1bOhIQ16t01w5VV8WdcD9q2+AVcumspqn98=; b=Q5WVPDmJW3bLLLZEnOy2NI1FOJEWvlsKoZFBpdscERt2vej53bGzPR6d4hOCquPZoM kDZ85DVOt9lxycxARBwecj+qKrxngeeKiR+w5DJ25s0WaLBYf76PCmMN9EZYOqYFoFNi KsEUy92K/Iax1zT0V6JYrZ53encCtYToGBO9e918mf5A1YSgVVpjJtDsC5a/n0trF3QP r/maiC+iGJePUdFcfxcuJcXbzFSUd8Js2fRSV1+z3qBP6ih2w46FWH42LNb8uIwmQB7h e4YAjOItKJQmkJW6sndO291D+3/fL7N5RM4fGxIeNIuOIUOrh7wVy0BrE/ZTdFjZqvZA +b9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=m5GXUsZl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g5-20020a1709065d0500b00726ab6cededsi5057084ejt.948.2022.06.28.04.03.31; Tue, 28 Jun 2022 04:03:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=m5GXUsZl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344673AbiF1Ko0 (ORCPT + 99 others); Tue, 28 Jun 2022 06:44:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236719AbiF1KoY (ORCPT ); Tue, 28 Jun 2022 06:44:24 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E69031371; Tue, 28 Jun 2022 03:44:23 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25SAgSPc007098; Tue, 28 Jun 2022 05:44:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=lUL13hlG1bOhIQ16t01w5VV8WdcD9q2+AVcumspqn98=; b=m5GXUsZlMd9KL73aRNrNchKyEszo4lE++g7VlgHYKytiutdpA4L9K1k8FpHEii2RZ1QW I43TMmSTaqI7gguSPe9qsLSpAUJhm7LNBfct+Z2JKUPxMO2Zj+7bxldX1xjAJV5iHAbI +B/iiXp2eDNXmvOpDP4QsTSIXNcQEeEVvq3XKNQEJ80YKkpZyFQLCSjQ+TPcXQqHk6eI w/+X3+WnZSQTxvIqmHRmwcOBVn2H/xMh6TPtRJ+aA+UC/iVKxM+zeI6IvU9iE+tjNm2A oenh3DKM30UII/GjhRlUw9vOeMlSNSDzp7S0aRzh/Mowh0ofJQpY2rUK6Wgn8PslR65L bg== Received: from ediex02.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3gwys2ky5d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 28 Jun 2022 05:44:16 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 28 Jun 2022 11:44:14 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2375.28 via Frontend Transport; Tue, 28 Jun 2022 11:44:14 +0100 Received: from sbinding-cirrus-dsktp.ad.cirrus.com (unknown [198.90.238.163]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 4B56F458; Tue, 28 Jun 2022 10:44:14 +0000 (UTC) From: Stefan Binding To: "Rafael J . Wysocki" , Len Brown , Mark Brown , Liam Girdwood CC: , , , , Stefan Binding Subject: [PATCH v4 1/2] ACPI: utils: Add api to read _SUB from ACPI Date: Tue, 28 Jun 2022 11:44:10 +0100 Message-ID: <20220628104411.984551-2-sbinding@opensource.cirrus.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220628104411.984551-1-sbinding@opensource.cirrus.com> References: <20220628104411.984551-1-sbinding@opensource.cirrus.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: Zw_SzCiTT7IQPmJ1dcAxil_05wcekMMH X-Proofpoint-GUID: Zw_SzCiTT7IQPmJ1dcAxil_05wcekMMH X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a wrapper function to read the _SUB string from ACPI. Signed-off-by: Stefan Binding --- drivers/acpi/utils.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/acpi.h | 6 ++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/acpi/utils.c b/drivers/acpi/utils.c index 3a9773a09e19..394954f4b6ef 100644 --- a/drivers/acpi/utils.c +++ b/drivers/acpi/utils.c @@ -291,6 +291,44 @@ int acpi_get_local_address(acpi_handle handle, u32 *addr) } EXPORT_SYMBOL(acpi_get_local_address); +#define ACPI_MAX_SUB_BUF_SIZE 9 + +const char *acpi_get_subsystem_id(acpi_handle handle) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object *obj; + acpi_status status; + const char *sub; + + status = acpi_evaluate_object(handle, METHOD_NAME__SUB, NULL, &buffer); + if (ACPI_FAILURE(status)) { + acpi_handle_debug(handle, "Reading ACPI _SUB failed: %#x\n", status); + return ERR_PTR(-ENODATA); + } + + obj = buffer.pointer; + if (obj->type == ACPI_TYPE_STRING) { + if (strlen(obj->string.pointer) < ACPI_MAX_SUB_BUF_SIZE && + strlen(obj->string.pointer) > 0) { + sub = kstrdup(obj->string.pointer, GFP_KERNEL); + if (!sub) + sub = ERR_PTR(-ENOMEM); + } else { + acpi_handle_err(handle, "ACPI _SUB Length %zu is Invalid\n", + strlen(obj->string.pointer)); + sub = ERR_PTR(-EINVAL); + } + } else { + acpi_handle_warn(handle, "Warning ACPI _SUB did not return a string\n"); + sub = ERR_PTR(-EINVAL); + } + + acpi_os_free(buffer.pointer); + + return sub; +} +EXPORT_SYMBOL_GPL(acpi_get_subsystem_id); + acpi_status acpi_evaluate_reference(acpi_handle handle, acpi_string pathname, diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 4f82a5bc6d98..968a187f14f0 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -762,6 +762,7 @@ static inline u64 acpi_arch_get_root_pointer(void) #endif int acpi_get_local_address(acpi_handle handle, u32 *addr); +const char *acpi_get_subsystem_id(acpi_handle handle); #else /* !CONFIG_ACPI */ @@ -1023,6 +1024,11 @@ static inline int acpi_get_local_address(acpi_handle handle, u32 *addr) return -ENODEV; } +static inline const char *acpi_get_subsystem_id(acpi_handle handle) +{ + return ERR_PTR(-ENODEV); +} + static inline int acpi_register_wakeup_handler(int wake_irq, bool (*wakeup)(void *context), void *context) { -- 2.25.1