From patchwork Tue Apr 5 09:24:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Walle X-Patchwork-Id: 12801403 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 051D0C433EF for ; Tue, 5 Apr 2022 10:46:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234282AbiDEKgE (ORCPT ); Tue, 5 Apr 2022 06:36:04 -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 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@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 Reviewed-by: Tom Rix --- 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);