Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp883104lqp; Thu, 21 Mar 2024 20:39:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURQ7tj4sYDsQVLZuFTpyUZn5VioZIj7JTb/C5h4ceccJSbTsySZXval/wnTMgVSKp/ddGO4DDV3V1QNQKWvH69M4mxxfAerFspRELlkw== X-Google-Smtp-Source: AGHT+IHg2nx2s2j6RTjnY4eFCNWHzLbX/UeRGqLuK5fcRRoYiwqHMBmMnvM3COKQMC/KmDktRPiC X-Received: by 2002:a05:6a20:c87:b0:1a3:4d0a:35c0 with SMTP id dt7-20020a056a200c8700b001a34d0a35c0mr1257786pzb.17.1711078794479; Thu, 21 Mar 2024 20:39:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711078794; cv=pass; d=google.com; s=arc-20160816; b=XqYO//UuCi8z56/34dS3EIEoEpKeRglof8YuNZ53TGxZ4rOOonIT3vwKxCS8i3eBbI VJl7dx0W0LWOpLlev7P27//XGuvhPNlhpm3iHy8u98beSWPQZXJEZVG2Nijq6j3LhZ/x 37dz7/MRf5TpZhuVXtxsOmhz4D2uOUgshXhoQcfEkWeY/mitqGiqCLsmiB0kgW6hzgm1 2sDZXzbSpqya1SSdfvIpnYNG7qnL9/X4ahgFGlVeNDJfb6N+6AcbsRlT1Ve2gzpDNQT0 XsOBQUsR52UXWQbkI/1Ng6lfKaxlB396Qva7gWQYCBjOtiYLFxQ0gSA03QstH4Vzo+ap 8BEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:to:from:dkim-signature; bh=aaThFgoqCnVkRdxTondZNkroyy7Kv7fQbcUMkGLhXZA=; fh=OB/tMXumi5iQBhGMKm39if2YoMWkyT+DM6dAWoK4SlY=; b=LbDXiTeIdLHRVLHIlmGQFpiAqd16IImjERip3BMhFjOuqfNCfl4LDNPSUgCuA3+dQv pJKE49xOD/sU1vJukPzFMLSXBI0NWAQleWtQUaX5jGaeLAHADnCYn3FU+ci9qeALLboH XJ4BF/4t45hjJakYFI91+gNZXH5opOi4UHTGsdKYTcTEQljHlkZYbumPfFFONCrqJe6i IBSX39RWAnWNbdv/gRpn2cAFEzViM6RUjPOb2+BkjpMc9GP+/1994b1bkklbt58zxpND ugZV5Q/yIFLKDZRelwI0Aod3us5jKPiVzKRemUtQu1mXxjsOhslD92CrgdFloAB1bAf7 tkkw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CFJj510s; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-110911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110911-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d16-20020a17090ac25000b0029a1aaefe30si1128684pjx.188.2024.03.21.20.39.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 20:39:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CFJj510s; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-110911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110911-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id F00E5B2305A for ; Fri, 22 Mar 2024 03:39:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 21B5A1119B; Fri, 22 Mar 2024 03:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CFJj510s" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB36E10A1D for ; Fri, 22 Mar 2024 03:38:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711078738; cv=none; b=txWrc5t6mrIfOZ6HJI4iT//N8ZFaZ8oH3QZf3NZwTNFoXjSXMnAMUcJVpvwiTGb2YHF5iB/1NiYYuUHavU2KTwiswIIEN7D2mKpR0sOrNJsznPFi4LnLSc9aDsLRKfbjzZsA3s6GUEiluNjXL5cY1E9NKZMLauf/vOTASQgOVDw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711078738; c=relaxed/simple; bh=f5/bJ67Sv0EFeJIOjhY7goPpZbgR8OLgYaO4aKMajrg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=htqXIXa7q688Nwd0gk3FJRBhAIigq5b1cOqVvpRKJQIxIyeSo0VISvAPhEQxw3Y+NZKPlUR16biRUqVkJqMgr2Qo0n/ZWDT429TYjE5rwUzEz6aGjGMxwKkhonTG1bRthiCGbILc2k92eabB+73j2CM8tSOLa90TjwrdFn+8ZCY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CFJj510s; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711078735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aaThFgoqCnVkRdxTondZNkroyy7Kv7fQbcUMkGLhXZA=; b=CFJj510sefSkGmhC1euU1j7Oet5rY+Me7rmDpcNijdPKKM4BNxtFj97eGYsMEh55UCDtYn wWvwgQgbEzkE7XlO+pN/Wmt/8cwv/2NUDP+EeE8s6r0HJP00+4gh3pceEs6CDMVmaX/YJh YqXfUvvfd9jy5s3b3etB84j2bJ4n8lg= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-418-1cFmZtnjPRiM48klTFqeBw-1; Thu, 21 Mar 2024 23:38:49 -0400 X-MC-Unique: 1cFmZtnjPRiM48klTFqeBw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6C8A03C0275F; Fri, 22 Mar 2024 03:38:49 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.39.192.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7CBBC2022C23; Fri, 22 Mar 2024 03:38:44 +0000 (UTC) From: Kate Hsuan To: Pavel Machek , Lee Jones , linux-leds@vger.kernel.org, platform-driver-x86@vger.kernel.org, Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , =?UTF-8?q?Andr=C3=A9=20Apitzsch?= , linux-kernel@vger.kernel.org, Sebastian Reichel , linux-pm@vger.kernel.org Subject: [PATCH v5 4/6] leds: trigger: Add led_mc_trigger_event() function Date: Fri, 22 Mar 2024 11:37:34 +0800 Message-ID: <20240322033736.9344-5-hpa@redhat.com> In-Reply-To: <20240322033736.9344-1-hpa@redhat.com> References: <20240322033736.9344-1-hpa@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 From: Hans de Goede Add a new led_mc_trigger_event() function for triggers which want to change the color of a multi-color LED based on their trigger conditions. Signed-off-by: Hans de Goede --- drivers/leds/led-triggers.c | 20 ++++++++++++++++++++ include/linux/leds.h | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c index bd59a14a4a90..fcc4e7a7b12b 100644 --- a/drivers/leds/led-triggers.c +++ b/drivers/leds/led-triggers.c @@ -380,6 +380,26 @@ void led_trigger_event(struct led_trigger *trig, } EXPORT_SYMBOL_GPL(led_trigger_event); +void led_mc_trigger_event(struct led_trigger *trig, + unsigned int *intensity_value, unsigned int num_colors, + enum led_brightness brightness) +{ + struct led_classdev *led_cdev; + + if (!trig) + return; + + rcu_read_lock(); + list_for_each_entry_rcu(led_cdev, &trig->led_cdevs, trig_list) { + if (!(led_cdev->flags & LED_MULTI_COLOR)) + continue; + + led_mc_set_brightness(led_cdev, intensity_value, num_colors, brightness); + } + rcu_read_unlock(); +} +EXPORT_SYMBOL_GPL(led_mc_trigger_event); + static void led_trigger_blink_setup(struct led_trigger *trig, unsigned long delay_on, unsigned long delay_off, diff --git a/include/linux/leds.h b/include/linux/leds.h index fed88eb9e170..5378e4cd03ff 100644 --- a/include/linux/leds.h +++ b/include/linux/leds.h @@ -526,6 +526,9 @@ void led_trigger_register_simple(const char *name, struct led_trigger **trigger); void led_trigger_unregister_simple(struct led_trigger *trigger); void led_trigger_event(struct led_trigger *trigger, enum led_brightness event); +void led_mc_trigger_event(struct led_trigger *trig, + unsigned int *intensity_value, unsigned int num_colors, + enum led_brightness brightness); void led_trigger_blink(struct led_trigger *trigger, unsigned long delay_on, unsigned long delay_off); void led_trigger_blink_oneshot(struct led_trigger *trigger, @@ -562,6 +565,9 @@ static inline void led_trigger_register_simple(const char *name, static inline void led_trigger_unregister_simple(struct led_trigger *trigger) {} static inline void led_trigger_event(struct led_trigger *trigger, enum led_brightness event) {} +static inline void led_mc_trigger_event(struct led_trigger *trig, + unsigned int *intensity_value, unsigned int num_colors, + enum led_brightness brightness) {} static inline void led_trigger_blink(struct led_trigger *trigger, unsigned long delay_on, unsigned long delay_off) {} -- 2.44.0