From patchwork Tue Mar 29 16:07:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12795055 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 0DE99C433F5 for ; Tue, 29 Mar 2022 16:08:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239269AbiC2QJy (ORCPT ); Tue, 29 Mar 2022 12:09:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230330AbiC2QJe (ORCPT ); Tue, 29 Mar 2022 12:09:34 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B18F1E2F65; Tue, 29 Mar 2022 09:07:51 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id CCA752224F; Tue, 29 Mar 2022 18:07:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1648570067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ICyBKbcIANIRXFbM3XwImZyH8BggKJrVFsuGIGCnPIc=; b=ndwGVfNH2rpEswAMlPNbXXbh/lBTRKacuLkziFr1tB0krx0Qj0RmAAFSztGBTn5oG4mnfc rnuNqBGNCVjI0QIYPpga+VJw129Ccp6ZtVBazrxSplfXu/MizJRnretLRYOLt2ng95IQyk F7Cj3FuQCCEFWj8jXdm3l44NR4jOMyM= From: Michael Walle To: Xu Yilun , Tom Rix , Jean Delvare , Guenter Roeck , 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, Michael Walle Subject: [PATCH RFC v2 5/5] hwmon: move hwmon_is_bad_char() into core Date: Tue, 29 Mar 2022 18:07:30 +0200 Message-Id: <20220329160730.3265481-6-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220329160730.3265481-1-michael@walle.cc> References: <20220329160730.3265481-1-michael@walle.cc> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC With the last user of this function converted to hwmon_sanitize_name(), move the function into the core itself and make it private. Signed-off-by: Michael Walle --- drivers/hwmon/hwmon.c | 20 ++++++++++++++++++++ include/linux/hwmon.h | 23 ----------------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c index 619ef9f9a16e..f19b69b066ef 100644 --- a/drivers/hwmon/hwmon.c +++ b/drivers/hwmon/hwmon.c @@ -1057,6 +1057,26 @@ void devm_hwmon_device_unregister(struct device *dev) } EXPORT_SYMBOL_GPL(devm_hwmon_device_unregister); +/** + * hwmon_is_bad_char - Is the char invalid in a hwmon name + * @ch: the char to be considered + * + * Returns true if the char is invalid, false otherwise. + */ +static bool hwmon_is_bad_char(const char ch) +{ + switch (ch) { + case '-': + case '*': + case ' ': + case '\t': + case '\n': + return true; + default: + return false; + } +} + static char *__hwmon_sanitize_name(struct device *dev, const char *old_name) { char *name, *p; diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h index 4efaf06fd2b8..6a60e3a4acc0 100644 --- a/include/linux/hwmon.h +++ b/include/linux/hwmon.h @@ -464,27 +464,4 @@ int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type, char *hwmon_sanitize_name(const char *name); char *devm_hwmon_sanitize_name(struct device *dev, const char *name); -/** - * hwmon_is_bad_char - Is the char invalid in a hwmon name - * @ch: the char to be considered - * - * hwmon_is_bad_char() can be used to determine if the given character - * may not be used in a hwmon name. - * - * Returns true if the char is invalid, false otherwise. - */ -static inline bool hwmon_is_bad_char(const char ch) -{ - switch (ch) { - case '-': - case '*': - case ' ': - case '\t': - case '\n': - return true; - default: - return false; - } -} - #endif