From patchwork Thu Nov 17 16:04:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 1837 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp483416wrr; Thu, 17 Nov 2022 08:07:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf7gVcZYS20Mzal61yJAF4OYGHueOZwBvOcNnKPkDaANFfjzlWRsvdY7P8h7cEPpQ8UkOgbO X-Received: by 2002:a17:906:1844:b0:77a:4bfe:d6df with SMTP id w4-20020a170906184400b0077a4bfed6dfmr2732807eje.396.1668701237543; Thu, 17 Nov 2022 08:07:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668701237; cv=none; d=google.com; s=arc-20160816; b=TzzH5kMg8ODSt9yICndsI5O1xxeMDEbztt7uCpj0sNA7vEXwGu2RZc26Q29B/UV/F/ nIaMnATBXaB7El2P457Dm90LFnIQV60RL5Ka89L1LpD+jlZMPb4PjSiXUep7Mr2RoC9t JtvweLiCnByKDrTFPq0w2ZukE6U9nh3wfBK9CbxduuGwF/paw82+Q+4N5P0pDFNmv0RK f9wfaMAMivthfp+nudPBmnnngHB4PKaqAtuiDPZ90OUjADIQSku8BMSWm4piepNfd3rz CtPow5/FihVfnopRJNnOKAd1YtvcJW58L4QXDGLWWbO8fZ4wLMgc/YbRmlyvgjY0O7zN PZog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=glbQ6mTyVBsdL3VI7crUDwjeo2OubidgUdUoWrbTFyk=; b=zqi9DRQGeallC6QMGkc+TESn0tcavKjdaSJiiw3IYT6ZJfd+efJ4n519G6Pux9WowA ifVtDiXVaXr6P2dQiaBRgjGivBAjQxBtSAb4RvWO93vDjaZPTc4sl2IhpRLtMX5qAQ71 8H9recr0nejkuttibekU/yNBCdb9hpGmAopY37WRRMajrMdSKapUXAU+xmlRk6G8L8Ce G4KPihRFs/Cg2dhcfuccZGegGV39RmsLehXKsN2REHh4yxZpljdHyBkzb5WKj7ET78sb cjgxAvWYGpcaFfIYv59X1yyrf1ZN/ikAkK69xxUiPdMV8M/nANTSRk8Tthb4ynU1wYYi aBRQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a50fa84000000b00456dcf56d90si1157020edr.84.2022.11.17.08.06.50; Thu, 17 Nov 2022 08:07:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234917AbiKQQFA (ORCPT + 99 others); Thu, 17 Nov 2022 11:05:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233899AbiKQQE6 (ORCPT ); Thu, 17 Nov 2022 11:04:58 -0500 Received: from smtpout1.mo528.mail-out.ovh.net (smtpout1.mo528.mail-out.ovh.net [46.105.34.251]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05CF345096; Thu, 17 Nov 2022 08:04:56 -0800 (PST) Received: from pro2.mail.ovh.net (unknown [10.109.143.168]) by mo528.mail-out.ovh.net (Postfix) with ESMTPS id E290813CAD67E; Thu, 17 Nov 2022 17:04:54 +0100 (CET) Received: from localhost.localdomain (88.161.25.233) by DAG1EX1.emp2.local (172.16.2.1) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Thu, 17 Nov 2022 17:04:54 +0100 From: Jean-Jacques Hiblot To: , , , , CC: , , , , , , , , Jean-Jacques Hiblot Subject: [PATCH v6 0/6] Add a multicolor LED driver for groups of monochromatic LEDs Date: Thu, 17 Nov 2022 17:04:41 +0100 Message-ID: <20221117160447.294491-1-jjhiblot@traphandler.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [88.161.25.233] X-ClientProxiedBy: DAG1EX1.emp2.local (172.16.2.1) To DAG1EX1.emp2.local (172.16.2.1) X-Ovh-Tracer-Id: 6604247379627555291 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvgedrgeekgdekvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecunecujfgurhephffvvefufffkofgggfgtihesthekredtredttdenucfhrhhomheplfgvrghnqdflrggtqhhuvghsucfjihgslhhothcuoehjjhhhihgslhhothesthhrrghphhgrnhgulhgvrhdrtghomheqnecuggftrfgrthhtvghrnhepjeeuhfeklefghfelhfethfegkedtvedvgfekledtheegueejuedtheekuefhffdtnecukfhppeduvdejrddtrddtrddupdekkedrudeiuddrvdehrddvfeefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeojhhjhhhisghlohhtsehtrhgrphhhrghnughlvghrrdgtohhmqedpnhgspghrtghpthhtohepuddprhgtphhtthhopehlvggvrdhjohhnvghssehlihhnrghrohdrohhrghdpphgrvhgvlhesuhgtfidrtgiipdhrohgshhdoughtsehkvghrnhgvlhdrohhrghdpshhvvghnrdhstghhfigvrhhmvghrseguihhsrhhuphhtihhvvgdqthgvtghhnhholhhoghhivghsrdgtohhmpdhkrhiihihsiihtohhfrdhkohiilhhofihskhhiodgutheslhhinhgrrhhordhorhhgpdhjohhhrghnodhlihhnrghroheskhgvrhhnvghlrdhorhhgpdhmrghrihhjnhdrshhuihhjthgvnhesshhomhgrihhnlh hinhgvrdhorhhgpdgsjhhorhhnrdgrnhguvghrshhsohhnsehlihhnrghrohdrohhrghdprghnugihrdhshhgvvhgthhgvnhhkohesghhmrghilhdrtghomhdpjhgrtggvkhdrrghnrghsiigvfihskhhisehgmhgrihhlrdgtohhmpdhlihhnuhigqdhlvggushesvhhgvghrrdhkvghrnhgvlhdrohhrghdpuggvvhhitggvthhrvggvsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdpoffvtefjohhsthepmhhohedvkedpmhhouggvpehsmhhtphhouhht X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749760068858166203?= X-GMAIL-MSGID: =?utf-8?q?1749760068858166203?= Some HW design implement multicolor LEDs with several monochromatic LEDs. Grouping the monochromatic LEDs allows to configure them in sync and use the triggers. The PWM multicolor LED driver implements such grouping but only for PWM-based LEDs. As this feature is also desirable for the other types of LEDs, this series implements it for any kind of LED device. changes v5->v6: - restore sysfs access to the leds when the device is removed changes v4->v5: - Use "depends on COMPILE_TEST || OF" in Kconfig to indicate that OF is a functional requirement, not just a requirement for the compilation. - in led_mcg_probe() check if devm_of_led_get_optional() returns an error before testing for the end of the list. - use sysfs_emit() instead of sprintf() in color_show(). - some grammar fixes in the comments and the commit logs. changes v2->v3, only minor changes: - rephrased the Kconfig descritpion - make the sysfs interface of underlying LEDs read-only only if the probe is successful. - sanitize the header files - removed the useless call to dev_set_drvdata() - use dev_fwnode() to get the fwnode to the device. changes v1->v2: - Followed Rob Herrings's suggestion to make the dt binding much simpler. - Added a patch to store the color property of a LED in its class structure (struct led_classdev). Jean-Jacques Hiblot (6): devres: provide devm_krealloc_array() leds: class: simplify the implementation of devm_of_led_get() leds: provide devm_of_led_get_optional() leds: class: store the color index in struct led_classdev dt-bindings: leds: Add binding for a multicolor group of LEDs leds: Add a multicolor LED driver to group monochromatic LEDs Documentation/ABI/testing/sysfs-class-led | 9 + .../bindings/leds/leds-group-multicolor.yaml | 64 +++++++ drivers/leds/led-class.c | 65 +++++-- drivers/leds/rgb/Kconfig | 10 ++ drivers/leds/rgb/Makefile | 1 + drivers/leds/rgb/leds-group-multicolor.c | 168 ++++++++++++++++++ include/linux/device.h | 13 ++ include/linux/leds.h | 3 + 8 files changed, 319 insertions(+), 14 deletions(-) create mode 100644 Documentation/devicetree/bindings/leds/leds-group-multicolor.yaml create mode 100644 drivers/leds/rgb/leds-group-multicolor.c