1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * LED Disk Activity Trigger 4 * 5 * Copyright 2006 Openedhand Ltd. 6 * 7 * Author: Richard Purdie <rpurdie@openedhand.com> 8 */ 9 10 #include <linux/kernel.h> 11 #include <linux/init.h> 12 #include <linux/leds.h> 13 14 #define BLINK_DELAY 30 15 16 DEFINE_LED_TRIGGER(ledtrig_disk); 17 DEFINE_LED_TRIGGER(ledtrig_disk_read); 18 DEFINE_LED_TRIGGER(ledtrig_disk_write); 19 20 void ledtrig_disk_activity(bool write) 21 { 22 unsigned long blink_delay = BLINK_DELAY; 23 24 led_trigger_blink_oneshot(ledtrig_disk, 25 &blink_delay, &blink_delay, 0); 26 if (write) 27 led_trigger_blink_oneshot(ledtrig_disk_write, 28 &blink_delay, &blink_delay, 0); 29 else 30 led_trigger_blink_oneshot(ledtrig_disk_read, 31 &blink_delay, &blink_delay, 0); 32 } 33 EXPORT_SYMBOL(ledtrig_disk_activity); 34 35 static int __init ledtrig_disk_init(void) 36 { 37 led_trigger_register_simple("disk-activity", &ledtrig_disk); 38 led_trigger_register_simple("disk-read", &ledtrig_disk_read); 39 led_trigger_register_simple("disk-write", &ledtrig_disk_write); 40 41 return 0; 42 } 43 device_initcall(ledtrig_disk_init); 44