summaryrefslogtreecommitdiff
path: root/recipes-kernel/vizzini/vizzini-1.1/vizzini-1.1-ledrtig.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-kernel/vizzini/vizzini-1.1/vizzini-1.1-ledrtig.patch')
-rw-r--r--recipes-kernel/vizzini/vizzini-1.1/vizzini-1.1-ledrtig.patch117
1 files changed, 117 insertions, 0 deletions
diff --git a/recipes-kernel/vizzini/vizzini-1.1/vizzini-1.1-ledrtig.patch b/recipes-kernel/vizzini/vizzini-1.1/vizzini-1.1-ledrtig.patch
new file mode 100644
index 0000000..7d8e03a
--- /dev/null
+++ b/recipes-kernel/vizzini/vizzini-1.1/vizzini-1.1-ledrtig.patch
@@ -0,0 +1,117 @@
+diff -ur orig/vizzini.c new/vizzini.c
+--- orig/vizzini.c 2017-07-21 13:55:37.000000000 +0300
++++ new/vizzini.c 2017-07-20 15:37:52.000000000 +0300
+@@ -54,6 +54,8 @@
+ #include <linux/fcntl.h>
+ #include <asm/uaccess.h>
+
++#include <linux/leds.h>
++
+
+ #include "vizzini.h"
+ #include "vzioctl.h"
+@@ -71,6 +73,38 @@
+ static DEFINE_MUTEX(xr21v141x_table_lock);
+
+ /*
++ * LED triggers
++ */
++
++static void xr21v141x_register_led_triggers(struct xr21v141x *xr21v141x)
++{
++#ifdef CONFIG_LEDS_TRIGGERS
++ xr21v141x->led_trigger_rx_delay_on = 50;
++ xr21v141x->led_trigger_rx_delay_off = 1;
++ sprintf(xr21v141x->led_trigger_rx_name, "vizzini%d-rx", xr21v141x->minor);
++ led_trigger_register_simple(xr21v141x->led_trigger_rx_name, &xr21v141x->led_trigger_rx);
++
++ xr21v141x->led_trigger_tx_delay_on = 50;
++ xr21v141x->led_trigger_tx_delay_off = 1;
++ sprintf(xr21v141x->led_trigger_tx_name, "vizzini%d-tx", xr21v141x->minor);
++ led_trigger_register_simple(xr21v141x->led_trigger_tx_name, &xr21v141x->led_trigger_tx);
++
++ dev_info(&xr21v141x->control->dev, "%s and %s led triggers registered\n",
++ xr21v141x->led_trigger_rx_name, xr21v141x->led_trigger_tx_name);
++#endif
++}
++
++static void xr21v141x_unregister_led_triggers(struct xr21v141x *xr21v141x)
++{
++#ifdef CONFIG_LEDS_TRIGGERS
++ led_trigger_unregister_simple(xr21v141x->led_trigger_rx);
++ led_trigger_unregister_simple(xr21v141x->led_trigger_tx);
++ dev_info(&xr21v141x->control->dev, "led triggers unregistered\n");
++#endif
++}
++
++
++/*
+ * Functions for ACM control messages.
+ */
+
+@@ -330,6 +364,11 @@
+ if (!urb->actual_length)
+ return;
+
++#ifdef CONFIG_LEDS_TRIGGERS
++ led_trigger_blink_oneshot(xr21v141x->led_trigger_rx,
++ &xr21v141x->led_trigger_rx_delay_on,
++ &xr21v141x->led_trigger_rx_delay_off, 0);
++#endif
+
+ tty_insert_flip_string(&xr21v141x->port, urb->transfer_buffer, urb->actual_length);
+ tty_flip_buffer_push(&xr21v141x->port);
+@@ -653,6 +692,12 @@
+
+ spin_unlock_irqrestore(&xr21v141x->write_lock, flags);
+
++#ifdef CONFIG_LEDS_TRIGGERS
++ led_trigger_blink_oneshot(xr21v141x->led_trigger_tx,
++ &xr21v141x->led_trigger_tx_delay_on,
++ &xr21v141x->led_trigger_tx_delay_off, 0);
++#endif
++
+
+ if (stat < 0)
+ return stat;
+@@ -1723,6 +1768,9 @@
+ }
+ #endif
+
++
++ xr21v141x_register_led_triggers(xr21v141x);
++
+ return 0;
+ alloc_fail8:
+ if (xr21v141x->country_codes) {
+@@ -1817,6 +1865,8 @@
+ xr21v141x->data : xr21v141x->control);
+
+ tty_port_put(&xr21v141x->port);
++
++ xr21v141x_unregister_led_triggers(xr21v141x);
+ }
+
+ #ifdef CONFIG_PM
+diff -ur orig/vizzini.h new/vizzini.h
+--- orig/vizzini.h 2017-07-21 13:55:37.000000000 +0300
++++ new/vizzini.h 2017-07-20 15:36:57.000000000 +0300
+@@ -282,6 +282,18 @@
+ #ifdef VIZZINI_IWA
+ int iwa;
+ #endif
++
++#ifdef CONFIG_LEDS_TRIGGERS
++ char led_trigger_rx_name[32];
++ unsigned long led_trigger_rx_delay_on;
++ unsigned long led_trigger_rx_delay_off;
++ struct led_trigger *led_trigger_rx;
++ char led_trigger_tx_name[32];
++ unsigned long led_trigger_tx_delay_on;
++ unsigned long led_trigger_tx_delay_off;
++ struct led_trigger *led_trigger_tx;
++#endif
++
+ struct serial_rs485 rs485;
+ };
+