From patchwork Sat Nov 30 14:04:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mario Limonciello X-Patchwork-Id: 13889178 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2057.outbound.protection.outlook.com [40.107.244.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 799131AAE0C; Sat, 30 Nov 2024 14:05:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.244.57 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975555; cv=fail; b=hlWGXPsKDwWcv2HTeC4Q+1kM3xlfmSkOROcVPcPJaUxVp8lfeYQFGeynLqn/F1UbLeksTx6j6MWNidqRKiqO9jMWSBHyUiwCdk1pcWNfwdkxhXuCXHcVYRgyXB5n0dgQ1v7DqbMDfFsXKIm8AHeTQBlMwFpG2EEgPONeNtvrKO8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732975555; c=relaxed/simple; bh=t1I6XbTlAg32LuZyx/zXnSdsSg4Grm5d56jAKU8vPec=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dgVFAqWOLj2qUSBNS/dwKAXdNRiKg0mZj3zHGhVHpy3Wh9TWIRMllHwK9pcF8mylhuL/StA5aWNCKwLOlDcRDdpNqOXVd2Jx9UhVB2OYqlGqJSvP0UquHOZZIYEpD77U1U85eB2T2NhSqwVeWjVzJ+xdjBPIi4CgVH4UImpKREo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=AIRSw85u; arc=fail smtp.client-ip=40.107.244.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="AIRSw85u" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qAfOZ0Dbir25uyJf/mA4/TXu/W6Cee62sZXRM8NVhsSr+AchUNG4scUx4/VN+C1Rgd1Qzi2zkb00ysKcIQ0nqv+9sG21LW/cI38b2vzwpYMgyL/EE3pH/uaUPy74vsGYv1kTlJtTtJAbipPiYFZomxCrOKDj3h9ZvDd5JVc0tsht6ltLrzGoEgwRbkuQE0yV2Fp1hbpJ+XXsC7ABcpL4ITSxV/QVGNV8KRdc/szGl7IPzvkFOtsrk3ucNYzlPWfFRTk2L1mBAs2uy8XU/ob6leZcOxcL6Z+QSYDT9VwEkJ0SMobPKdsX9X0oVMrmYvREeS9mDjmtsm1Mp7/DgGkP6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8ZRiBc29Tzl09/U6QRzkiEpEHzP9HtzUZIQBk5q6oLw=; b=J02DDQt0jKwSmEfd728uMa8/DYwDjYzY3SZercl1DaRE837IgOaqL7pxJxYuoayP/YlNiR271cEsIPAU4mQBrnUGPVvOlRsTYBNMV02kOk5xuznj2ul6Tki91jNujsRgVpyrJXGKkLlQgpcuC3ktHw3mOsguPvZEg5rmovnGfZDcpXBrEPtu4VI4jnT7Z67aJPAdXs4+O0l+xglvsc2ypPQeGAGY4C+dIXOlpq+gyfrcmtRHk7Nvrfog7IQoZmlNQTfTyqam+owmn7FW94i+mkA2ok/A800bveZVjSPGc4pkmhybbixGUnLFYAyqpbDmUd21nmQkFC7YuaX9rcuXGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=redhat.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8ZRiBc29Tzl09/U6QRzkiEpEHzP9HtzUZIQBk5q6oLw=; b=AIRSw85uJY1CiNn7zqOqpas2HRIxLdfpJOvPbUNQQnOqMS0vn/ePPVxfhajrNViLiIcGxpn5Kt1Di8XDMhev2k4tgfY5D1vPvQ/oQpwc2FdiL7teD478hAbozLjcmMo36N/fXM4jgTrf0TFGaWGejGJdhdvti6VNlDa0ZAnkl0I= Received: from PH7PR10CA0006.namprd10.prod.outlook.com (2603:10b6:510:23d::25) by IA0PR12MB8087.namprd12.prod.outlook.com (2603:10b6:208:401::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.16; Sat, 30 Nov 2024 14:05:46 +0000 Received: from CY4PEPF0000EDD6.namprd03.prod.outlook.com (2603:10b6:510:23d:cafe::c9) by PH7PR10CA0006.outlook.office365.com (2603:10b6:510:23d::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.15 via Frontend Transport; Sat, 30 Nov 2024 14:05:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EDD6.mail.protection.outlook.com (10.167.241.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8230.7 via Frontend Transport; Sat, 30 Nov 2024 14:05:45 +0000 Received: from AUS-P9-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Sat, 30 Nov 2024 08:05:42 -0600 From: Mario Limonciello To: Hans de Goede , =?utf-8?q?Ilpo_J=C3=A4rvinen?= CC: "Rafael J . Wysocki" , Len Brown , Maximilian Luz , Lee Chun-Yi , "Shyam Sundar S K" , Corentin Chary , "Luke D . Jones" , Ike Panhc , Henrique de Moraes Holschuh , "Alexis Belmonte" , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Ai Chao , Gergo Koteles , open list , "open list:ACPI" , "open list:MICROSOFT SURFACE PLATFORM PROFILE DRIVER" , "open list:THINKPAD ACPI EXTRAS DRIVER" , Mark Pearson , Matthew Schwartz , Mario Limonciello , Armin Wolf Subject: [PATCH v8 12/22] ACPI: platform_profile: Add choices attribute for class interface Date: Sat, 30 Nov 2024 08:04:44 -0600 Message-ID: <20241130140454.455-13-mario.limonciello@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241130140454.455-1-mario.limonciello@amd.com> References: <20241130140454.455-1-mario.limonciello@amd.com> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EDD6:EE_|IA0PR12MB8087:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e30b921-7553-4603-89a6-08dd114815f9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|1800799024|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?8CoD1vzqIQjWFOBjSfRrPGFJV/upiSR?= =?utf-8?q?QpiDQHgIh805K3Bp3r0wzh3KvMqJ7PTs0mbrkWUNIUHrw72mulcAPnAP34Tb7cXU8?= =?utf-8?q?rwHgDYoACDLpo3WyASK+4TO0f8sRNiUJSup8x+1j1TvccCYRWVPlzToDGbKBWJ89A?= =?utf-8?q?cU1+/+3PlOD3qZ6yi5eHLNwBwHV3u4Cfe3nzYnN6rdw0Hm3I6THtB4kDYxh3TtgKZ?= =?utf-8?q?7Crg/fi90lu6bLEsNqV/VrX401Aa7UnA7/43Lp3MWXHNqVAk7qgxYyvwIpsiEQTAE?= =?utf-8?q?+p8IQho18jzHVh6idSv3DZL0PV2hUbqTxFGofxhU3I/5+stTf/K2wQDVm/hSANOIZ?= =?utf-8?q?AuY2obFhd+bSsvyIwfK/rfD0puxfe9pAH7WySUbXXb3c1d5lTLxVl5ZtF4/WnKdDm?= =?utf-8?q?gXn8ab7w0/kYe0ZkY4TuzBHpaITPmVL47prbwb6ib6iTRebArNylvvR/WT/WMnoIb?= =?utf-8?q?1ZXU5D34FJTH6LPO0Qxf1pfA7OPVoms6HwKvZfPZUecCjOpnii+JAJktkbQlP7XoI?= =?utf-8?q?eXKRB4GCUnLbYpeEfoy+rRo1lRFujZLtXcR2s1bUvr6k7wxSd3sYPnmehoLHs3dMw?= =?utf-8?q?B7RDP+YWeb/CNJWbv2Typ+8//U75alN1Fqku4rEGNZ22eJ+en3Bn9peoPxYYTHKTi?= =?utf-8?q?xiZ4emPUu0gyhZD1zkHvUnayRxx5XRSy1V+0gnLODSuVghuwZVQA7HEfPzXWDVCqb?= =?utf-8?q?VjBpDJWfbuUzAL7c47oqKqBUV43LpUMgUlxTCZ5q2m2K3XOJT/AxBqIu2EqZGozhA?= =?utf-8?q?tHdWbos/jzbK78NBy8AMfxq/hAifqPdGK9hd3LLS6WPdMD46Q6/dnCGd6AUM8dneH?= =?utf-8?q?/c/8kamGmibl1seNDAeHXf9d16OMgdPD5Fr7MSBUt8uEoljTwSZXiqA08yZcDWASL?= =?utf-8?q?11mHrJ18DzCH4FnJFVXCccMiXBAB9rcJT2Y3bDxAYQtSk3LLshXE2jbKoslBTRsAa?= =?utf-8?q?La96YBKCVb8aJS8yLIFvTaTJCjKAG0IS1Iby42XXbbkwhb41HYHEpIjhTFausA5Ui?= =?utf-8?q?TNN6in6V+ymCSGoeczthRybyNI+JBi6/BbgDgkNeCld2nY3eNMETJMedKeMzA3BTs?= =?utf-8?q?7/vfGfzZiDYw9T/2agol6fNUVvO7PScPuhomr/zBimnaF4I+5ebuaoL/djs1PpLXL?= =?utf-8?q?JGVNkYv9b5TBDYQdj7W6rPrdnLRq/rFo9x0MaVxkoxqgQX0ZU95fmCzJhtGGxaEpN?= =?utf-8?q?ZXW7GLf4YhvGYqvcNu5FsAS+tzmZafbrcrHyshPjHNuEdgtPw+dLla/DO+9PsjdkO?= =?utf-8?q?k9MLL1qCsiuYN31/gYy/HUagbcJo2WjbVCT4I5pu75MLX+ZljunD5K06p8h6G3URp?= =?utf-8?q?PKfhsHsQP8z9jPrErXWOT+fhILeUwwYqSPJAapRdIjkmAmxDuiH8dm3jJReEyxhIg?= =?utf-8?q?L9PkXdycCeQ?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(7416014)(376014)(1800799024)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2024 14:05:45.8752 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e30b921-7553-4603-89a6-08dd114815f9 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CY4PEPF0000EDD6.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8087 The `choices` file will show all possible choices that a given platform profile handler can support. Tested-by: Mark Pearson Reviewed-by: Ilpo Järvinen Reviewed-by: Armin Wolf Reviewed-by: Mark Pearson Signed-off-by: Mario Limonciello --- v8: whitespace --- drivers/acpi/platform_profile.c | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c index eec842bd00643..6a257e500b190 100644 --- a/drivers/acpi/platform_profile.c +++ b/drivers/acpi/platform_profile.c @@ -25,6 +25,28 @@ static_assert(ARRAY_SIZE(profile_names) == PLATFORM_PROFILE_LAST); static DEFINE_IDA(platform_profile_ida); +/** + * _commmon_choices_show - Show the available profile choices + * @choices: The available profile choices + * @buf: The buffer to write to + * + * Return: The number of bytes written + */ +static ssize_t _commmon_choices_show(unsigned long *choices, char *buf) +{ + int i, len = 0; + + for_each_set_bit(i, choices, PLATFORM_PROFILE_LAST) { + if (len == 0) + len += sysfs_emit_at(buf, len, "%s", profile_names[i]); + else + len += sysfs_emit_at(buf, len, " %s", profile_names[i]); + } + len += sysfs_emit_at(buf, len, "\n"); + + return len; +} + /** * name_show - Show the name of the profile handler * @dev: The device @@ -41,8 +63,27 @@ static ssize_t name_show(struct device *dev, struct device_attribute *attr, char } static DEVICE_ATTR_RO(name); +/** + * choices_show - Show the available profile choices + * @dev: The device + * @attr: The attribute + * @buf: The buffer to write to + * + * Return: The number of bytes written + */ +static ssize_t choices_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct platform_profile_handler *handler = dev_get_drvdata(dev); + + return _commmon_choices_show(handler->choices, buf); +} +static DEVICE_ATTR_RO(choices); + static struct attribute *profile_attrs[] = { &dev_attr_name.attr, + &dev_attr_choices.attr, NULL }; ATTRIBUTE_GROUPS(profile);