Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1093753imu; Fri, 9 Nov 2018 10:49:14 -0800 (PST) X-Google-Smtp-Source: AJdET5eRI3lMWmifzbK4Dfqu79IUKONDYTEluPvdB+tYEigLPHL1HUr1qunK+Sjjmw5t9QGIsodc X-Received: by 2002:a63:2a4a:: with SMTP id q71mr8409225pgq.374.1541789354811; Fri, 09 Nov 2018 10:49:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541789354; cv=none; d=google.com; s=arc-20160816; b=ZHS2f6z2pSXKKYGK/JWlaOuzgYquV7obO1MFjFFSQBuO0ISjuMBAGO8EwQYUwmYEG/ 7edy5pSz03Z9aKmbdEXZmTl2tF8eFZDZ/hek9e1r5KJToS2FjpCbIaS6YnZh1pGZ5yyB mt4lhW+wzqlT6WybhfCJ19FO3IFa6QB+FXHnCicbqfH9kaQaNr1rkVYh8kP2FzEMaN0j Yce0mSQhIRRQKKZUYEmc992b6oTFKmlsyFPNREzrcJBvrs1J9ibCbH8N+Owq/+FcJ7MB N1d+UhzcGKLzA3TtKjp3OpSC/zyKmoaq72PM9Ll5DqVA34Gf4HRo6QE1uHIKHrRlhImL TVFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=sS/K2Y1C/Br2Joj1o0Kr52Ok9VmM8Y7VMiaCyUP3JyE=; b=I2/BeDWHo/aDSLGDVB91ds+zne0z/O4f49PrU/X3IvuiRIeexLiFCabFRsMqfnSt/k TFqC05ah1mJKBH6FWl4kel1Mkp7lNEomznD7gevy+qeA3b0i96Msa7H8y6rhBe6GS2kO ncKtbAEmGteNb/6wAl4u+/P6Hqc3CJOpTdZLt0ASO2aAZNx1s98/BG/kcKKGmDbRJ+hQ MHviVT8pahfU7Xy6tohohDuduQ8821n6/zuQvZnDTxHj/iPtXjpRz2m6z1y9y4hSdq2F v1cW8B3mh/DR09wj7WuYMLso2XeXGFB7/06tCtkj93iarYqYtGwXXfwNM/OADaRrHoDz gV3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g5-v6si7416804pgm.223.2018.11.09.10.48.56; Fri, 09 Nov 2018 10:49:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728664AbeKJEaX (ORCPT + 99 others); Fri, 9 Nov 2018 23:30:23 -0500 Received: from mx0a-00010702.pphosted.com ([148.163.156.75]:42214 "EHLO mx0b-00010702.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728162AbeKJEaX (ORCPT ); Fri, 9 Nov 2018 23:30:23 -0500 Received: from pps.filterd (m0098781.ppops.net [127.0.0.1]) by mx0a-00010702.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wA9IjggU024776; Fri, 9 Nov 2018 12:48:06 -0600 Received: from ni.com (skprod3.natinst.com [130.164.80.24]) by mx0a-00010702.pphosted.com with ESMTP id 2nn531jd7m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Nov 2018 12:48:06 -0600 Received: from us-aus-exhub2.ni.corp.natinst.com (us-aus-exhub2.ni.corp.natinst.com [130.164.68.32]) by us-aus-skprod3.natinst.com (8.16.0.22/8.16.0.22) with ESMTPS id wA9Im5DM008577 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 9 Nov 2018 12:48:05 -0600 Received: from us-aus-exch3.ni.corp.natinst.com (130.164.68.13) by us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 9 Nov 2018 12:48:05 -0600 Received: from us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) by us-aus-exch3.ni.corp.natinst.com (130.164.68.13) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 9 Nov 2018 12:48:05 -0600 Received: from senary.amer.corp.natinst.com (130.164.49.7) by us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Fri, 9 Nov 2018 12:48:05 -0600 From: Kyle Roeschley To: Andrew Lunn , Florian Fainelli CC: "David S . Miller" , , , Kyle Roeschley Subject: [PATCH v3] net: phy: leds: Don't make our own link speed names Date: Fri, 9 Nov 2018 12:48:03 -0600 Message-ID: <20181109184803.15588-1-kyle.roeschley@ni.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-11-09_06:,, signatures=0 X-Proofpoint-Spam-Reason: safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The phy core provides a handy phy_speed_to_str() helper, so use that instead of doing our own formatting of the different known link speeds. To do this, increase PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE to 11 so we can fit 'Unsupported' if necessary. Signed-off-by: Kyle Roeschley --- v3: const-ify suffix param of phy_led_trigger_format_name() to silence warning. v2: Increase PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE to fit 'Unsupported'. drivers/net/phy/phy_led_triggers.c | 15 ++------------- include/linux/phy_led_triggers.h | 2 +- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/net/phy/phy_led_triggers.c b/drivers/net/phy/phy_led_triggers.c index 491efc1bf5c4..263385b75bba 100644 --- a/drivers/net/phy/phy_led_triggers.c +++ b/drivers/net/phy/phy_led_triggers.c @@ -67,7 +67,7 @@ void phy_led_trigger_change_speed(struct phy_device *phy) EXPORT_SYMBOL_GPL(phy_led_trigger_change_speed); static void phy_led_trigger_format_name(struct phy_device *phy, char *buf, - size_t size, char *suffix) + size_t size, const char *suffix) { snprintf(buf, size, PHY_ID_FMT ":%s", phy->mdio.bus->id, phy->mdio.addr, suffix); @@ -77,20 +77,9 @@ static int phy_led_trigger_register(struct phy_device *phy, struct phy_led_trigger *plt, unsigned int speed) { - char name_suffix[PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE]; - plt->speed = speed; - - if (speed < SPEED_1000) - snprintf(name_suffix, sizeof(name_suffix), "%dMbps", speed); - else if (speed == SPEED_2500) - snprintf(name_suffix, sizeof(name_suffix), "2.5Gbps"); - else - snprintf(name_suffix, sizeof(name_suffix), "%dGbps", - DIV_ROUND_CLOSEST(speed, 1000)); - phy_led_trigger_format_name(phy, plt->name, sizeof(plt->name), - name_suffix); + phy_speed_to_str(speed)); plt->trigger.name = plt->name; return led_trigger_register(&plt->trigger); diff --git a/include/linux/phy_led_triggers.h b/include/linux/phy_led_triggers.h index b37b05bfd1a6..4587ce362535 100644 --- a/include/linux/phy_led_triggers.h +++ b/include/linux/phy_led_triggers.h @@ -20,7 +20,7 @@ struct phy_device; #include #include -#define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 10 +#define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 11 #define PHY_LINK_LED_TRIGGER_NAME_SIZE (MII_BUS_ID_SIZE + \ FIELD_SIZEOF(struct mdio_device, addr)+\ -- 2.19.1