Skip to contentSkip to conversation

leds: ledtrig-tty: add tty_led_mode xtension

PATCH Superseded Florian Eckert 3 participants 7 messages Feb 21, 2023 – Feb 22, 2023

Subsystems (2)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#1 lore raw

PATCH v5 1/2 tty: new helper function tty_get_mget

In reply to 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.

---
 drivers/tty/tty_io.c | 28 ++++++++++++++++++++++------
 include/linux/tty.h  |  1 +
 2 files changed, 23 insertions(+), 6 deletions(-)
drivers/tty/tty_io.c +22 -6
index 3149114bf130..a068b03a0828 100644
@@ -2493,6 +2493,24 @@ 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
@@ -2505,14 +2523,12 @@ static int send_break(struct tty_struct *tty, unsigned int duration)
  */
 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
index 730c3301d710..825186c0fec1 100644
@@ -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
#2 lore raw

PATCH v5 2/2 trigger: ledtrig-tty: add additional modes

In reply to Florian Eckert

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>/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            | 145 ++++++++++++++++--
 2 files changed, 146 insertions(+), 15 deletions(-)
Documentation/ABI/testing/sysfs-class-led-trigger-tty +16 -0
index 2bf6b24e781b..31d62a5ae095 100644
@@ -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 +130 -15

187 lines not on this page · raw message

Signature · 1 line
2.30.2
#0 lore raw

v5 cover leds: ledtrig-tty: add tty_led_mode xtension

Hello,

here commes v5 of this series to add additional tty_led_modes.

v5:
Changes compared to the v4 patchset with
[email protected] are.

Sorry for the inconvenience, but I sent the wrong patch for ledtrig-tty.c in v4. The v5 patchset now includes all the changes I specified in the v4 patchset.

v4:
Changes compared to the v3 patchset with
[email protected] are.

Addressed review comments by Jiri Slaby are:

ledtrig-tty.c:
- Do not use __TTY_LED_MAX pattern us instead __TTY_LED_LAST = TTY_LED_RNG
- Move declartion and assignment into one singel line
- Use __TTY_LED_LAST pattern, to simplify tty_mode_show and tty_mode_store handling

v3:
Changes compared to the v2 patchset with
[email protected] are.

Addressed review comments by Greg K-H are:

tty.h:
- Fix first comment line and remark -%ENOTTY for the new function 'tty_get_mget' to make a proper kernel doc.
- Add the return value -%ENOTTY again, I thought it was no longer needed.

v2:
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'

ledtrig-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            | 145 ++++++++++++++++--
 drivers/tty/tty_io.c                          |  28 +++-
 include/linux/tty.h                           |   1 +
 4 files changed, 169 insertions(+), 21 deletions(-)
Signature · 1 line
2.30.2
#3 lore raw

Re: [PATCH v5 2/2] trigger: ledtrig-tty: add additional modes

In reply to Florian Eckert
Thank you for the patch! Perhaps something to improve:

Hi Florian,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tty/tty-testing]
[also build test WARNING on tty/tty-next tty/tty-linus staging/staging-testing staging/staging-next staging/staging-linus pavel-leds/for-next linus/master v6.2 next-20230221] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Florian-Eckert/tty-new-helper-function-tty_get_mget/20230221-162126
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
patch link:    https://lore.kernel.org/r/20230221081901.15557-3-fe%40dev.tdt.de
patch subject: [PATCH v5 2/2] trigger: ledtrig-tty: add additional modes
reproduce:
        # https://github.com/intel-lab-lkp/linux/commit/445b7555bccd279bf106995ee42f5dbef2e97c8b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Florian-Eckert/tty-new-helper-function-tty_get_mget/20230221-162126
        git checkout 445b7555bccd279bf106995ee42f5dbef2e97c8b
        make menuconfig
        # enable CONFIG_COMPILE_TEST, CONFIG_WARN_MISSING_DOCUMENTS, CONFIG_WARN_ABI_ERRORS
        make htmldocs

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> Documentation/ABI/testing/sysfs-class-led-trigger-tty:9: WARNING: Unexpected indentation.
>> Documentation/ABI/testing/sysfs-class-led-trigger-tty:9: WARNING: Block quote ends without a blank line; unexpected unindent.

vim +9 Documentation/ABI/testing/sysfs-class-led-trigger-tty

   > 9	Date:		January 2023
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#4 lore raw

Re: [PATCH v5 2/2] trigger: ledtrig-tty: add additional modes

Quoted 36 lines · kernel test robot

Hi Florian,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tty/tty-testing]
[also build test WARNING on tty/tty-next tty/tty-linus staging/staging-testing staging/staging-next staging/staging-linus pavel-leds/for-next linus/master v6.2 next-20230221]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Florian-Eckert/tty-new-helper-function-tty_get_mget/20230221-162126
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
tty-testing

patch link:    https://lore.kernel.org/r/20230221081901.15557-3-fe%40dev.tdt.de
patch subject: [PATCH v5 2/2] trigger: ledtrig-tty: add additional modes
reproduce:
        #
https://github.com/intel-lab-lkp/linux/commit/445b7555bccd279bf106995ee42f5dbef2e97c8b
        git remote add linux-review 
https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review

Florian-Eckert/tty-new-helper-function-tty_get_mget/20230221-162126
git checkout 445b7555bccd279bf106995ee42f5dbef2e97c8b make menuconfig
# enable CONFIG_COMPILE_TEST, CONFIG_WARN_MISSING_DOCUMENTS,
CONFIG_WARN_ABI_ERRORS
make htmldocs

If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <[email protected]>
| Link:
https://lore.kernel.org/oe-kbuild-all/[email protected]/

Quoted 8 lines

All warnings (new ones prefixed by >>):

Quoted 2 lines
Quoted 2 lines

Documentation/ABI/testing/sysfs-class-led-trigger-tty:9: WARNING: Unexpected indentation. Documentation/ABI/testing/sysfs-class-led-trigger-tty:9: WARNING: Block quote ends without a blank line; unexpected unindent.

vim +9 Documentation/ABI/testing/sysfs-class-led-trigger-tty

Quoted 1 line

9 Date: January 2023

I apologies for the question! But I don't know what the test buildbot here wants from me. I've looked at the other files and I can't find anything that stands out.

--
Regards Florian

maintainer
#5 lore raw

Re: [PATCH v5 2/2] trigger: ledtrig-tty: add additional modes

Quoted 43 lines · Florian Eckert
Quoted 40 lines · kernel test robot

Hi Florian,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on tty/tty-testing]
[also build test WARNING on tty/tty-next tty/tty-linus staging/staging-testing staging/staging-next staging/staging-linus pavel-leds/for-next linus/master v6.2 next-20230221]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:
https://github.com/intel-lab-lkp/linux/commits/Florian-Eckert/tty-new-helper-function-tty_get_mget/20230221-162126
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
tty-testing
patch link: https://lore.kernel.org/r/20230221081901.15557-3-fe%40dev.tdt.de
patch subject: [PATCH v5 2/2] trigger: ledtrig-tty: add additional modes reproduce:
        #
https://github.com/intel-lab-lkp/linux/commit/445b7555bccd279bf106995ee42f5dbef2e97c8b
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Florian-Eckert/tty-new-helper-function-tty_get_mget/20230221-162126 git checkout 445b7555bccd279bf106995ee42f5dbef2e97c8b make menuconfig

        # enable CONFIG_COMPILE_TEST, CONFIG_WARN_MISSING_DOCUMENTS,
CONFIG_WARN_ABI_ERRORS
        make htmldocs

If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <[email protected]>
| Link:
https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

Quoted 2 lines
Quoted 2 lines

Documentation/ABI/testing/sysfs-class-led-trigger-tty:9: WARNING: Unexpected indentation. Documentation/ABI/testing/sysfs-class-led-trigger-tty:9: WARNING: Block quote ends without a blank line; unexpected unindent.

Quoted 6 lines
Quoted 3 lines

vim +9 Documentation/ABI/testing/sysfs-class-led-trigger-tty

   > 9    Date:        January 2023

I apologies for the question! But I don't know what the test buildbot here wants from me. I've looked at the other files and I can't find anything that stands out.

sphinx is always misleading.

It's the indentation of all "LED on if ...".

Signature · 2 lines
js
suse labs
maintainer
#6 lore raw

Re: [PATCH v5 2/2] trigger: ledtrig-tty: add additional modes

Quoted 10 lines · Jiri Slaby
Quoted 6 lines
Quoted 3 lines

vim +9 Documentation/ABI/testing/sysfs-class-led-trigger-tty

   > 9    Date:        January 2023

I apologies for the question! But I don't know what the test buildbot here wants from me. I've looked at the other files and I can't find anything that stands out.

sphinx is always misleading.

It's the indentation of all "LED on if ...".

So this should work:

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.

Signature · 2 lines
js
suse labs