leds: ledtrig-tty: add tty_led_mode xtension
Subsystems (2)
PATCH v2 1/2 tty: new helper function tty_get_mget
In reply to Florian EckertFor a given struct tty_struct, this provides the appropriate tty line state flags needed to add more modes to the ledtrig-tty trigger.
The new function is then used to get via tty_tiocmget() the different tty line states.
--- drivers/tty/tty_io.c | 30 +++++++++++++++++++++++------- include/linux/tty.h | 1 + 2 files changed, 24 insertions(+), 7 deletions(-)
drivers/tty/tty_io.c +23 -7
@@ -2493,26 +2493,42 @@ static int send_break(struct tty_struct *tty, unsigned int duration)return retval; } +/* +* tty_get_mget - get modem status +* @tty: tty device +* +* Obtain the modem status bits from the tty driver if the feature +* is supported. Return -ENOTTY if it is not available. +*/ +int tty_get_mget (struct tty_struct *tty) +{ +int retval = -ENOTTY ; + +if (tty->ops->tiocmget) + retval = tty->ops->tiocmget (tty); + +return retval; +} +EXPORT_SYMBOL_GPL (tty_get_mget); +/** * tty_tiocmget - get modem status * @tty: tty device * @p: pointer to result * * Obtain the modem status bits from the tty driver if the feature is -* supported. Return -%ENOTTY if it is not available. +* supported. * * Locking: none (up to the driver) */ static int tty_tiocmget (struct tty_struct *tty,int __user *p) { -int retval = -ENOTTY ; +int retval; -if (tty->ops->tiocmget) { - retval = tty->ops->tiocmget (tty); + retval =tty_get_mget (tty); +if (retval >=0 ) + retval =put_user (retval, p); -if (retval >=0 ) - retval =put_user (retval, p); - }return retval; }
include/linux/tty.h +1 -0
@@ -421,6 +421,7 @@ int tty_unthrottle_safe(struct tty_struct *tty);int tty_do_resize (struct tty_struct *tty,struct winsize *ws);int tty_get_icount (struct tty_struct *tty,struct serial_icounter_struct *icount); +int tty_get_mget (struct tty_struct *tty);int is_current_pgrp_orphaned (void );void tty_hangup (struct tty_struct *tty);void tty_vhangup (struct tty_struct *tty);
Signature · 1 line
2.30.2
v2 cover leds: ledtrig-tty: add tty_led_mode xtension
Hello,
here commes v2 of this series to add additional tty_led_modes. Changes compared to the initial patchset with [email protected] are.
Addressed review comments by Jiri Slaby are:
tty.h:
- Fix compilation error because of wrong rebaseing
- Remove empty lines
- Use new 'tty_get_mget' in 'tty_tiocmget'
ledtrg-tty.c:
- Update commit description
- Use enum for tty_led_mod in struct ledtrig_tty_date
- Rename sysfs file from 'mode' to 'tty_led_mode'
- Change tty_led_mode show function to use loop instead of switch/case
- Change tty_led_mode store function to use loop instead of switch/case
- Check return value of function tty_get_mget
Florian Eckert (2):
tty: new helper function tty_get_mget
trigger: ledtrig-tty: add additional modes
.../ABI/testing/sysfs-class-led-trigger-tty | 16 ++ drivers/leds/trigger/ledtrig-tty.c | 146 ++++++++++++++++-- drivers/tty/tty_io.c | 30 +++- include/linux/tty.h | 1 + 4 files changed, 171 insertions(+), 22 deletions(-)
Signature · 1 line
2.30.2
PATCH v2 2/2 trigger: ledtrig-tty: add additional modes
Until now, the LED is flashed when data is transmitted. With a legacy serial interface there are additional input signal lines.
CTS: Clear To Send -> DCE is ready to accept data from the DTE
DSR: Data Set Ready -> DCE is ready to receive and send data.
CAR: Data Carrier Detect -> DCE is receiving a carrier from a remote DCE.
RNG: Ring Indicator -> DCE has detected an incoming ring on the line.
Add additional modes to trigger the selected LED.
The following modes are supported:
Tx/Rx: Flash LED on data transmission (default)
CTS: DCE Ready to accept data from the DTE.
DSR: DCE is ready to receive and send data.
CAR: DCE is receiving a carrier from a remote DTE.
RNG: DCE has detected an incoming ring signal.
The mode can be changed for example with the following command:
echo "CTS" > /sys/class/leds/<led>/tty_led_mode
This would turn on the LED, when the DTE(modem) signals the DCE that it is ready to accept data.
--- .../ABI/testing/sysfs-class-led-trigger-tty | 16 ++ drivers/leds/trigger/ledtrig-tty.c | 146 ++++++++++++++++-- 2 files changed, 147 insertions(+), 15 deletions(-)
Documentation/ABI/testing/sysfs-class-led-trigger-tty +16 -0
@@ -4,3 +4,19 @@ KernelVersion: 5.10 Contact: [email protected] Description: Specifies the tty device name of the triggering tty + +What: /sys/class/leds/<led>/mode +Date: January 2023 +KernelVersion: 6.3 +Description: + Specifies the operating to trigger the LED. + The following operating modes are supported: + Tx/Rx: Flash LED on data transmission (default) + CTS: DCE Ready to accept data from the DTE. + LED on if line is high. + DSR: DCE is ready to receive and send data. + LED on if line is high. + CAR: DCE is receiving a carrier from a remote DTE. + LED on if line is high. + RNG: DCE has detected an incoming ring signal. + LED on if line is high.
drivers/leds/trigger/ledtrig-tty.c +131 -15
188 lines not on this page · raw message
Signature · 1 line
2.30.2
Greg KH
maintainerRe: [PATCH v2 1/2] tty: new helper function tty_get_mget
In reply to Florian EckertQuoted 17 lines · Florian Eckert
For a given struct
tty_struct, this provides the appropriate tty line state flags needed to add more modes to the ledtrig-tty trigger.The new function is then used to get via
tty_tiocmget()the different tty line states.Signed-off-by Florian Eckert <[email protected]>--- drivers/tty/tty_io.c | 30 +++++++++++++++++++++++------- include/linux/tty.h | 1 + 2 files changed, 24 insertions(+), 7 deletions(-)drivers/tty/tty_io.c +0
-0
drivers/tty/tty_io.c static int send_break(struct tty_struct *tty, unsigned int duration) · line 2501
Quoted 9 lines
drivers/tty/tty_io.c +6
-0@@ -2493,26 +2493,42 @@ static int send_break(struct tty_struct *tty, unsigned int duration)return retval; } +/* +* tty_get_mget - get modem status +* @tty: tty device +* +* Obtain the modem status bits from the tty driver if the feature +* is supported. Return -ENOTTY if it is not available.
Please make this proper kernel doc, the first comment line has to be /**
And you didn't mark -ENOTTY properly here either :(
Quoted 10 lines
drivers/tty/tty_io.c +10
-0+*/ +int tty_get_mget (struct tty_struct *tty) +{ +int retval = -ENOTTY ; + +if (tty->ops->tiocmget) + retval = tty->ops->tiocmget (tty); + +return retval; +}
drivers/tty/tty_io.c static int send_break(struct tty_struct *tty, unsigned int duration) · line 2520
Quoted 10 lines
drivers/tty/tty_io.c +3
-1+EXPORT_SYMBOL_GPL (tty_get_mget); +/** * tty_tiocmget - get modem status * @tty: tty device * @p: pointer to result * * Obtain the modem status bits from the tty driver if the feature is -* supported. Return -%ENOTTY if it is not available. +* supported.
Why did you remove the return value statement from the documentation here? It's still true, right?
thanks,
greg k-h