From patchwork Fri Mar 17 15:46:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Pearson X-Patchwork-Id: 13179252 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D212C74A5B for ; Fri, 17 Mar 2023 15:46:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbjCQPq4 (ORCPT ); Fri, 17 Mar 2023 11:46:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231286AbjCQPqz (ORCPT ); Fri, 17 Mar 2023 11:46:55 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ABF1BCFE7 for ; Fri, 17 Mar 2023 08:46:40 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id 8ECD03200920; Fri, 17 Mar 2023 11:46:39 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Fri, 17 Mar 2023 11:46:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squebb.ca; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1679067999; x= 1679154399; bh=oJTqiA1lEnsX4JQ/GzZ+6aUGQXMpeKwlUqLPE3H2zHE=; b=P 4noveNzRLhYFAA5ZfCjszSSaHTA2okyb2+xjRXQWYVPYyRs6Ta4JP29N8OQTVRuh vOnTMDupiDcVtIS+g7AQsM7BobpTljPfc6VPbjR3VwE6IldlNI4RcTsfgbtJeEUX LKWxxK7Qrwl0CMGoeFam23LFr0YbBJwD547v4ypGtG7PBai7AXL9NXcrXvYTs76r nfiPEjR332PZkDsvtNCy95h6qVowTMEwvhLAeOmqK9jjDj0jOu2Ytww9JjKYJ+pt 3VPHaNIBqeez24wqIGtNs/S6v+IL7dGW6FO9WoDJpf/2gSmf3FyIbamFAjXIcXZy J7iQ8v3/g95B4dGBUTp6g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1679067999; x= 1679154399; bh=oJTqiA1lEnsX4JQ/GzZ+6aUGQXMpeKwlUqLPE3H2zHE=; b=k jdPDF11a0od6aeEUindR1yCk2NzZtQviY2rP82pAV4402of0RfgMtBV4ka0ciiz7 PKsTgkUrCTOY+VkiT875AC2gijOvVvZOf/ms5IQYOkpFmlz47magDyuY/t09PN3F tsBOn5wJbGVjXsnDsyBfMp/N1Qd1Zkk3y+kzxVmIx2QkIac0/Je3EUFdu6Sryxsj ZH/OfSPJNlcYCGEpHPwtvsdknWI/dCp3alXOyK28znyS875/lzGgvLg5z8viqz+E 9PFLDfunAJVYe+vRI3C1bZB3nUFgQg42LN/jcHJgElFckgwBK+doeDrqDTU3Qkat 4hPHgAjvKPUOchogVwjbg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdefvddgjeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgoteeftdduqddtudculdduhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrrhhkucfrvggrrhhs ohhnuceomhhpvggrrhhsohhnqdhlvghnohhvohesshhquhgvsggsrdgtrgeqnecuggftrf grthhtvghrnhepvedtlefggefgjeettddvgfekhfeugfeutdekfeefudeuuddvieeutdel jedvhfdvnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmphgvrghrshhonhdqlhgvnhhovhho sehsqhhuvggssgdrtggr X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 17 Mar 2023 11:46:38 -0400 (EDT) From: Mark Pearson To: mpearson-lenovo@squebb.ca Cc: hdegoede@redhat.com, markgross@kernel.org, markpearson@lenovo.com, platform-driver-x86@vger.kernel.org Subject: [PATCH v3 1/3] platform/x86: think-lmi: add missing type attribute Date: Fri, 17 Mar 2023 11:46:33 -0400 Message-Id: <20230317154635.39692-1-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org This driver was missing the mandatory type attribute...oops. Add it in along with logic to determine whether the attribute is an enumeration type or a string by parsing the possible_values attribute. Upstream bug https://bugzilla.kernel.org/show_bug.cgi?id=216460 Signed-off-by: Mark Pearson --- Changes in v3: - Rebased on latest pdx86, review_hans branch Changes in v2: - Simplify the code and move type determination into show function - Don't use Fixes with URL in commit info drivers/platform/x86/think-lmi.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index 86b33b74519b..5fa5451c4802 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -947,6 +947,20 @@ static ssize_t possible_values_show(struct kobject *kobj, struct kobj_attribute return sysfs_emit(buf, "%s\n", setting->possible_values); } +static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); + + if (setting->possible_values) { + /* Figure out what setting type is as BIOS does not return this */ + if (strchr(setting->possible_values, ',')) + return sysfs_emit(buf, "enumeration\n"); + } + /* Anything else is going to be a string */ + return sysfs_emit(buf, "string\n"); +} + static ssize_t current_value_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) @@ -1036,10 +1050,13 @@ static struct kobj_attribute attr_possible_values = __ATTR_RO(possible_values); static struct kobj_attribute attr_current_val = __ATTR_RW_MODE(current_value, 0600); +static struct kobj_attribute attr_type = __ATTR_RO(type); + static struct attribute *tlmi_attrs[] = { &attr_displ_name.attr, &attr_current_val.attr, &attr_possible_values.attr, + &attr_type.attr, NULL }; From patchwork Fri Mar 17 15:46:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Pearson X-Patchwork-Id: 13179253 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CE65C74A5B for ; Fri, 17 Mar 2023 15:47:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230337AbjCQPrA (ORCPT ); Fri, 17 Mar 2023 11:47:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231286AbjCQPq7 (ORCPT ); Fri, 17 Mar 2023 11:46:59 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19E3DB863A for ; Fri, 17 Mar 2023 08:46:42 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 226613200925; Fri, 17 Mar 2023 11:46:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Fri, 17 Mar 2023 11:46:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squebb.ca; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1679068000; x= 1679154400; bh=aHEYHVPzZbIieasq8y0o5PCoM67EEVNfROQvWKJOpVM=; b=A RzF0+Yev7GYT17xfG4WIxa5esJ25uVSGwTuZVQxHXupX8Zx96RAMza7JoTdt6fRP 3Z0B3L/dNrJI7mxRwoqyQAxN2XxILq5wV5fGyD0+KmQW1r54vngtzz/fed6PtcDF bP518wtEihl1xQS6bnWzCTELi+MMzTSXNfAYpSNsyaWganGSODlsZVi7QWP12UES TLMBmUfk4TTX0kdXAkWFJmbIRw66GpbhqfKqV1pk4qGAanGSZU/Uy6J+VGrhw/DO M2RXIQNOw0g8hjj9EoGFTzGWdqLKjQkO4g4P7d38FNXfncFiM/TQeKMgxz/4pPFq EoUFzn4xlopdrY+cZJ5rA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1679068000; x= 1679154400; bh=aHEYHVPzZbIieasq8y0o5PCoM67EEVNfROQvWKJOpVM=; b=M 6n0L94JEK5qRs9Tqw1w2uBRVkv0L/js7K+omSRBYvnFVr8rPZviv1C6RCAlmftIN yG8V32TMYXBrH1psMPKmvTPX6DvW5dMnDMx9zfujhUQHMtK0ezwW93tk+8FwIHpz JQCU1zvlQxzKLKX7RDMEBJXET8LJM4bzT1ZZMg0BRmMLjB93CuLD2fx/O9KTHdgc c1dzUfMCFh9Mb5EO2q3v4D5e8tdIsQm/i1m6RtR06czHH68VhcUG27ppAwFILhdE k1nX7/Da/JiiYeN+HoBsPyN7lF+AFdLjJtBPQi/0dbE/+6gznDg+5d3CN1Wl7xJC up0JzBYnN9Wo8TvUVyKUA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdefvddgjeelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgoteeftdduqddtudculdduhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrrhhkucfrvggrrhhs ohhnuceomhhpvggrrhhsohhnqdhlvghnohhvohesshhquhgvsggsrdgtrgeqnecuggftrf grthhtvghrnhepfedtvdejfeelffevhffgjeejheduteetieeguefgkefhhfegjeduueet hefgvdffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhhpvggrrhhsohhnqdhlvghnohhvohesshhquhgvsggsrdgtrg X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 17 Mar 2023 11:46:40 -0400 (EDT) From: Mark Pearson To: mpearson-lenovo@squebb.ca Cc: hdegoede@redhat.com, markgross@kernel.org, markpearson@lenovo.com, platform-driver-x86@vger.kernel.org Subject: [PATCH v3 2/3] platform/x86: think-lmi: Add possible_values for ThinkStation Date: Fri, 17 Mar 2023 11:46:34 -0400 Message-Id: <20230317154635.39692-2-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317154635.39692-1-mpearson-lenovo@squebb.ca> References: <20230317154635.39692-1-mpearson-lenovo@squebb.ca> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org ThinkStation platforms don't support the API to return possible_values but instead embed it in the settings string. Try and extract this information and set the possible_values attribute appropriately. If there aren't any values possible then don't display possible_values. Signed-off-by: Mark Pearson --- Changes in V3: - Use is_visible attribute to determine if possible_values should be available - Code got refactored a bit to make compilation cleaner Changes in V2: - Move no value for possible_values handling into show function - use kstrndup for allocating string drivers/platform/x86/think-lmi.c | 82 ++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 26 deletions(-) diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index 5fa5451c4802..d89a1c9bdbf1 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -917,6 +917,8 @@ static ssize_t display_name_show(struct kobject *kobj, struct kobj_attribute *at return sysfs_emit(buf, "%s\n", setting->display_name); } +static struct kobj_attribute attr_displ_name = __ATTR_RO(display_name); + static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); @@ -937,30 +939,6 @@ static ssize_t current_value_show(struct kobject *kobj, struct kobj_attribute *a return ret; } -static ssize_t possible_values_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) -{ - struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); - - if (!tlmi_priv.can_get_bios_selections) - return -EOPNOTSUPP; - - return sysfs_emit(buf, "%s\n", setting->possible_values); -} - -static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *attr, - char *buf) -{ - struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); - - if (setting->possible_values) { - /* Figure out what setting type is as BIOS does not return this */ - if (strchr(setting->possible_values, ',')) - return sysfs_emit(buf, "enumeration\n"); - } - /* Anything else is going to be a string */ - return sysfs_emit(buf, "string\n"); -} - static ssize_t current_value_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) @@ -1044,14 +1022,46 @@ static ssize_t current_value_store(struct kobject *kobj, return ret ?: count; } -static struct kobj_attribute attr_displ_name = __ATTR_RO(display_name); +static struct kobj_attribute attr_current_val = __ATTR_RW_MODE(current_value, 0600); + +static ssize_t possible_values_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); + + return sysfs_emit(buf, "%s\n", setting->possible_values); +} static struct kobj_attribute attr_possible_values = __ATTR_RO(possible_values); -static struct kobj_attribute attr_current_val = __ATTR_RW_MODE(current_value, 0600); +static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *attr, + char *buf) +{ + struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); + + if (setting->possible_values) { + /* Figure out what setting type is as BIOS does not return this */ + if (strchr(setting->possible_values, ',')) + return sysfs_emit(buf, "enumeration\n"); + } + /* Anything else is going to be a string */ + return sysfs_emit(buf, "string\n"); +} static struct kobj_attribute attr_type = __ATTR_RO(type); +static umode_t attr_is_visible(struct kobject *kobj, + struct attribute *attr, int n) +{ + struct tlmi_attr_setting *setting = to_tlmi_attr_setting(kobj); + + /* We don't want to display possible_values attributes if not available */ + if (attr == (struct attribute *)&attr_possible_values) + if (!setting->possible_values) + return 0; + + return attr->mode; +} + static struct attribute *tlmi_attrs[] = { &attr_displ_name.attr, &attr_current_val.attr, @@ -1061,6 +1071,7 @@ static struct attribute *tlmi_attrs[] = { }; static const struct attribute_group tlmi_attr_group = { + .is_visible = attr_is_visible, .attrs = tlmi_attrs, }; @@ -1440,6 +1451,25 @@ static int tlmi_analyze(void) if (ret || !setting->possible_values) pr_info("Error retrieving possible values for %d : %s\n", i, setting->display_name); + } else { + /* + * Older Thinkstations don't support the bios_selections API. + * Instead they store this as a [Optional:Option1,Option2] section of the + * name string. + * Try and pull that out if it's available. + */ + char *item, *optstart, *optend; + + if (!tlmi_setting(setting->index, &item, LENOVO_BIOS_SETTING_GUID)) { + optstart = strstr(item, "[Optional:"); + if (optstart) { + optstart += strlen("[Optional:"); + optend = strstr(optstart, "]"); + if (optend) + setting->possible_values = + kstrndup(optstart, optend - optstart, GFP_KERNEL); + } + } } kobject_init(&setting->kobj, &tlmi_attr_setting_ktype); tlmi_priv.setting[i] = setting; From patchwork Fri Mar 17 15:46:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Pearson X-Patchwork-Id: 13179254 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF607C76196 for ; Fri, 17 Mar 2023 15:47:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231286AbjCQPrB (ORCPT ); Fri, 17 Mar 2023 11:47:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230031AbjCQPrA (ORCPT ); Fri, 17 Mar 2023 11:47:00 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2C85BDD00 for ; Fri, 17 Mar 2023 08:46:43 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 85B4B320091F; Fri, 17 Mar 2023 11:46:42 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 17 Mar 2023 11:46:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=squebb.ca; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1679068002; x= 1679154402; bh=y6PWYXpuekZgpPtcJ15isJkzl47+IeMknWrLd+HCfWk=; b=v YWJTaFSkYPOQfzKJLbx5HWTIA1HSqIyu4L5VW9e5sv4GHmb2f+CsZ0bjhWzTjyKa Yf4oHnhD3YPliA/ASx/j+kc6ATQIFD/V5NwP7ald4J+cBBneppCAd2p5cBoZdTJs abdrbcYe4D4J16zih9p3P3CyumGqoytdHY1G1Kp6asZJAvvgTGj3uYGl757EvO4e KIQ7n/+MqrfxJKhdarN6PT+jyRYe6UBj7berHDgH4S0GBWUrSeYqGG9pmSV8QQ7R cAPaZeIViZ8vRGzolsWcvrJEAPZXriUGSzdWcv8oTlc0U9MY8sVoDC2o76xUTxIg kTUrrAklCMqOCRgwp60WA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1679068002; x= 1679154402; bh=y6PWYXpuekZgpPtcJ15isJkzl47+IeMknWrLd+HCfWk=; b=S DJuKduxX0142TbxZtO+Sz2JYYR1g8JzPuL3s4PS81T8wa/2ICwevDQ1EL0A4xa/1 i/s8r+oKAM+KBULvOolNlTw5Y9XiQJDc5h3zMy0N2rym660YLCW820keAIAG/7Qg rsgrEEeWmF5ary2TMlRtWl3Bf8kCVeSjRBZbCgeF/UoLqcxo0/RExiOOJpbJP1p3 LFv2lRSDIdpfctGGK/tgdIn4nhCiaLCIG0jc1tq9BHXFpkqjR73N0O0Y/Efqga30 ETH0pAOCg/wobn93JWx5rwPZaWGZlWesGApRVUnc2NAfSiNxnQ3M6Jzx1qSYFDNp mVlZVKRKB8CezVVUbXvnw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdefvddgjeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucgoteeftdduqddtudculdduhedmnecujfgurhephf fvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepofgrrhhkucfrvggrrhhs ohhnuceomhhpvggrrhhsohhnqdhlvghnohhvohesshhquhgvsggsrdgtrgeqnecuggftrf grthhtvghrnhepfedtvdejfeelffevhffgjeejheduteetieeguefgkefhhfegjeduueet hefgvdffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhhpvggrrhhsohhnqdhlvghnohhvohesshhquhgvsggsrdgtrg X-ME-Proxy: Feedback-ID: ibe194615:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 17 Mar 2023 11:46:41 -0400 (EDT) From: Mark Pearson To: mpearson-lenovo@squebb.ca Cc: hdegoede@redhat.com, markgross@kernel.org, markpearson@lenovo.com, platform-driver-x86@vger.kernel.org Subject: [PATCH v3 3/3] platform/x86: think-lmi: use correct possible_values delimters Date: Fri, 17 Mar 2023 11:46:35 -0400 Message-Id: <20230317154635.39692-3-mpearson-lenovo@squebb.ca> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230317154635.39692-1-mpearson-lenovo@squebb.ca> References: <20230317154635.39692-1-mpearson-lenovo@squebb.ca> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org firmware-attributes class requires that possible values are delimited using ';' but the Lenovo firmware uses ',' instead. Parse string and replace where appropriate Thanks to Thomas W for pointing this out. Signed-off-by: Mark Pearson Reported-by: Thomas Weißschuh --- Changes in V3: New patch added to the series. No V1 & V2. drivers/platform/x86/think-lmi.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/think-lmi.c b/drivers/platform/x86/think-lmi.c index d89a1c9bdbf1..204f1060a533 100644 --- a/drivers/platform/x86/think-lmi.c +++ b/drivers/platform/x86/think-lmi.c @@ -1040,7 +1040,7 @@ static ssize_t type_show(struct kobject *kobj, struct kobj_attribute *attr, if (setting->possible_values) { /* Figure out what setting type is as BIOS does not return this */ - if (strchr(setting->possible_values, ',')) + if (strchr(setting->possible_values, ';')) return sysfs_emit(buf, "enumeration\n"); } /* Anything else is going to be a string */ @@ -1471,6 +1471,17 @@ static int tlmi_analyze(void) } } } + /* + * firmware-attributes requires that possible_values are separated by ';' but + * Lenovo FW uses ','. Replace appropriately. + */ + if (setting->possible_values) { + char *tmp = setting->possible_values; + + while ((tmp = strchr(tmp, ',')) != NULL) + *tmp++ = ';'; + } + kobject_init(&setting->kobj, &tlmi_attr_setting_ktype); tlmi_priv.setting[i] = setting; kfree(item);