Re: [PATCH v7 3/3] leds: trigger: implement a tty trigger

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi!

> +++ b/Documentation/ABI/testing/sysfs-class-led-trigger-tty
> @@ -0,0 +1,6 @@
> +What:		/sys/class/leds/<led>/ttyname
> +Date:		Jul 2020
> +KernelVersion:	5.8
> +Contact:	linux-leds@xxxxxxxxxxxxxxx
> +Description:
> +		Specifies the tty device name of the triggering tty
> diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kconfig
> index ce9429ca6dde..40ff08c93f56 100644
> --- a/drivers/leds/trigger/Kconfig
> +++ b/drivers/leds/trigger/Kconfig
> @@ -144,4 +144,11 @@ config LEDS_TRIGGER_AUDIO
>  	  the audio mute and mic-mute changes.
>  	  If unsure, say N
>  
> +config LEDS_TRIGGER_TTY
> +	tristate "LED Trigger for TTY devices"
> +	depends on TTY
> +	help
> +	  This allows LEDs to be controlled by activity on ttys which includes
> +	  serial devices like /dev/ttyS0.

"This driver can be built as a module, resulting module will be
named.. If unsure, say N."

> +++ b/drivers/leds/trigger/ledtrig-tty.c
> @@ -0,0 +1,192 @@
> +// SPDX-License-Identifier: GPL-2.0

2.0+ is preffered.

> +
> +	while (firstrun ||
> +	       icount.rx != trigger_data->rx ||
> +	       icount.tx != trigger_data->tx) {
> +
> +		led_set_brightness(trigger_data->led_cdev, LED_ON);
> +
> +		msleep(100);
> +
> +		led_set_brightness(trigger_data->led_cdev, LED_OFF);

Is this good idea inside workqueue?

> +		trigger_data->rx = icount.rx;
> +		trigger_data->tx = icount.tx;
> +		firstrun = false;
> +
> +		ret = tty_get_icount(trigger_data->tty, &icount);
> +		if (ret)
> +			return;

Unbalanced locking.

> +	}
> +
> +out:
> +	mutex_unlock(&trigger_data->mutex);
> +	schedule_delayed_work(&trigger_data->dwork, msecs_to_jiffies(100));
> +}

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux