Received: by 2002:a05:6512:2355:0:0:0:0 with SMTP id p21csp5523252lfu; Mon, 28 Mar 2022 15:57:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpWsUNPkGBuUnaz51Bft5Zh7W5looyuDElgyeHUPfIikklYQjfdEMMjRZ/tVjyy1P91mDH X-Received: by 2002:ab0:6989:0:b0:346:b33f:7b94 with SMTP id t9-20020ab06989000000b00346b33f7b94mr13441706uaq.5.1648508227499; Mon, 28 Mar 2022 15:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648508227; cv=none; d=google.com; s=arc-20160816; b=A9/j2f/GprMEUPE+xW7NNUNvnkCcAliXwDycWCUhKKAZtToX3+W1dzztgfZ/9F7KOj F7nRMX3icQSJ3TPrTGoSu+FYDVyyM3rEbvbK7CXrHuqkbMh3rxwDtM1WErtZi0SXCJ5o mjYZu26Eyw8DRqdzeFZei3EwXwCcCZFJJqqihaoAq+p/kWsbJqLeoDIrxr+AnHCIePM6 4PiOu7pYS5E47wxs9mhk/racXrakQNheyEhdG4MW1YWOnrf8b8I42A5jP7UQK9xu3tU+ exlwwiffgDxbhEMhQNwrJU4oga/I+cJgGJdbCqpiBrTkfYCIbv6jcYVPznZLtS/HJNKR 39oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=LGWDosA7uj0DRDvMTXB/qfLIc/X00g79gqGwaihOl7s=; b=GHyamQXdlDw4wwTCR0/xulDZk7kzzqkXtYS1zmffF7M+Q6xCS2Z/9gh2T0Z4OXVdzJ dlIsviHifBabyXbezE4Xj0REbd+Fgj2ejHrN9S9UXI1xKmoksKyNzpvx/Mqlf7JUJ3sE 1EobTw3nud22CdLZCEKpqpnxepmbqQaNHdk5jBa4fdBUb7VmCdZHTPG3EOvCJVzGjfSf qxMaWdTx8zvmFUfiMWcYKqNiq5Jorytf8tBNrIu3kInYZw4d3e88lFZS1yN9+Gvg6e6a 1SW4KrnMdx7slGAP9oW09iSVQd85I//Kt8M7TjCQ8NGXUt6dHfG9EO8UzlU6Msiy49UC ErKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@roeck-us.net header.s=default header.b=lBeLwz5K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i14-20020a67ecce000000b00324c5c3c081si3105912vsp.707.2022.03.28.15.57.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Mar 2022 15:57:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=fail header.i=@roeck-us.net header.s=default header.b=lBeLwz5K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 448DE26B3B2; Mon, 28 Mar 2022 14:57:40 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241388AbiC1QoC (ORCPT + 99 others); Mon, 28 Mar 2022 12:44:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239143AbiC1QoB (ORCPT ); Mon, 28 Mar 2022 12:44:01 -0400 Received: from gateway22.websitewelcome.com (gateway22.websitewelcome.com [192.185.47.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E73E43E5DF for ; Mon, 28 Mar 2022 09:42:20 -0700 (PDT) Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 777E91194C for ; Mon, 28 Mar 2022 11:42:20 -0500 (CDT) Received: from 162-215-252-75.unifiedlayer.com ([208.91.199.152]) by cmsmtp with SMTP id YsRgnSR5Kb6UBYsRgnZKUd; Mon, 28 Mar 2022 11:42:20 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LGWDosA7uj0DRDvMTXB/qfLIc/X00g79gqGwaihOl7s=; b=lBeLwz5KX2ZXRumnweriMl2NJE qNqw1idR51FQaNMHbVoWmL9nYldXoKdTaqheVgfbA3+mMgPfqj0z1mHKs306Ix2klc5npNyNzJohI fukpzzGLATBKFs9VGGJFsWoWJMyAqbzkqinFoiwGjrX5lGP0GK3rD+Umdhk1Ls+EhyANtDHdel9tZ Cu179zwU/AYWCquCMNF6fKcY+zBf9nuV8bWnme4YjRWOh1SBxoTAMZj/1MO6l0EjMqlfFu1Sp35ky YfAEpu5sRLUiR0oMntGL84ISLTN31HLzbX8N9ne43zDPFiii/G9MI8K9qemmg+yAsuSSHqa0AJwx/ Jto+MDPw==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:54534) by bh-25.webhostbox.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nYsRf-001lqf-M4; Mon, 28 Mar 2022 16:42:19 +0000 Message-ID: Date: Mon, 28 Mar 2022 09:42:17 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v1 1/2] hwmon: introduce hwmon_sanitize_name() Content-Language: en-US To: Tom Rix , Michael Walle , Xu Yilun , Jean Delvare , Andrew Lunn , Heiner Kallweit , Russell King , "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org References: <20220328115226.3042322-1-michael@walle.cc> <20220328115226.3042322-2-michael@walle.cc> From: Guenter Roeck In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-BWhitelist: no X-Source-IP: 108.223.40.66 X-Source-L: No X-Exim-ID: 1nYsRf-001lqf-M4 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 108-223-40-66.lightspeed.sntcca.sbcglobal.net [108.223.40.66]:54534 X-Source-Auth: linux@roeck-us.net X-Email-Count: 35 X-Source-Cap: cm9lY2s7YWN0aXZzdG07YmgtMjUud2ViaG9zdGJveC5uZXQ= X-Local-Domain: yes X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 3/28/22 05:25, Tom Rix wrote: > > On 3/28/22 4:52 AM, Michael Walle wrote: >> More and more drivers will check for bad characters in the hwmon name >> and all are using the same code snippet. Consolidate that code by adding >> a new hwmon_sanitize_name() function. >> >> Signed-off-by: Michael Walle >> --- >>   drivers/hwmon/intel-m10-bmc-hwmon.c |  5 +---- >>   include/linux/hwmon.h               | 16 ++++++++++++++++ >>   2 files changed, 17 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/hwmon/intel-m10-bmc-hwmon.c b/drivers/hwmon/intel-m10-bmc-hwmon.c >> index 7a08e4c44a4b..e6e55fc30153 100644 >> --- a/drivers/hwmon/intel-m10-bmc-hwmon.c >> +++ b/drivers/hwmon/intel-m10-bmc-hwmon.c >> @@ -515,7 +515,6 @@ static int m10bmc_hwmon_probe(struct platform_device *pdev) >>       struct intel_m10bmc *m10bmc = dev_get_drvdata(pdev->dev.parent); >>       struct device *hwmon_dev, *dev = &pdev->dev; >>       struct m10bmc_hwmon *hw; >> -    int i; >>       hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL); >>       if (!hw) >> @@ -532,9 +531,7 @@ static int m10bmc_hwmon_probe(struct platform_device *pdev) >>       if (!hw->hw_name) >>           return -ENOMEM; >> -    for (i = 0; hw->hw_name[i]; i++) >> -        if (hwmon_is_bad_char(hw->hw_name[i])) >> -            hw->hw_name[i] = '_'; >> +    hwmon_sanitize_name(hw->hw_name); >>       hwmon_dev = devm_hwmon_device_register_with_info(dev, hw->hw_name, >>                                hw, &hw->chip, NULL); >> diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h >> index eba380b76d15..210b8c0b2827 100644 >> --- a/include/linux/hwmon.h >> +++ b/include/linux/hwmon.h >> @@ -484,4 +484,20 @@ static inline bool hwmon_is_bad_char(const char ch) >>       } >>   } > > hwmon_is_bad_char is now only used by hwmon_sanitize_name. > > as patch 3, consolidate into only hwmon_sanitize_name. > That would make the code look messy. The function isn't execution-time critical, and neither is hwmon_sanitize_name(). I would suggest to implement hwmon_sanitize_name() in the hwmon core. The existing static inline can then be removed from the include file after all callers have been converted. Thanks, Guenter