From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BE60C433E1 for ; Sun, 12 Jul 2020 08:25:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21FAB20720 for ; Sun, 12 Jul 2020 08:25:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728578AbgGLIY6 (ORCPT ); Sun, 12 Jul 2020 04:24:58 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:50330 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725974AbgGLIY6 (ORCPT ); Sun, 12 Jul 2020 04:24:58 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 50FAD1C0BD2; Sun, 12 Jul 2020 10:24:54 +0200 (CEST) Date: Sun, 12 Jul 2020 10:24:53 +0200 From: Pavel Machek To: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= Cc: Jacek Anaszewski , Dan Murphy , Greg Kroah-Hartman , Jiri Slaby , kernel@pengutronix.de, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Johan Hovold Subject: Re: [PATCH v7 3/3] leds: trigger: implement a tty trigger Message-ID: <20200712082453.GI8295@amd> References: <20200707165958.16522-1-u.kleine-koenig@pengutronix.de> <20200707165958.16522-4-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="HkMjoL2LAeBLhbFV" Content-Disposition: inline In-Reply-To: <20200707165958.16522-4-u.kleine-koenig@pengutronix.de> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --HkMjoL2LAeBLhbFV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > +++ b/Documentation/ABI/testing/sysfs-class-led-trigger-tty > @@ -0,0 +1,6 @@ > +What: /sys/class/leds//ttyname > +Date: Jul 2020 > +KernelVersion: 5.8 > +Contact: linux-leds@vger.kernel.org > +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 > =20 > +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 !=3D trigger_data->rx || > + icount.tx !=3D 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 =3D icount.rx; > + trigger_data->tx =3D icount.tx; > + firstrun =3D false; > + > + ret =3D 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)); > +} --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --HkMjoL2LAeBLhbFV Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl8KyNUACgkQMOfwapXb+vIRGQCfcetd56bS9agQaVauYv2lHkvb 1s8An3uDX2YeCo929pVDkPHeyNch219x =NlJV -----END PGP SIGNATURE----- --HkMjoL2LAeBLhbFV--