Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2304687rwr; Fri, 28 Apr 2023 08:38:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5OGZ3dGtvZ+bmLY21fIpDFmX5/pY/GU1eREPGhHDwX7Do9H8L/1zEhhS4qYICcJNWiMg7B X-Received: by 2002:a05:6a20:4309:b0:f3:9f6:6ee8 with SMTP id h9-20020a056a20430900b000f309f66ee8mr7388680pzk.43.1682696289756; Fri, 28 Apr 2023 08:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682696289; cv=none; d=google.com; s=arc-20160816; b=qoyfmWfqNychlGcfnObfEfJZC1vQSWxvLjrdzxCxyCSNaN9CJ1awxqfU8XjrPjLgOi N0KEQgxQYJKjageLNyERySv1Hpyc9aEVDLL/XGth0a6X+JZwVwmfpNurwkdqBn3VgAAI eG98XScv9gZMcVvqGWjC1Cst2/q9qsmi3VUFSb1Iq7A/UW9/KWo4yEALNxO0WWIij7JO YoRZrcKld4cwn3c9U1JxR0r/7O5d5EMJANf8eEvwlZEbJ6Hjo3//u4DLnaQDQlxH5j1B dx9bedtRJoUKKHLcxwuo1OsCtYz7hhJudG6AeHPHgEn2Nux6xOK/mzk8vbkZzZBnaMV7 IBLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:date; bh=Yf2+ukj6dcHMKB0J80L64NhfZCbLNRyp4v42n44BJoo=; b=MalcEBHbgwk3FYUoFyOWACyxpsxdP2ReuvOetCqSnPonnRepbMH97VgEUSQjB2dcfT VvhRyzfkILV4Ye4L757EWL9n+dg0bR+WowpcH3pUO8bACfwdGsGs2RWADgS8pctehQ5M 2iYfpKgAcxNo40IGSI94oi7mUO0xGglfQas+ikW7UP4nT5zBya4DjoLke4H8Uo9nJcYt gq6pbSvvzOm214OvcBbJbSL/SUgos74O0iPe50e70ZgB2mUw83DgiDe7MyjaODPk0ktE Z8l6uOvOMV/U4Z9xFPJ3+SlvltAd6pHPIffkeoYJoWM0c78nfiybP40tJJa9PM8KV4U/ Gb9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@t-8ch.de header.s=mail header.b="U/0pCfV8"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k24-20020a63f018000000b00513f070aa0dsi4967682pgh.655.2023.04.28.08.37.58; Fri, 28 Apr 2023 08:38:09 -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=@t-8ch.de header.s=mail header.b="U/0pCfV8"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230336AbjD1Pha (ORCPT + 99 others); Fri, 28 Apr 2023 11:37:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229851AbjD1Ph2 (ORCPT ); Fri, 28 Apr 2023 11:37:28 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C66355AD; Fri, 28 Apr 2023 08:36:53 -0700 (PDT) Date: Fri, 28 Apr 2023 17:36:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=t-8ch.de; s=mail; t=1682696178; bh=7jLiEj7+Pv2h4RAIi3yfMfMbNX9AW+A1ZOdwGlDD00k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=U/0pCfV8PHvTtLuVAuSw4fiWwMZVPBpaRzGM+KJ15OUjgA0TR7DT1JzjyR9vDYLU4 aDgJ6y0jMJJGsiGBxzIwgFl8BwER6MLaxqsC8EAIrrk15CK6c/J0zWLUoI3wM6JwQM 4QupQhQ/0wLFTCKV6NXcueD+nDQuIPl9S/PrXFOs= From: Thomas =?utf-8?Q?Wei=C3=9Fschuh?= To: Jorge Lopez Cc: hdegoede@redhat.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v11 08/14] HP BIOSCFG driver - bioscfg-h Message-ID: <462b5d12-0430-4fbe-8c26-7b6126556ec8@t-8ch.de> References: <20230420165454.9517-1-jorge.lopez2@hp.com> <20230420165454.9517-9-jorge.lopez2@hp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On 2023-04-28 10:24:40-0500, Jorge Lopez wrote: > On Sun, Apr 23, 2023 at 7:01 AM Thomas Weißschuh wrote: > > > > On 2023-04-20 11:54:48-0500, Jorge Lopez wrote: > > > --- > > > drivers/platform/x86/hp/hp-bioscfg/bioscfg.h | 613 +++++++++++++++++++ > > > 1 file changed, 613 insertions(+) > > > create mode 100644 drivers/platform/x86/hp/hp-bioscfg/bioscfg.h > > > +/* global structure used by multiple WMI interfaces */ > > > +extern struct bioscfg_priv bioscfg_drv; > > > + > > > +enum hp_wmi_data_type { > > > + HPWMI_STRING_TYPE = 0x00, > > > + HPWMI_INTEGER_TYPE = 0x01, > > > + HPWMI_ENUMERATION_TYPE = 0x02, > > > + HPWMI_ORDERED_LIST_TYPE = 0x03, > > > + HPWMI_PASSWORD_TYPE = 0x04, > > > + HPWMI_SECURE_PLATFORM_TYPE = 0x05, > > > + HPWMI_SURE_START_TYPE = 0x06 > > > +}; > > > > Unused. > > Both hp_wmi_data_type and hp_wmi_data_elements are used > for instance HP_WMI_STRING_TYPE > > bioscfg.c:338: case HPWMI_STRING_TYPE: > bioscfg.c:626: case HPWMI_STRING_TYPE: > bioscfg.c:722: case HPWMI_STRING_TYPE: > bioscfg.c:798: case HPWMI_STRING_TYPE: > bioscfg.c:906: ret = hp_init_bios_attributes(HPWMI_STRING_TYPE, > HP_WMI_BIOS_STRING_GUID); > bioscfg.h:247: HPWMI_STRING_TYPE Indeed. I think I just searched for "hp_wmi_data_type". The proper enum hp_wmi_data_type type should be used instead of "int attr_type". > > > + > > > +enum hp_wmi_elements_count { > > > + STRING_ELEM_CNT = 12, > > > + INTEGER_ELEM_CNT = 13, > > > + ENUM_ELEM_CNT = 13, > > > + ORDERED_ELEM_CNT = 12, > > > + PASSWORD_ELEM_CNT = 15 > > > +}; > > > > To make it clearer where these values come from you could put them into > > the enum hp_wmi_data_elements. > > > > ... > > ORD_LIST_ELEMENTS = 11, > > ORD_LIST_ELEM_CNT = 12, > > ... > > Done! changes provided across all files affected. > > > > > But replacing the loop logic would remove the need for these enums > > completely. > > > > _CNT values are necessary when elements are read from a buffer ( > populate_string_elements_from_buffer). > _CNT values are not needed when elements are read from a package > (populate_string_package_data) Hm, I don't see why populate_string_elements_from_buffer() would need the _CNT define. (In another review mail I wrote down how I would expect it to look without the loop) > > > + > > > +#define ATTRIBUTE_PROPERTY_STORE(curr_val, type) \ > > > + static ssize_t curr_val##_store(struct kobject *kobj, \ > > > + struct kobj_attribute *attr, \ > > > + const char *buf, size_t count) \ > > > + { \ > > > + char *p = NULL; \ > > > + char *attr_value = NULL; \ > > > + int i; \ > > > + int ret = -EIO; \ > > > + \ > > > + attr_value = kstrdup(buf, GFP_KERNEL); \ > > > + if (!attr_value) \ > > > + return -ENOMEM; \ > > > + \ > > > + p = memchr(attr_value, '\n', count); \ > > > + if (p != NULL) \ > > > + *p = '\0'; \ > > > > This can also truncate the string if there is data after the newline. > > This is a expected behavior as described by Hans in a later email I'm fine with stripping a trailing newline. But this truncates the string at the first newline. "foo\nbar" -> "foo" "\nfoo" -> ""