15fd54aceSGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 20cfbd328SMichal Sojka /* 30cfbd328SMichal Sojka * LED Triggers for USB Activity 40cfbd328SMichal Sojka * 50cfbd328SMichal Sojka * Copyright 2014 Michal Sojka <sojka@merica.cz> 60cfbd328SMichal Sojka */ 70cfbd328SMichal Sojka 80cfbd328SMichal Sojka #include <linux/module.h> 90cfbd328SMichal Sojka #include <linux/kernel.h> 100cfbd328SMichal Sojka #include <linux/init.h> 110cfbd328SMichal Sojka #include <linux/leds.h> 120cfbd328SMichal Sojka #include <linux/usb.h> 13812086d3SGreg Kroah-Hartman #include "common.h" 140cfbd328SMichal Sojka 150cfbd328SMichal Sojka #define BLINK_DELAY 30 160cfbd328SMichal Sojka 170cfbd328SMichal Sojka DEFINE_LED_TRIGGER(ledtrig_usb_gadget); 180cfbd328SMichal Sojka DEFINE_LED_TRIGGER(ledtrig_usb_host); 190cfbd328SMichal Sojka usb_led_activity(enum usb_led_event ev)200cfbd328SMichal Sojkavoid usb_led_activity(enum usb_led_event ev) 210cfbd328SMichal Sojka { 220cfbd328SMichal Sojka struct led_trigger *trig = NULL; 230cfbd328SMichal Sojka 240cfbd328SMichal Sojka switch (ev) { 250cfbd328SMichal Sojka case USB_LED_EVENT_GADGET: 260cfbd328SMichal Sojka trig = ledtrig_usb_gadget; 270cfbd328SMichal Sojka break; 280cfbd328SMichal Sojka case USB_LED_EVENT_HOST: 290cfbd328SMichal Sojka trig = ledtrig_usb_host; 300cfbd328SMichal Sojka break; 310cfbd328SMichal Sojka } 320cfbd328SMichal Sojka /* led_trigger_blink_oneshot() handles trig == NULL gracefully */ 33*e298d8a3SHans de Goede led_trigger_blink_oneshot(trig, BLINK_DELAY, BLINK_DELAY, 0); 340cfbd328SMichal Sojka } 350cfbd328SMichal Sojka EXPORT_SYMBOL_GPL(usb_led_activity); 360cfbd328SMichal Sojka 370cfbd328SMichal Sojka ledtrig_usb_init(void)38812086d3SGreg Kroah-Hartmanvoid __init ledtrig_usb_init(void) 390cfbd328SMichal Sojka { 400cfbd328SMichal Sojka led_trigger_register_simple("usb-gadget", &ledtrig_usb_gadget); 410cfbd328SMichal Sojka led_trigger_register_simple("usb-host", &ledtrig_usb_host); 420cfbd328SMichal Sojka } 430cfbd328SMichal Sojka ledtrig_usb_exit(void)44812086d3SGreg Kroah-Hartmanvoid __exit ledtrig_usb_exit(void) 450cfbd328SMichal Sojka { 460cfbd328SMichal Sojka led_trigger_unregister_simple(ledtrig_usb_gadget); 470cfbd328SMichal Sojka led_trigger_unregister_simple(ledtrig_usb_host); 480cfbd328SMichal Sojka } 49