Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp19396imu; Thu, 8 Nov 2018 13:06:55 -0800 (PST) X-Google-Smtp-Source: AJdET5dHknpW6KppERLsvEI9faB25hAGCyTha2jdFw2sbqfLQ0eTNfKQ47akxa0Gg9r0fk0O2hLl X-Received: by 2002:a62:39d2:: with SMTP id u79-v6mr6193768pfj.116.1541711215395; Thu, 08 Nov 2018 13:06:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541711215; cv=none; d=google.com; s=arc-20160816; b=fMOktAajOp5camfKJ5fYXXNClKvMs+hH+4KIhl2LJcZMGhYTO0bmr2pu/smnW8uPBX YPz3fpV2+OxT9ft+BZ9hJi5BieWoIjOs/rpimhWTwkYctpVXMRvuxoYXh5+YTrzM6uxW mnk13drdJh9bCuePpFFIyiXdO54tBKQrwSFvr2W3ZeCCKfhh95ooZwlqDCFL8isafZkC OpeAh/X/7WZZSiMZpSE1/db5WSK41F9s3/OJ9KvzW1Ac/Gld/Uw3bsxmrbOhwsEqGC9y CPnFAxh3loeJlB55cf9dCipZpY34eJlkC6SE20yehTe20X/MoUGVRN4ZoXeom9dHgYCj Ce5A== 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=8FLeIhPf+0rdEdQwU2jd3Xh2auNPb0IeOFyFGOM99e8=; b=eFYxMW45pYrrGjzuMFH/j/jEbpCje46BdqfK31sYs6BKz0PKpKhTJdU022IToEKCZd Lg5BvcPrRbQ9XvXGInu5ZupQrW3/eDKDvAUfQ/UeXb1yC/MYmPrE4Pj4RZ6Nx5JoxX2O J5Au0pUCa6GJyhJEk9iRczVYo1T+0j2qgFX3Oxs7c/WKJVRtsPOjI7GB1sapeno3N466 0Pw4dty5XKx2zzbVjZSevk5TeymkZ0P3V1UgfmCSXyOmRoQSSHq6lV5kX0NBuSfmNnPj 9J6Fn56aoxfQ/H7L45j2mcrJASA4fVN9w+7ZxaLoaf/DUfN5oLmy4E378hGbypvG8q1n i2AA== 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 i11-v6si4776959pgk.29.2018.11.08.13.06.39; Thu, 08 Nov 2018 13:06:55 -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 S1727376AbeKIGlo (ORCPT + 99 others); Fri, 9 Nov 2018 01:41:44 -0500 Received: from mx0a-00010702.pphosted.com ([148.163.156.75]:34210 "EHLO mx0b-00010702.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725922AbeKIGlo (ORCPT ); Fri, 9 Nov 2018 01:41:44 -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 wA8L2qfd021296; Thu, 8 Nov 2018 15:03:14 -0600 Received: from ni.com (skprod2.natinst.com [130.164.80.23]) by mx0a-00010702.pphosted.com with ESMTP id 2nktgnxxft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 08 Nov 2018 15:03:14 -0600 Received: from us-aus-exhub2.ni.corp.natinst.com (us-aus-exhub2.ni.corp.natinst.com [130.164.68.32]) by us-aus-skprod2.natinst.com (8.16.0.22/8.16.0.22) with ESMTPS id wA8L3D8n014836 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 8 Nov 2018 15:03:13 -0600 Received: from us-aus-exch5.ni.corp.natinst.com (130.164.68.15) by us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 8 Nov 2018 15:03:13 -0600 Received: from us-aus-exhub1.ni.corp.natinst.com (130.164.68.41) by us-aus-exch5.ni.corp.natinst.com (130.164.68.15) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 8 Nov 2018 15:03:12 -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; Thu, 8 Nov 2018 15:03:13 -0600 From: Kyle Roeschley To: Andrew Lunn , Florian Fainelli CC: "David S . Miller" , , , Kyle Roeschley Subject: [PATCH v2] net: phy: leds: Don't make our own link speed names Date: Thu, 8 Nov 2018 15:03:10 -0600 Message-ID: <20181108210310.32606-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-08_12:,, 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 --- v2: Increase PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE to fit 'Unsupported'. drivers/net/phy/phy_led_triggers.c | 13 +------------ include/linux/phy_led_triggers.h | 2 +- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/net/phy/phy_led_triggers.c b/drivers/net/phy/phy_led_triggers.c index 491efc1bf5c4..2827eb413c9c 100644 --- a/drivers/net/phy/phy_led_triggers.c +++ b/drivers/net/phy/phy_led_triggers.c @@ -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