| .. | .. |
|---|
| 1 | | -/* Copyright (C) 2016 National Instruments Corp. |
|---|
| 2 | | - * |
|---|
| 3 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 4 | | - * it under the terms of the GNU General Public License as published by |
|---|
| 5 | | - * the Free Software Foundation; either version 2 of the License, or |
|---|
| 6 | | - * (at your option) any later version. |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 9 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | | - * GNU General Public License for more details. |
|---|
| 12 | | - */ |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
|---|
| 2 | +/* Copyright (C) 2016 National Instruments Corp. */ |
|---|
| 13 | 3 | #include <linux/leds.h> |
|---|
| 14 | 4 | #include <linux/phy.h> |
|---|
| 15 | 5 | #include <linux/phy_led_triggers.h> |
|---|
| .. | .. |
|---|
| 68 | 58 | EXPORT_SYMBOL_GPL(phy_led_trigger_change_speed); |
|---|
| 69 | 59 | |
|---|
| 70 | 60 | static void phy_led_trigger_format_name(struct phy_device *phy, char *buf, |
|---|
| 71 | | - size_t size, char *suffix) |
|---|
| 61 | + size_t size, const char *suffix) |
|---|
| 72 | 62 | { |
|---|
| 73 | 63 | snprintf(buf, size, PHY_ID_FMT ":%s", |
|---|
| 74 | 64 | phy->mdio.bus->id, phy->mdio.addr, suffix); |
|---|
| .. | .. |
|---|
| 78 | 68 | struct phy_led_trigger *plt, |
|---|
| 79 | 69 | unsigned int speed) |
|---|
| 80 | 70 | { |
|---|
| 81 | | - char name_suffix[PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE]; |
|---|
| 82 | | - |
|---|
| 83 | 71 | plt->speed = speed; |
|---|
| 84 | | - |
|---|
| 85 | | - if (speed < SPEED_1000) |
|---|
| 86 | | - snprintf(name_suffix, sizeof(name_suffix), "%dMbps", speed); |
|---|
| 87 | | - else if (speed == SPEED_2500) |
|---|
| 88 | | - snprintf(name_suffix, sizeof(name_suffix), "2.5Gbps"); |
|---|
| 89 | | - else |
|---|
| 90 | | - snprintf(name_suffix, sizeof(name_suffix), "%dGbps", |
|---|
| 91 | | - DIV_ROUND_CLOSEST(speed, 1000)); |
|---|
| 92 | | - |
|---|
| 93 | 72 | phy_led_trigger_format_name(phy, plt->name, sizeof(plt->name), |
|---|
| 94 | | - name_suffix); |
|---|
| 73 | + phy_speed_to_str(speed)); |
|---|
| 95 | 74 | plt->trigger.name = plt->name; |
|---|
| 96 | 75 | |
|---|
| 97 | 76 | return led_trigger_register(&plt->trigger); |
|---|