blob: 5c4d7a7551011da675fd47f996ab73201a988a7b [file] [log] [blame]
Thomas Gleixnerc942fdd2019-05-27 08:55:06 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Zach Brown2e0bc452016-10-17 10:49:55 -05002/* Copyright (C) 2016 National Instruments Corp.
Zach Brown2e0bc452016-10-17 10:49:55 -05003 */
4#ifndef __PHY_LED_TRIGGERS
5#define __PHY_LED_TRIGGERS
6
7struct phy_device;
8
9#ifdef CONFIG_LED_TRIGGER_PHY
10
11#include <linux/leds.h>
Geert Uytterhoeven3c880eb2017-01-25 11:39:50 +010012#include <linux/phy.h>
Zach Brown2e0bc452016-10-17 10:49:55 -050013
Kyle Roeschley457937b2018-11-09 12:48:03 -060014#define PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE 11
Zach Brown2e0bc452016-10-17 10:49:55 -050015
Geert Uytterhoeven3c880eb2017-01-25 11:39:50 +010016#define PHY_LINK_LED_TRIGGER_NAME_SIZE (MII_BUS_ID_SIZE + \
Pankaj Bharadiyac5936422019-12-09 10:31:43 -080017 sizeof_field(struct mdio_device, addr)+\
Zach Brown2e0bc452016-10-17 10:49:55 -050018 PHY_LED_TRIGGER_SPEED_SUFFIX_SIZE)
19
20struct phy_led_trigger {
21 struct led_trigger trigger;
22 char name[PHY_LINK_LED_TRIGGER_NAME_SIZE];
23 unsigned int speed;
24};
25
26
27extern int phy_led_triggers_register(struct phy_device *phy);
28extern void phy_led_triggers_unregister(struct phy_device *phy);
29extern void phy_led_trigger_change_speed(struct phy_device *phy);
30
31#else
32
33static inline int phy_led_triggers_register(struct phy_device *phy)
34{
35 return 0;
36}
37static inline void phy_led_triggers_unregister(struct phy_device *phy) { }
38static inline void phy_led_trigger_change_speed(struct phy_device *phy) { }
39
40#endif
41
42#endif