From patchwork Tue Mar 28 16:15:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 7354 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2361886vqo; Tue, 28 Mar 2023 09:50:50 -0700 (PDT) X-Google-Smtp-Source: AKy350ZRmot8t1PjHPvTs6j3PHyJlQQ75YWxDC9MVtlLWmJmZTc9XWwhLW0Mug52y7Pny8kMWTyW X-Received: by 2002:aa7:9732:0:b0:5cd:229e:f1d8 with SMTP id k18-20020aa79732000000b005cd229ef1d8mr15405116pfg.4.1680022249816; Tue, 28 Mar 2023 09:50:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680022249; cv=none; d=google.com; s=arc-20160816; b=tuDPrtQ6DkxkiFyw1fjM36dECLNrfyap4fsHq2TEzkuIxG5r/fG5MXqV+RluLEikmW SAK5CPlaJDNfVYb7Y7o3QXMQTsGPK8hnbUg1cXvWIMTs0fI7jr9eC/qHIbK2pHahrTs6 kRkagl+mtl38Z1XDBKRkDiMPY/7whLd9/yq9WAkVlSx9EoQqdjwfHnyMKNz/k0CFdeXY q2FIxWV2Z9gb8qOzd79cXeFDjQMUUQpGeCpCCZDi4KtR2TXg3w+JRFQU9aJ6GCPbwUyT K1IqTfl5pQ1Q4Rzk4GUlWdiByBl2aZ3dJU7jMJoyBaGTstyLrx2sMMcsUTz5rnuJuTpd vmig== 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=Tl8X1ETvGEmUZDGYV62ophAoOOfG0jTJSipkmjsVmCc=; b=B0h2GFfoPVXjWYWVZ+munVdqLjfmyhZywwQ9U4qcae1ElRoyxI86vBiutinfs2dlAr FOxgBX5u/Xdul3waegjOm4N0Vj4VD81LCUikwKMU2g3YyzzPm6CkD4g1/NZavN5LkYlo CIbKWpjjXUsfo9EdJNisfxPY9z47KenWjrCvwqHkzOj+DpaxPUM3iIwgDuO0+cFmB9xo BaAflGLjigfvq5Vs3zk+RowyEeYfYKkvUuWyQ8/vvc20PqlIyt9499UtNHBdX5bfetfp ml7HhIrCVzCIM/fl+KdhwisAiENeiHb8rZUQV7vWZcoGBlAHIybjx2JGcdS0w/2vNvss YQBA== 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 y193-20020a638aca000000b0050be067284bsi18573724pgd.556.2023.03.28.09.50.37; Tue, 28 Mar 2023 09:50:49 -0700 (PDT) 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 S231976AbjC1Qff (ORCPT + 99 others); Tue, 28 Mar 2023 12:35:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229924AbjC1Qfe (ORCPT ); Tue, 28 Mar 2023 12:35:34 -0400 X-Greylist: delayed 1173 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 28 Mar 2023 09:35:31 PDT Received: from 10.mo563.mail-out.ovh.net (10.mo563.mail-out.ovh.net [46.105.78.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5C98AF1C for ; Tue, 28 Mar 2023 09:35:30 -0700 (PDT) Received: from director2.derp.mail-out.ovh.net (director2.derp.mail-out.ovh.net [79.137.60.36]) by mo563.mail-out.ovh.net (Postfix) with ESMTPS id 8397D22B47; Tue, 28 Mar 2023 16:15:54 +0000 (UTC) Received: from director2.derp.mail-out.ovh.net (director2.derp.mail-out.ovh.net. [127.0.0.1]) by director2.derp.mail-out.ovh.net (inspect_sender_mail_agent) with SMTP for ; Tue, 28 Mar 2023 16:15:54 +0000 (UTC) Received: from pro2.mail.ovh.net (unknown [10.109.138.35]) by director2.derp.mail-out.ovh.net (Postfix) with ESMTPS id 597EF1FE77; Tue, 28 Mar 2023 16:15:54 +0000 (UTC) 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.23; Tue, 28 Mar 2023 18:15:53 +0200 From: Jean-Jacques Hiblot To: , , , , CC: , , , , , , , Jean-Jacques Hiblot Subject: [PATCH v8 0/6] Add a multicolor LED driver for groups of monochromatic LEDs Date: Tue, 28 Mar 2023 18:15:35 +0200 Message-ID: <20230328161541.599463-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: DAG8EX1.emp2.local (172.16.2.81) To DAG1EX1.emp2.local (172.16.2.1) X-Ovh-Tracer-Id: 1349391041031453147 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvhedrvdehgedgleekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffoggfgtghisehtkeertdertddtnecuhfhrohhmpeflvggrnhdqlfgrtghquhgvshcujfhisghlohhtuceojhhjhhhisghlohhtsehtrhgrphhhrghnughlvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeejuefhkeelgffhlefhtefhgeektdevvdfgkeeltdehgeeujeeutdehkeeuhffftdenucfkpheptddrtddrtddrtddpkeekrdduiedurddvhedrvdeffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhhtpdhhvghlohepughirhgvtghtohhrvddruggvrhhprdhmrghilhdqohhuthdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepjhhjhhhisghlohhtsehtrhgrphhhrghnughlvghrrdgtohhmpdhnsggprhgtphhtthhopedupdhrtghpthhtoheplhhinhhugidqlhgvughssehvghgvrhdrkhgvrhhnvghlrdhorhhgpdfovfetjfhoshhtpehmohehieef X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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?1761631010498749892?= X-GMAIL-MSGID: =?utf-8?q?1761631010498749892?= 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 v7->v8: - consistently use "LEDs group multicolor" throughout the code. - rename some variables with more explicit names. - improve comments. - use the 100-characters per line limit. changes v6->v7: - in led_mcg_probe() increment the counter at the end of the loop for clarity. 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 | 13 ++ drivers/leds/rgb/Makefile | 1 + drivers/leds/rgb/leds-group-multicolor.c | 164 ++++++++++++++++++ include/linux/device.h | 13 ++ include/linux/leds.h | 3 + 8 files changed, 318 insertions(+), 14 deletions(-) create mode 100644 Documentation/devicetree/bindings/leds/leds-group-multicolor.yaml create mode 100644 drivers/leds/rgb/leds-group-multicolor.c