From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753520AbcGZHin (ORCPT ); Tue, 26 Jul 2016 03:38:43 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:65210 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751333AbcGZHil (ORCPT ); Tue, 26 Jul 2016 03:38:41 -0400 X-AuditID: cbfec7f4-f796c6d000001486-7c-5797137d807a Message-id: <5797137C.9090304@samsung.com> Date: Tue, 26 Jul 2016 09:38:36 +0200 From: Jacek Anaszewski User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130804 Thunderbird/17.0.8 MIME-version: 1.0 To: David Lechner Cc: linux-leds@vger.kernel.org, Richard Purdie , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Joel Becker Subject: Re: [RFC] User-defined leds References: <57965C15.1070705@lechnology.com> In-reply-to: <57965C15.1070705@lechnology.com> Content-type: text/plain; charset=UTF-8; format=flowed Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsVy+t/xq7q1wtPDDdauNbVY1CBmcfLcNxaL TY+vsVpc3jWHzWLrm3WMFrt3PWV1YPN4ejHI41P/SVaPzUvqPfbM/8Hq8XmTXABrFJdNSmpO Zllqkb5dAlfG5S7pgjXCFTuaDrE0MG7h72Lk5JAQMJFoX7GZHcIWk7hwbz1bFyMXh5DAUkaJ Jd+6WCCcZ4wSv9sXMXcxcnDwCmhJdNyUAGlgEVCVmPf/E1gzm4ChxM8Xr5lAbFGBCIk/p/ex gti8AoISPybfYwFpFRHQkHjR6QYykllgDaPE2m/3wOqFBVQkdizrZASpERLQldj+1hUkzCmg J/F82nNmEJtZwEziUcs6KFteYvOat8wTGAVmIdkwC0nZLCRlCxiZVzGKppYmFxQnpeca6hUn 5haX5qXrJefnbmKEBPSXHYyLj1kdYhTgYFTi4eVMmRYuxJpYVlyZe4hRgoNZSYQ3SGh6uBBv SmJlVWpRfnxRaU5q8SFGaQ4WJXHeubvehwgJpCeWpGanphakFsFkmTg4pRoY41bI/9/NeFEi gjdiqiCX0dx1UuYFknwizP6WXYX590ummO62uvy5/ZSA1DnHa++8GiZ1NHkty5Q9a2PvJfOu bo1z0h0b35a1FQLfPbZt6Fy7P1Vc1Fr1RZmrxI4djM94G29zGZWEzH8bJPv9xPMtbHt2Hfla piOyrUqminnT95CXCbejz/opsRRnJBpqMRcVJwIAY9gSw2QCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi David, On 07/25/2016 08:36 PM, David Lechner wrote: > short version: I have a use case for leds where I want to be able to use > the triggers in the leds subsystem without having a physical hardware led. > > long version: I am working on a program to make one embedded system > (http://fatcatlab.com/product/evb/) compatible with another > (http://mindstorms.lego.com). One has physical red/green LEDs, that use > the gpio leds driver to control them. The other system does not have > physical leds. However, it does have a color screen. So, my idea is > to create virtual LEDs on the screen that emulate the physical LEDs on > the other device. > > I would like to make a userspace program that works the same on both > devices. If the leds were simple on-off, then it would of course be > simpler to make the virtual leds completely in userspace. However, we > are currently using other triggers (disk activity/heatbeat/etc.) with > the leds. I would like for the virtual LEDs to be able to use these > triggers as well. > > > Proposed implementation: > > My thought is to create a new module that can be used to create > user-defined leds using configfs. Below is some sample code that I have > been experimenting with. Be aware, it does not quite match the > description I am about to give. > > In configfs you simply create a new node for each leds and assign the > name. We could have separate attributes for devicename, color and > function to enforce the naming convention or we could just allow > arbitrary names. > > Once the leds class devices are configured in configfs and exported, it > will create the usual leds class device in sysfs as well as a character > device that can be polled by the userspace program. The character device > would work a bit like evdev where any time the brightness is changed, it > spits out an event on the character device. > > It would probably be simplest to have a single character device for all > virtual leds. In this case the leds device name or some other id would > need to be part of the event structure. > > Any thoughts? Does this seem like a sane thing to do? Or maybe there is > a different way to accomplish the same thing using existing drivers? The idea sounds reasonable. Please also compare the solutions spotted by Marcel. After that please submit the patch officially, along with the sample user space application. -- Best regards, Jacek Anaszewski