Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp101341rwb; Sat, 17 Sep 2022 01:31:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4+dehLf8PCDQ2+ZJuBs/47sNeqQqYrZs1qatPZQLB6eD7zIzyoIr6Z9a08XzXGhvUILWJ0 X-Received: by 2002:a17:906:5d11:b0:780:bf2d:6d14 with SMTP id g17-20020a1709065d1100b00780bf2d6d14mr3271897ejt.543.1663403514408; Sat, 17 Sep 2022 01:31:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663403514; cv=none; d=google.com; s=arc-20160816; b=y2rv1ViL368gSBptw/iIn2pJbP/PAJorGOB4F2M0uw/6TwqjxBEZVae6st5BxqrJfW T54Yct8X9CVKVXmSs3Lamre5ghS63b8H2FSVTRBz1D/a3SDChlDVW/6vej1SjK+eIK3N J37DiRDr2O0z5eAsPWFuU6LM4xmYyCeYkTC8Xok20JY124a40ygTiwabOeAxrMBm6ziD UvVxiOW1+LXgHVOaFoH1MKPZTcp3L53Fu03GuY9mGureWlevW/7+Ry9CrUG0OvliNIGt D0gvLbnBi+dJCrNYzsjv7maO0TmdlAG/5cxfbOoX+vrY5Qv0eKYr6E6FUUSXYWxk1e3V JiZg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Dowwebf4PMhFb1sC9wmTHQOkcEEsSSVaxGpMtV8EHFA=; b=Fo+PWxt2RYUILuGwoeodX+yax0o3f5eXS0LyS8OY+JnHAS66oJhTLIVlCduqUNsGPU BeJxPD6yGXFyT8lAyobdn5KQ0s3+FCFi/NybcetMKGDJCs10JCQnopx9qX6W8HZRB/qJ 880G/oKKtR7O3IJST4ZrP7EXYIDR/t3pXV+FTPVQfyo7SQ0BUtXwSNggEnlQcaCP5X8C QcPClBivde38qcNq2LQF//+VJCFQ12k41w1DrfdlML2jNARIBtGdKAuasTWXVmv08j/d /YuQTZ/zcyq5GS1UNA4knx9DRqwTgcg0xp9K8+CTrmNtShRErgvMvvzhbcWk4YkggD89 GJ7Q== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xg14-20020a170907320e00b007809c50fd78si4957460ejb.262.2022.09.17.01.31.27; Sat, 17 Sep 2022 01:31:54 -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 S229703AbiIQIOT (ORCPT + 99 others); Sat, 17 Sep 2022 04:14:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229568AbiIQIOR (ORCPT ); Sat, 17 Sep 2022 04:14:17 -0400 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 93DE63ECFC; Sat, 17 Sep 2022 01:14:15 -0700 (PDT) Received: from pro2.mail.ovh.net (unknown [10.109.156.240]) by mo528.mail-out.ovh.net (Postfix) with ESMTPS id D3FE1128726F3; Sat, 17 Sep 2022 10:13:55 +0200 (CEST) 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.12; Sat, 17 Sep 2022 10:13:55 +0200 From: Jean-Jacques Hiblot To: , , , CC: , , , , , , , , Jean-Jacques Hiblot Subject: [RESEND PATCH v3 2/4] leds: class: store the color index in struct led_classdev Date: Sat, 17 Sep 2022 10:13:37 +0200 Message-ID: <20220917081339.3354075-3-jjhiblot@traphandler.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220917081339.3354075-1-jjhiblot@traphandler.com> References: <20220917081339.3354075-1-jjhiblot@traphandler.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [88.161.25.233] X-ClientProxiedBy: DAG1EX2.emp2.local (172.16.2.2) To DAG1EX1.emp2.local (172.16.2.1) X-Ovh-Tracer-Id: 9350317254946535703 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrfedvvddgtddvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgtghisehtkeertdertddtnecuhfhrohhmpeflvggrnhdqlfgrtghquhgvshcujfhisghlohhtuceojhhjhhhisghlohhtsehtrhgrphhhrghnughlvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeduteevleevvefggfdvueffffejhfehheeuiedtgedtjeeghfehueduudegfeefueenucfkpheptddrtddrtddrtddpkeekrdduiedurddvhedrvdeffeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhhouggvpehsmhhtphhouhhtpdhhvghlohepphhrohdvrdhmrghilhdrohhvhhdrnhgvthdpihhnvghtpedtrddtrddtrddtpdhmrghilhhfrhhomhepjhhjhhhisghlohhtsehtrhgrphhhrghnughlvghrrdgtohhmpdhnsggprhgtphhtthhopedupdhrtghpthhtohepshhhrgesphgvnhhguhhtrhhonhhigidruggvpdfovfetjfhoshhtpehmohehvdek X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 This information might be useful for more than only deriving the led's name. Signed-off-by: Jean-Jacques Hiblot --- drivers/leds/led-class.c | 7 +++++++ include/linux/leds.h | 1 + 2 files changed, 8 insertions(+) diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c index 2c0d979d0c8a..537379f09801 100644 --- a/drivers/leds/led-class.c +++ b/drivers/leds/led-class.c @@ -350,6 +350,10 @@ int led_classdev_register_ext(struct device *parent, if (fwnode_property_present(init_data->fwnode, "retain-state-shutdown")) led_cdev->flags |= LED_RETAIN_AT_SHUTDOWN; + + if (fwnode_property_present(init_data->fwnode, "color")) + fwnode_property_read_u32(init_data->fwnode, "color", + &led_cdev->color); } } else { proposed_name = led_cdev->name; @@ -359,6 +363,9 @@ int led_classdev_register_ext(struct device *parent, if (ret < 0) return ret; + if (led_cdev->color >= LED_COLOR_ID_MAX) + dev_warn(parent, "LED %s color identifier out of range\n", final_name); + mutex_init(&led_cdev->led_access); mutex_lock(&led_cdev->led_access); led_cdev->dev = device_create_with_groups(leds_class, parent, 0, diff --git a/include/linux/leds.h b/include/linux/leds.h index ba4861ec73d3..fe6346604e36 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -71,6 +71,7 @@ struct led_classdev { const char *name; unsigned int brightness; unsigned int max_brightness; + unsigned int color; int flags; /* Lower 16 bits reflect status */ -- 2.25.1