From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Chen Subject: Re: [PATCH V2] leds: trigger: Introduce an USB port trigger Date: Mon, 18 Jul 2016 10:31:26 +0800 Message-ID: <20160718023126.GB31293@shlinux2> References: <1468239883-22695-1-git-send-email-zajec5@gmail.com> <1468617060-29830-1-git-send-email-zajec5@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Content-Disposition: inline In-Reply-To: <1468617060-29830-1-git-send-email-zajec5@gmail.com> Sender: linux-leds-owner@vger.kernel.org To: =?utf-8?B?UmFmYcWCIE1pxYJlY2tp?= Cc: Richard Purdie , Jacek Anaszewski , Felipe Balbi , linux-usb@vger.kernel.org, Rob Herring , Mark Rutland , Jonathan Corbet , Sakari Ailus , Ezequiel Garcia , Boris Brezillon , Pavel Machek , Geert Uytterhoeven , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , open list , "open list:DOCUMENTATION" , "open list:LED SUBSYSTEM" List-Id: devicetree@vger.kernel.org On Fri, Jul 15, 2016 at 11:10:45PM +0200, Rafa=C5=82 Mi=C5=82ecki wrote= : > + > +usbport trigger: > +- usb-ports : List of USB ports that usbport should observed for tur= ning on a > + given LED. > + %s/should/should be > Examples: > =20 > system-status { > @@ -58,6 +64,11 @@ system-status { > ... > }; > =20 > +usb { > + label =3D "USB"; > + usb-ports =3D <&ohci_port1>, <&ehci_port1>; > +}; > + > camera-flash { > label =3D "Flash"; > led-sources =3D <0>, <1>; > diff --git a/Documentation/leds/ledtrig-usbport.txt b/Documentation/l= eds/ledtrig-usbport.txt > new file mode 100644 > index 0000000..642c4cd > --- /dev/null > +++ b/Documentation/leds/ledtrig-usbport.txt > @@ -0,0 +1,19 @@ > +USB port LED trigger > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > + > +This LED trigger can be used for signaling user a presence of USB de= vice in a > +given port. It simply turns on LED when device appears and turns it = off when it > +disappears. > + > +It requires specifying a list of USB ports that should be observed. = This can be > +done in DT by setting a proper property with list of a phandles. If = more than > +one port is specified, LED will be turned on as along as there is at= least one > +device connected to any of ports. > + > +This trigger can be activated from user space on led class devices a= s shown > +below: > + > + echo usbport > trigger > + > +Nevertheless, current there isn't a way to specify list of USB ports= from user > +space. > diff --git a/drivers/leds/trigger/Kconfig b/drivers/leds/trigger/Kcon= fig > index 9893d91..5b8e7c7 100644 > --- a/drivers/leds/trigger/Kconfig > +++ b/drivers/leds/trigger/Kconfig > @@ -126,4 +126,12 @@ config LEDS_TRIGGER_PANIC > a different trigger. > If unsure, say Y. > =20 > +config LEDS_TRIGGER_USBPORT > + tristate "USB port LED trigger" > + depends on LEDS_TRIGGERS && USB && OF > + help > + This allows LEDs to be controlled by USB events. This trigger wil= l > + enable LED if some USB device gets connected to any of ports spec= ified > + in DT. > + > endif # LEDS_TRIGGERS > diff --git a/drivers/leds/trigger/Makefile b/drivers/leds/trigger/Mak= efile > index 8cc64a4..80e2494 100644 > --- a/drivers/leds/trigger/Makefile > +++ b/drivers/leds/trigger/Makefile > @@ -10,3 +10,4 @@ obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) +=3D ledtrig-= default-on.o > obj-$(CONFIG_LEDS_TRIGGER_TRANSIENT) +=3D ledtrig-transient.o > obj-$(CONFIG_LEDS_TRIGGER_CAMERA) +=3D ledtrig-camera.o > obj-$(CONFIG_LEDS_TRIGGER_PANIC) +=3D ledtrig-panic.o > +obj-$(CONFIG_LEDS_TRIGGER_USBPORT) +=3D ledtrig-usbport.o > diff --git a/drivers/leds/trigger/ledtrig-usbport.c b/drivers/leds/tr= igger/ledtrig-usbport.c > new file mode 100644 > index 0000000..97b064c > --- /dev/null > +++ b/drivers/leds/trigger/ledtrig-usbport.c > @@ -0,0 +1,206 @@ > +/* > + * USB port LED trigger > + * > + * Copyright (C) 2016 Rafa=C5=82 Mi=C5=82ecki > + * > + * This program is free software; you can redistribute it and/or mod= ify > + * it under the terms of the GNU General Public License as published= by > + * the Free Software Foundation; either version 2 of the License, or= (at > + * your option) any later version. > + */ GPL v2 only. > +MODULE_AUTHOR("Rafa=C5=82 Mi=C5=82ecki "); > +MODULE_DESCRIPTION("USB port trigger"); > +MODULE_LICENSE("GPL"); GPL v2 After you fix above, feel free to add: Reviewed-by: Peter Chen --=20 Best Regards, Peter Chen