• Home
  • Raw
  • Download

Lines Matching full:phy

4 #include <linux/phy.h>
8 static struct phy_led_trigger *phy_speed_to_led_trigger(struct phy_device *phy, in phy_speed_to_led_trigger() argument
13 for (i = 0; i < phy->phy_num_led_triggers; i++) { in phy_speed_to_led_trigger()
14 if (phy->phy_led_triggers[i].speed == speed) in phy_speed_to_led_trigger()
15 return &phy->phy_led_triggers[i]; in phy_speed_to_led_trigger()
20 static void phy_led_trigger_no_link(struct phy_device *phy) in phy_led_trigger_no_link() argument
22 if (phy->last_triggered) { in phy_led_trigger_no_link()
23 led_trigger_event(&phy->last_triggered->trigger, LED_OFF); in phy_led_trigger_no_link()
24 led_trigger_event(&phy->led_link_trigger->trigger, LED_OFF); in phy_led_trigger_no_link()
25 phy->last_triggered = NULL; in phy_led_trigger_no_link()
29 void phy_led_trigger_change_speed(struct phy_device *phy) in phy_led_trigger_change_speed() argument
33 if (!phy->link) in phy_led_trigger_change_speed()
34 return phy_led_trigger_no_link(phy); in phy_led_trigger_change_speed()
36 if (phy->speed == 0) in phy_led_trigger_change_speed()
39 plt = phy_speed_to_led_trigger(phy, phy->speed); in phy_led_trigger_change_speed()
41 netdev_alert(phy->attached_dev, in phy_led_trigger_change_speed()
42 "No phy led trigger registered for speed(%d)\n", in phy_led_trigger_change_speed()
43 phy->speed); in phy_led_trigger_change_speed()
44 return phy_led_trigger_no_link(phy); in phy_led_trigger_change_speed()
47 if (plt != phy->last_triggered) { in phy_led_trigger_change_speed()
48 if (!phy->last_triggered) in phy_led_trigger_change_speed()
49 led_trigger_event(&phy->led_link_trigger->trigger, in phy_led_trigger_change_speed()
52 led_trigger_event(&phy->last_triggered->trigger, LED_OFF); in phy_led_trigger_change_speed()
55 phy->last_triggered = plt; in phy_led_trigger_change_speed()
60 static void phy_led_trigger_format_name(struct phy_device *phy, char *buf, in phy_led_trigger_format_name() argument
64 phy->mdio.bus->id, phy->mdio.addr, suffix); in phy_led_trigger_format_name()
67 static int phy_led_trigger_register(struct phy_device *phy, in phy_led_trigger_register() argument
72 phy_led_trigger_format_name(phy, plt->name, sizeof(plt->name), in phy_led_trigger_register()
84 int phy_led_triggers_register(struct phy_device *phy) in phy_led_triggers_register() argument
89 phy->phy_num_led_triggers = phy_supported_speeds(phy, speeds, in phy_led_triggers_register()
91 if (!phy->phy_num_led_triggers) in phy_led_triggers_register()
94 phy->led_link_trigger = devm_kzalloc(&phy->mdio.dev, in phy_led_triggers_register()
95 sizeof(*phy->led_link_trigger), in phy_led_triggers_register()
97 if (!phy->led_link_trigger) { in phy_led_triggers_register()
102 phy_led_trigger_format_name(phy, phy->led_link_trigger->name, in phy_led_triggers_register()
103 sizeof(phy->led_link_trigger->name), in phy_led_triggers_register()
105 phy->led_link_trigger->trigger.name = phy->led_link_trigger->name; in phy_led_triggers_register()
107 err = led_trigger_register(&phy->led_link_trigger->trigger); in phy_led_triggers_register()
111 phy->phy_led_triggers = devm_kcalloc(&phy->mdio.dev, in phy_led_triggers_register()
112 phy->phy_num_led_triggers, in phy_led_triggers_register()
115 if (!phy->phy_led_triggers) { in phy_led_triggers_register()
120 for (i = 0; i < phy->phy_num_led_triggers; i++) { in phy_led_triggers_register()
121 err = phy_led_trigger_register(phy, &phy->phy_led_triggers[i], in phy_led_triggers_register()
127 phy->last_triggered = NULL; in phy_led_triggers_register()
128 phy_led_trigger_change_speed(phy); in phy_led_triggers_register()
133 phy_led_trigger_unregister(&phy->phy_led_triggers[i]); in phy_led_triggers_register()
134 devm_kfree(&phy->mdio.dev, phy->phy_led_triggers); in phy_led_triggers_register()
136 phy_led_trigger_unregister(phy->led_link_trigger); in phy_led_triggers_register()
138 devm_kfree(&phy->mdio.dev, phy->led_link_trigger); in phy_led_triggers_register()
139 phy->led_link_trigger = NULL; in phy_led_triggers_register()
141 phy->phy_num_led_triggers = 0; in phy_led_triggers_register()
146 void phy_led_triggers_unregister(struct phy_device *phy) in phy_led_triggers_unregister() argument
150 for (i = 0; i < phy->phy_num_led_triggers; i++) in phy_led_triggers_unregister()
151 phy_led_trigger_unregister(&phy->phy_led_triggers[i]); in phy_led_triggers_unregister()
153 if (phy->led_link_trigger) in phy_led_triggers_unregister()
154 phy_led_trigger_unregister(phy->led_link_trigger); in phy_led_triggers_unregister()