From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756921AbcH2JBZ (ORCPT ); Mon, 29 Aug 2016 05:01:25 -0400 Received: from mail-oi0-f47.google.com ([209.85.218.47]:33765 "EHLO mail-oi0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750828AbcH2JBX (ORCPT ); Mon, 29 Aug 2016 05:01:23 -0400 MIME-Version: 1.0 In-Reply-To: <20160829084127.GA10529@amd> References: <57BF3D64.3090402@gmail.com> <25cdf5e1-c3b5-e8a3-8213-f35a6f6160c2@samsung.com> <20160829080551.GA7987@amd> <20160829084127.GA10529@amd> From: =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= Date: Mon, 29 Aug 2016 11:01:21 +0200 Message-ID: Subject: Re: [PATCH RFC V3.5] leds: trigger: Introduce an USB port trigger To: Pavel Machek Cc: Jacek Anaszewski , Jacek Anaszewski , Alan Stern , Richard Purdie , Felipe Balbi , Greg KH , Peter Chen , "linux-usb@vger.kernel.org" , =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , Jonathan Corbet , Ezequiel Garcia , Stephan Linz , Matthias Brugger , Boris Brezillon , Geert Uytterhoeven , "open list:DOCUMENTATION" , open list , "open list:LED SUBSYSTEM" Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id u7T91kef021446 On 29 August 2016 at 10:41, Pavel Machek wrote: > On Mon 2016-08-29 10:21:48, Rafał Miłecki wrote: >> On 29 August 2016 at 10:05, Pavel Machek wrote: >> >> >2) Having "ports" subdir with RW files, one per each existing physical port >> >> >In this situation we don't need "new_port" or "remove_port". If we >> >> >want port to be observable we just do: >> >> >echo 1 > 1-1 >> >> >Implementing this solution needs reading more details from USB subsystem. >> >> >> >> The situation here is clear IMO - the number of USB ports in the system >> >> can change dynamically. I'm not sure if this can be handled easily with >> >> sysfs, where we usually expose an interface for known set of settings. >> >> struct attribute arrays are usually defined statically at the compile >> >> time and filled with the variables, that are created with DEVICE_ATTR >> >> macro. >> > >> > sysfs already exposes current view of all usb devices. Just use it. >> >> We're talking about USB ports not devices, but this is still true. You >> can find them in >> /sys/bus/usb/devices/*/*-port* >> >> I can't see how we could use them. How could I develop sysfs interface >> in /sys/class/leds/*/ to allow userspace assigning USB ports to the >> LED trigger? > > Create /sys/bus/usb/devices/*/*-port*/led_trigger file? > > (Do you plan one USB trigger, or multiple ones?) I guess it means slightly more complex cross-subsystem interaction I may need help to understand. First of all: I will need multiple USB port triggers. It's because there are many devices with multiple USB LEDs. Some complex (but existing!) case: USB 2.0 white LED - activated by USB 2.0 dev in USB 2.0 port USB 3.0 white LED - activated by USB 2.0 dev in USB 3.0 port USB 3.0 green LED - activated by USB 3.0 dev in USB 3.0 port (This devices has separated EHCI and XHCI controllers, so we have 2 logical ports for 1 physical one) So I guess I'll need something more complex like /sys/bus/usb/devices/*/*-port*/bcm53xx:white:usb2_led_trigger /sys/bus/usb/devices/*/*-port*/bcm53xx:white:usb3_led_trigger /sys/bus/usb/devices/*/*-port*/bcm53xx:green:usb3_led_trigger in case every USB led has "usbport" trigger assigned. How can I create above sysfs files? Should I write code for this in ledtrig-usbport.c? That would require accessing struct usb_hub and then struct usb_port, but both of them are internal structs defined in drivers/usb/core/hub.h. How could I work with that? -- Rafał