Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1069153pxb; Tue, 29 Mar 2022 16:26:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxOadD22p+JLQdZ6LNKStdANBLBBOnRMnfr/MHlH6NRa7wPzLjMSZw2ijKtPYYR4yv/bABk X-Received: by 2002:a63:3d0b:0:b0:37f:ef34:1431 with SMTP id k11-20020a633d0b000000b0037fef341431mr3711391pga.547.1648596408805; Tue, 29 Mar 2022 16:26:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648596408; cv=none; d=google.com; s=arc-20160816; b=UHYwAL7PIPatHuHgupv3ONHw0j4ILMZhA3qpbSuEWkPC5PE86LvyCLo50Sy2A9n74v HmKaDHU4RTrTxIC9Dl8/L7F26YW5L5HSTrJG2uEv2n3w8H7L3P1jtXHYfNP2g+Qmmuk4 RmYI32sEAm3k6SUfOsJxxU4IFO8DMrT8/guwqVFx8+xhDZmYies05DrMYihGd3cv1q9u 9rkvIW6yJBzdHKM2aLRfKTJg7NlN9Rw6RiRQMOMeY205ehNCWuXZuzLg97U9FBxT3Nsr 5LaHSpnve6xggvfap81DtyIBRg6CnXbEjQCVMCJBeNC9ba4FpbCM9pdUhqd5+QK+WrcB sKmA== 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=m8voqXgytYyDMBr4Anf3saVzxi+gWiv76fTQ2j03gg4=; b=QSalytFnvQvRdpzjdvOzH5VxZIybK5ffGoFOHcMgW4mVpvEUYrYUojmor1ijvN3N3P R25mnCASMcFsTRl5kCg8PdPnXxmF/3f6lzZujoyeP/kRRAZLx81THVXWkUbz5Rd3NpNz UONOEbbJGTrGsXxP+HodoMkSG1KqTkvIA1d0/6FY5eufjKAAgIqP8wl6v3078O4F65Im MhCBbwX4Hyfqgcer8EBKmXenEj61wIGqxZmdRnm7vbwXFhblwTDaS0uQR81hfDOx76ah xJD/jsVyiQdS7xN2yNCcCHQGZdTRqjR5LV+iZckPipX83jCrbSOH05aS/oGz8EKGnG/j xvKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b="XfVp/4Gx"; 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 g2-20020a17090ace8200b001c7532e6d3fsi4639682pju.72.2022.03.29.16.26.35; Tue, 29 Mar 2022 16:26:48 -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="XfVp/4Gx"; 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 S239416AbiC2QJn (ORCPT + 99 others); Tue, 29 Mar 2022 12:09:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239327AbiC2QJc (ORCPT ); Tue, 29 Mar 2022 12:09:32 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0785725ECB6; Tue, 29 Mar 2022 09:07:47 -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 D22702224D; Tue, 29 Mar 2022 18:07:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1648570066; 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=m8voqXgytYyDMBr4Anf3saVzxi+gWiv76fTQ2j03gg4=; b=XfVp/4GxL4q+U/mutEbzMeEqYACGjzV4JkukcMsoPiomBUljaLDvgwNHo9D7HzAVFs39Rb 1QFQMiQpZho4oywGBA1K1Sc30FQ2iz8e5GwUV6Mi0/iuNQH2xKgzFMWZp8gL3KmwqIVnKQ Lg6NPD2YtubzncZNVh/isn8JfjoLkys= 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 v2 3/5] net: sfp: use hwmon_sanitize_name() Date: Tue, 29 Mar 2022 18:07:28 +0200 Message-Id: <20220329160730.3265481-4-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 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 hwmon_sanitize_name(). Signed-off-by: Michael Walle --- drivers/net/phy/sfp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/net/phy/sfp.c b/drivers/net/phy/sfp.c index 4dfb79807823..0d5dba30444d 100644 --- a/drivers/net/phy/sfp.c +++ b/drivers/net/phy/sfp.c @@ -1289,7 +1289,7 @@ static const struct hwmon_chip_info sfp_hwmon_chip_info = { static void sfp_hwmon_probe(struct work_struct *work) { struct sfp *sfp = container_of(work, struct sfp, hwmon_probe.work); - int err, i; + int err; /* hwmon interface needs to access 16bit registers in atomic way to * guarantee coherency of the diagnostic monitoring data. If it is not @@ -1317,16 +1317,12 @@ static void sfp_hwmon_probe(struct work_struct *work) return; } - sfp->hwmon_name = kstrdup(dev_name(sfp->dev), GFP_KERNEL); + sfp->hwmon_name = hwmon_sanitize_name(dev_name(sfp->dev)); if (!sfp->hwmon_name) { dev_err(sfp->dev, "out of memory for hwmon name\n"); return; } - for (i = 0; sfp->hwmon_name[i]; i++) - if (hwmon_is_bad_char(sfp->hwmon_name[i])) - sfp->hwmon_name[i] = '_'; - sfp->hwmon_dev = hwmon_device_register_with_info(sfp->dev, sfp->hwmon_name, sfp, &sfp_hwmon_chip_info, -- 2.30.2