David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | /* Copyright (C) 2016 National Instruments Corp. |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 3 | */ |
| 4 | #ifndef __PHY_LED_TRIGGERS |
| 5 | #define __PHY_LED_TRIGGERS |
| 6 | |
| 7 | struct phy_device; |
| 8 | |
| 9 | #ifdef CONFIG_LED_TRIGGER_PHY |
| 10 | |
| 11 | #include <linux/leds.h> |
| 12 | #include <linux/phy.h> |
| 13 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 14 | #define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 11 |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 15 | |
| 16 | #define PHY_LINK_LED_TRIGGER_NAME_SIZE (MII_BUS_ID_SIZE + \ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame] | 17 | sizeof_field(struct mdio_device, addr)+\ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 18 | PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE) |
| 19 | |
| 20 | struct phy_led_trigger { |
| 21 | struct led_trigger trigger; |
| 22 | char name[PHY_LINK_LED_TRIGGER_NAME_SIZE]; |
| 23 | unsigned int speed; |
| 24 | }; |
| 25 | |
| 26 | |
| 27 | extern int phy_led_triggers_register(struct phy_device *phy); |
| 28 | extern void phy_led_triggers_unregister(struct phy_device *phy); |
| 29 | extern void phy_led_trigger_change_speed(struct phy_device *phy); |
| 30 | |
| 31 | #else |
| 32 | |
| 33 | static inline int phy_led_triggers_register(struct phy_device *phy) |
| 34 | { |
| 35 | return 0; |
| 36 | } |
| 37 | static inline void phy_led_triggers_unregister(struct phy_device *phy) { } |
| 38 | static inline void phy_led_trigger_change_speed(struct phy_device *phy) { } |
| 39 | |
| 40 | #endif |
| 41 | |
| 42 | #endif |