Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp928967imu; Tue, 11 Dec 2018 09:42:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/WWqAwHr4YkNlnRiVzn1Q5IHFb71eVvkRuNSTu/4uvt3eXvTKeOEiBGk9L0Yr0Y1kF5rmCu X-Received: by 2002:a17:902:7581:: with SMTP id j1mr16981958pll.308.1544550135117; Tue, 11 Dec 2018 09:42:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544550135; cv=none; d=google.com; s=arc-20160816; b=faGUW8ApAP4BtMQT2hkha1WX0kP7f9AjJxrMWjfG6yscHR09OgDlyqbVZ8yWvBe3cf 3WkmcHOPTkYVa2MkT0+3qLzGYSW6IUcubSdz4DpW1x2gFbu1JdtEvRXblvQIh0yTE6MZ GbWT5usKQ0URzhts+FVJTducNC9rPUsM1eeVeZJJEG5FmVKSm0VULRQ2UhonIPkhG/Iy tOPk+VW4KTkXI9V/rWPpFe7N9HYeVyykp/hPrfiEUHMSaP3rqrLWgg5o8BEbIlJLqPCC BEyUgSby0T1t12zfB/RG5D8KxibiWiEWFWMlbLfkCV82u0qGnEsFp84PbiczkXWQXqpu bsMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ScvAbFz27AHGveyd69R6j4+vIc3atMVuBNxL+/01Cc8=; b=K/FTLkCQgBPMxShEbsCNrEKBAbK+OjhWFI5KezpaEMh5wGt4k4zBrk95ddivjRgoOX GgD7VJ33rYFjWRmzNuBwsdBNvj4sq2UJU8tSf6KfVdnZ+j3s/xyCxEA2Cc5AzXgvPB2D NfjX9Syk/wLgj8BfS6xlK5nsjErfspqFdbyqCIWC6L/DiZJQWAIsml3QQZ43b0y5qwMf 6Kf2T+qnm4Mn7uEsctoh2GEGM/w33qOHKw9W57NsuqF8lOT9YAvXPIDLPRhjvGg1QSqr bfuAlzVnWAP+hyIrUSzEIIe16YucjZ+/ICyH9KSziBNqt4mDaqizjuETLCzmxHq6kgTl ilcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Op0YYhUj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k38si12109133pgi.235.2018.12.11.09.42.00; Tue, 11 Dec 2018 09:42:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Op0YYhUj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726562AbeLKR14 (ORCPT + 99 others); Tue, 11 Dec 2018 12:27:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:33492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726231AbeLKR14 (ORCPT ); Tue, 11 Dec 2018 12:27:56 -0500 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9A82F208E7; Tue, 11 Dec 2018 17:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544549274; bh=dwqK2tKwgQnPscC9YeC7ymqibML7h+WGcSdCOVkbTuM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Op0YYhUj02LYPWdCTH0KtZn8FkhOn6Z/gWtCYFv8QnCAWj2OSNUUYpFFqwe6KSpLo bOq0FGq/4iSvDlJsxr2Aj6jRtvi0i3W+Qyqk5D4aa2LuZDGy9fkU8g+q4dsDmSZSXs ig+zRFIYBN8aTCXhVekIhQ5ioiccCBFw+nNE0OWs= Received: by mail-qk1-f176.google.com with SMTP id n12so9036965qkh.11; Tue, 11 Dec 2018 09:27:54 -0800 (PST) X-Gm-Message-State: AA+aEWZzaTm2NBzFEInpOn2rXCDg0BmPlMWYTtgZUj3PWleRG01tjaTf pAGshJyp8W2maQf2hnwniS5kjIlo+j74bLPPQw== X-Received: by 2002:a37:5686:: with SMTP id k128mr14520681qkb.29.1544549273756; Tue, 11 Dec 2018 09:27:53 -0800 (PST) MIME-Version: 1.0 References: <1541542052-10081-1-git-send-email-jacek.anaszewski@gmail.com> <1541542052-10081-5-git-send-email-jacek.anaszewski@gmail.com> <5bea0eb8.1c69fb81.6b921.80e6@mx.google.com> <0a0b176c-4eb4-4b0e-6c3c-b3c6c8f5fff5@gmail.com> <20181130210814.GA5756@amd> In-Reply-To: From: Rob Herring Date: Tue, 11 Dec 2018 11:27:41 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 04/24] dt-bindings: leds: Add function and color properties To: Jacek Anaszewski Cc: Pavel Machek , Linux LED Subsystem , devicetree@vger.kernel.org, "linux-kernel@vger.kernel.org" , Baolin Wang , Daniel Mack , Dan Murphy , Linus Walleij , Oleh Kravchenko , Sakari Ailus , Simon Shields Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 1, 2018 at 3:17 PM Jacek Anaszewski wrote: > > On 11/30/2018 11:19 PM, Rob Herring wrote: > > On Fri, Nov 30, 2018 at 3:08 PM Pavel Machek wrote: > >> > >> Hi! > >> > >>>> Pavel gave following examples: > >>>> > >>>> eth0:green:link > >>>> adsl0:green:link > >>>> adsl0:red:error > >>>> > >>>> So we would have e.g.: > >>>> > >>>> associated-vl42-device = <&camera1>; > >>>> associated-network-device = <&phy1>; > >>>> associated-block-device = <&phy1>; > >>> > >>> Variable property names are kind of a pain to parse. > >> > >> Ok, would it be enough to have associated-device = <&whatever>? > > > > Yeah, but I though you needed the device type name in there. > > > >>> Perhaps when LEDs are associated with a device, we shouldn't care > >>> within the context of the LED subsystem what the name is. The > >>> association is more important and if you have that exposed, then you > >>> don't really need to care what the name is. You still have to deal > >>> with a device with more than 1 LED, but that becomes a problem local > >>> to that device. > >>> > >>> What I'm getting at is following a more standard binding pattern of > >>> providers and consumers like we have for gpios, clocks, etc. So we'd > >>> have something like this: > >>> > >>> ethernet { > >>> ... > >>> leds = <&green_led>, <&red_led>; > >>> led-names = "link", "err"; > >>> }; > >> > >> Basically every single device could have a LED associated with it > >> ("activity"). Would doing it like this mean we'd have to modify every > >> single driver to parse leds / led-names properties? > > > > Normally, that's how properties like this would work. A driver is also > > what knows how the leds should function. > > This is not true in case of associations where LED controller is > an independent device, as in Pavel's example [0]. I'm not really following how the HDD example is different. The parent of an LED would be the controller. The link to the led node would be in the disk controller node. Though maybe if things get complicated enough, we'd want to describe the drives or drive bays in DT. > > A driver can retrieve the led > > and associate it with the 'foo-bar' function. The 'foo-bar' function > > then doesn't have to be defined in DT nor exposed to userspace. It > > wouldn't even have to be driver specific. The driver's subsystem could > > handle it all if the led functions are standardized. Though then you'd > > be back to needing standard names for 'led-names', but that's no worse > > that trigger names. This model would also allow getting rid of > > 'linux,default-trigger' properties in a lot of cases which wouldn't be > > a bad thing. > > > > However, having drivers handle this is not required. You can iterate > > thru the tree for nodes with 'leds' and find the node which has a > > phandle to the led node you care about. > > This way of discovering associations between devices and LEDs > would be more reliable than by devicename part of LED class device > as discussed previously. > > However, I've just tried to verify how it works, but > I can't find the way to get the of_node phandle from sysfs. > > The "of_node" link in per-device dirs in /sys/devices point > to the directories containing DT properties of the node, but > I see no way to obtain the node phandle. You probably don't want to be doing this in userspace. It's possible, but you've got to read the 'leds' property to get the phandle and then walk the tree to find the node with the matching phandle property value (i.e. reimplement what the kernel does). You'd probably would instead want to define a LED specific symlink sysfs attr either in the associated device to the led device or vice versa. Rob