Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp650729pxb; Tue, 5 Apr 2022 17:19:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx9I5CIZLKXVu8C0pTYpMsv03CZkO3XD4vV7CePNYDdD0dDBeOR/xJ3rVfy1W60jKUWZLAO X-Received: by 2002:a17:906:5d05:b0:6df:f88c:ae96 with SMTP id g5-20020a1709065d0500b006dff88cae96mr5945367ejt.480.1649204291375; Tue, 05 Apr 2022 17:18:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649204291; cv=none; d=google.com; s=arc-20160816; b=iRQSx+3m5lk6dTbRqZVqs5I+93LtCthSWsUWDrMjQP2Ewx7n5lObXfJhIijgTwKTzx Y8bc7giSNUST1/UsLINXoQJaS7TYyIOoJpohNG9EQh6ajOHhehwbYRxI9VljLetl1jpx k3VX3QulNbiVW1G2kDg2OVmagaEDdIykhcW/9KH6gQJ9A3Vd2t2kWBQaJs+5be/ZOcV+ AZIzR2oQYLom1w+xYPSnlqRkBWeJFMhAChx4bgI+m8ZgfJ5XiCmUyXgS6p2Y+1XTMAxu PUXJepiyiLJTGJk35jVE+0QHF4678UScDMT6F2exFIh1WF7PqFSxCK7m3Dd2fVNuI5xH VW8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LFGJ3O9qYA9938AO+AQNVvGHGDybEslbIOzd5ve6rOc=; b=PQkMCxT0xtWWGTvfhlUtwb1BM65VcLwg7IFcb4TdpEGx/ndB6u+sSNKeUHzyCB+rG7 XM5GcWLCaOaR8Qz+xac2g+fq1MAgYnvnlv0mGfb+6tWC+ZoOMLcGDQgj1kANjZvWrzRB HB7NSjFk58kRBS8GerGdbrDKIcv1RLTOv2VwT5sougx4jUo/rtto698ayq4nlYNQEZE+ 1Qx10Gj4cyw3H6og5vpjr5RmEtLy1HqeOzR5D2yTlMDwD0E0KLZMl0fzhqvCZzOW2l3i VYzMojBY3TCo//Vd/LFmBnWZWfJRF0rGHX08zIQiNGxyGyhUR9+yDg9uhAbCFRCDdG9R hX7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=Q47t6wRO; 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 fy24-20020a1709069f1800b006df76385bf9si8995856ejc.153.2022.04.05.17.17.46; Tue, 05 Apr 2022 17:18:11 -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=@walle.cc header.s=mail2016061301 header.b=Q47t6wRO; 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 S1388709AbiDEOkt (ORCPT + 99 others); Tue, 5 Apr 2022 10:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243882AbiDEJkf (ORCPT ); Tue, 5 Apr 2022 05:40:35 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82219B91BF; Tue, 5 Apr 2022 02:25:04 -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 59A0022247; Tue, 5 Apr 2022 11:25:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1649150702; 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=LFGJ3O9qYA9938AO+AQNVvGHGDybEslbIOzd5ve6rOc=; b=Q47t6wRO/Ontk9oWcJ4vW9oK8/E+y+rWODF0rkBnL9v+/QXeae/qrwlUfdccHnDmhLRVX6 4ZJYbomJ2z88PT80DLdLq9xDxngYJFp7nL83yRLw7NFbNN+nI/gjV3Tq583WBCexaCW0hv 31+C6oUMXrl2LMJ4rdbUhUXiJsSfdV0= 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, David Laight , Michael Walle Subject: [PATCH v4 2/2] hwmon: intel-m10-bmc-hwmon: use devm_hwmon_sanitize_name() Date: Tue, 5 Apr 2022 11:24:52 +0200 Message-Id: <20220405092452.4033674-3-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220405092452.4033674-1-michael@walle.cc> References: <20220405092452.4033674-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Instead of open-coding the bad characters replacement in the hwmon name, use the new devm_hwmon_sanitize_name(). Signed-off-by: Michael Walle Acked-by: Xu Yilun --- drivers/hwmon/intel-m10-bmc-hwmon.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/hwmon/intel-m10-bmc-hwmon.c b/drivers/hwmon/intel-m10-bmc-hwmon.c index 7a08e4c44a4b..6e82f7200d1c 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) @@ -528,13 +527,9 @@ static int m10bmc_hwmon_probe(struct platform_device *pdev) hw->chip.info = hw->bdata->hinfo; hw->chip.ops = &m10bmc_hwmon_ops; - hw->hw_name = devm_kstrdup(dev, id->name, GFP_KERNEL); - 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] = '_'; + hw->hw_name = devm_hwmon_sanitize_name(dev, id->name); + if (IS_ERR(hw->hw_name)) + return PTR_ERR(hw->hw_name); hwmon_dev = devm_hwmon_device_register_with_info(dev, hw->hw_name, hw, &hw->chip, NULL); -- 2.30.2