Message ID | 20240128204740.2355092-1-aren@peacevolution.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-41948-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp218541dyb; Sun, 28 Jan 2024 12:49:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFHBP5aYl2kgpTAJJx1Ioqpip37XyBuTr5F8hDp5UmQpula7fwp9OEgShf+DdZguA4alo6r X-Received: by 2002:a05:620a:1198:b0:783:aae7:3ba6 with SMTP id b24-20020a05620a119800b00783aae73ba6mr5100877qkk.59.1706474951191; Sun, 28 Jan 2024 12:49:11 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706474951; cv=pass; d=google.com; s=arc-20160816; b=UImk1HPlNx4vEk0jh0d3Lv6xaJcjLkM9+ukssPo4Aw8tJfRtPgZOSKqTYvL86075OI mCBPS5XGWY7DFI3z3PFRYvI1VH/gbzXptemZeviEn88fsAJ/ROylOmonbboUiVzWkWA2 G3DEKQZW3ERUp7WLiZjbez1hVTq1vryCfaaVHesjDuwaXOUbEOVM7ZWCTyvBeEORdgBx kKTR2l3UsnHolZisqHrfXSxiZm3ZHH0HWXuT0No6MCH3K+kZYkvFNUlQOjs7e5kX64Rr 0jU7gHEKXfsXwLW15ot3NanABRX/NB8fdos+WV8Ojd1oR0mNFc4X1c2iaricI5JUWxAE yN2g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=dkim-signature:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from; bh=lb0m4VN+fLcRwTMjHhUiN4pOHzBM3BNlNUXpNwfCjmE=; fh=njozN0qru9YNTgJtJOIUDJb6czKSA6JD/2GDjvQI5IY=; b=OsdLuHLOJ5mdSTh2K7AoozXG1XJTdr4g/MfNOZwp08/vBzLeVOKbbZDX5jlbfXQdsr 6g4k3ol59rdYQA0qMu21nk/6bthjeczMUIx6RRglXBnFHrCYUocRhVj1fuisc0my2Gm8 81bmvnmAkjSs+id90F09KQyxxxrnGEd4UFf4MC+P2HqWik/Ev6I+CEvvNGoRIdN3l9fu 6u5d7QdgUDwymshkKF+KOubniymUaJ3EDBOr34q6iEG/r+Ze80Ie+PjrNtEe3aby8Qp4 NCHJEW0jhJHApxrtBusbTu9wIIqGLxEln45ypA3H/rQDqs3QrY0q8Udf0Z8gqGlYsoF6 VLAA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@peacevolution.org header.s=dkim header.b=Q7uXlMIy; arc=pass (i=1 spf=pass spfdomain=peacevolution.org dkim=pass dkdomain=peacevolution.org dmarc=pass fromdomain=peacevolution.org); spf=pass (google.com: domain of linux-kernel+bounces-41948-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41948-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=peacevolution.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id vr3-20020a05620a55a300b00783ab755e57si3670749qkn.429.2024.01.28.12.49.11 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 12:49:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41948-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@peacevolution.org header.s=dkim header.b=Q7uXlMIy; arc=pass (i=1 spf=pass spfdomain=peacevolution.org dkim=pass dkdomain=peacevolution.org dmarc=pass fromdomain=peacevolution.org); spf=pass (google.com: domain of linux-kernel+bounces-41948-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41948-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=peacevolution.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0218C1C2164D for <ouuuleilei@gmail.com>; Sun, 28 Jan 2024 20:49:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 984063C48A; Sun, 28 Jan 2024 20:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b="Q7uXlMIy" Received: from a.peacevolution.org (a.peacevolution.org [206.189.193.133]) (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 7B3BC2E62B; Sun, 28 Jan 2024 20:48:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=206.189.193.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706474925; cv=none; b=pMpOLPp22r9kW7iidKxC+DSDDMKOq5DyfG72a9srPMStad8E/P+bK3Lk6IAxiCwN0sGLR1BnLXezDdrI/o7fwOYitBp0KMFWnu1zFae7T0jwV6xSbCYYMAZWZZkbEbiwRXPbkF8CA+r7kExGgE6ChplFKhxMsicO9dtGTZu0vmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706474925; c=relaxed/simple; bh=DKGeUasBS6xTyhYqe+UExGr24G9PuFPZv+fUiAffDj4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=oWAqEMi8WW6rfSWVRxKzLSIJuuvb+lm69zj7EVEwla80TdItQHq8Zc0tu1bSs8g4RS45rS5jHauSrVdCK+Ft+WJTZkjmVmzhpbOrykVP97Xn96lbD7ck8TTjdJQ8VafEq2WK/lQWX16dLPH4kpsZZluU7/LM9plaezLMWQChNcM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org; spf=pass smtp.mailfrom=peacevolution.org; dkim=pass (1024-bit key) header.d=peacevolution.org header.i=@peacevolution.org header.b=Q7uXlMIy; arc=none smtp.client-ip=206.189.193.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peacevolution.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peacevolution.org Received: from authenticated-user (PRIMARY_HOSTNAME [PUBLIC_IP]) by a.peacevolution.org (Postfix) with ESMTPA id B11E846366; Sun, 28 Jan 2024 20:48:35 +0000 (UTC) From: Aren Moynihan <aren@peacevolution.org> To: linux-kernel@vger.kernel.org Cc: Miles Alan <m@milesalan.com>, Ondrej Jirman <megi@xff.cz>, Aren Moynihan <aren@peacevolution.org>, Jean-Jacques Hiblot <jjhiblot@traphandler.com>, Lee Jones <lee@kernel.org>, Pavel Machek <pavel@ucw.cz>, linux-leds@vger.kernel.org Subject: [PATCH 1/4] leds: rgb: leds-group-multicolor: allow leds to stay on in suspend Date: Sun, 28 Jan 2024 15:45:07 -0500 Message-ID: <20240128204740.2355092-1-aren@peacevolution.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: auth=pass smtp.auth=aren@peacevolution.org smtp.mailfrom=aren@peacevolution.org X-Spam-Level: **** X-Spamd-Bar: ++++ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peacevolution.org; s=dkim; t=1706474916; h=from:subject:date:message-id:to:cc:mime-version:content-transfer-encoding; bh=lb0m4VN+fLcRwTMjHhUiN4pOHzBM3BNlNUXpNwfCjmE=; b=Q7uXlMIygUiuEL02z/PKkAuY3qqvE7csYD6Ap3VSRKMhAcg9XvsTxqUCfzt1iXgwsFM/dA OjBDHPlh47mATnlAVVPe8P9+k/GJS+gEBeeDeytbBimKfDq+phqSniMkY4TWN7GlpCfmcI uWHqkBDSAjOl2f0CL/XYL7DgnPb4WCk= X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789368678643639358 X-GMAIL-MSGID: 1789368678643639358 |
Series |
[1/4] leds: rgb: leds-group-multicolor: allow leds to stay on in suspend
|
|
Commit Message
Aren
Jan. 28, 2024, 8:45 p.m. UTC
If none of the managed leds enable LED_CORE_SUSPENDRESUME, then we
shouldn't need to set it here. This makes it possible to use multicolor
groups with gpio leds that enable retain-state-suspended in the device
tree.
Signed-off-by: Aren Moynihan <aren@peacevolution.org>
---
drivers/leds/rgb/leds-group-multicolor.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Comments
On 28/01/2024 21:45, Aren Moynihan wrote: > If none of the managed leds enable LED_CORE_SUSPENDRESUME, then we > shouldn't need to set it here. This makes it possible to use multicolor > groups with gpio leds that enable retain-state-suspended in the device > tree. > > Signed-off-by: Aren Moynihan <aren@peacevolution.org> > --- > > drivers/leds/rgb/leds-group-multicolor.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/leds/rgb/leds-group-multicolor.c b/drivers/leds/rgb/leds-group-multicolor.c > index 39f58be32af5..194c6a33640b 100644 > --- a/drivers/leds/rgb/leds-group-multicolor.c > +++ b/drivers/leds/rgb/leds-group-multicolor.c > @@ -69,7 +69,7 @@ static int leds_gmc_probe(struct platform_device *pdev) > struct mc_subled *subled; > struct leds_multicolor *priv; > unsigned int max_brightness = 0; > - int i, ret, count = 0; > + int i, ret, count, common_flags = 0; count is not initialized anymore. Isn't it a problem ? > > priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > if (!priv) > @@ -91,6 +91,7 @@ static int leds_gmc_probe(struct platform_device *pdev) > if (!priv->monochromatics) > return -ENOMEM; > > + common_flags |= led_cdev->flags; > priv->monochromatics[count] = led_cdev; > > max_brightness = max(max_brightness, led_cdev->max_brightness); > @@ -114,12 +115,15 @@ static int leds_gmc_probe(struct platform_device *pdev) > > /* Initialise the multicolor's LED class device */ > cdev = &priv->mc_cdev.led_cdev; > - cdev->flags = LED_CORE_SUSPENDRESUME; > cdev->brightness_set_blocking = leds_gmc_set; > cdev->max_brightness = max_brightness; > cdev->color = LED_COLOR_ID_MULTI; > priv->mc_cdev.num_colors = count; > > + /* we only need suspend/resume if a sub-led requests it */ > + if (common_flags & LED_CORE_SUSPENDRESUME) > + cdev->flags = LED_CORE_SUSPENDRESUME; > + > init_data.fwnode = dev_fwnode(dev); > ret = devm_led_classdev_multicolor_register_ext(dev, &priv->mc_cdev, &init_data); > if (ret)
On Wed, Jan 31, 2024 at 08:39:01AM +0100, Jean-Jacques Hiblot wrote: > > > On 28/01/2024 21:45, Aren Moynihan wrote: > > If none of the managed leds enable LED_CORE_SUSPENDRESUME, then we > > shouldn't need to set it here. This makes it possible to use multicolor > > groups with gpio leds that enable retain-state-suspended in the device > > tree. > > > > Signed-off-by: Aren Moynihan <aren@peacevolution.org> > > --- > > > > drivers/leds/rgb/leds-group-multicolor.c | 8 ++++++-- > > 1 file changed, 6 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/leds/rgb/leds-group-multicolor.c b/drivers/leds/rgb/leds-group-multicolor.c > > index 39f58be32af5..194c6a33640b 100644 > > --- a/drivers/leds/rgb/leds-group-multicolor.c > > +++ b/drivers/leds/rgb/leds-group-multicolor.c > > @@ -69,7 +69,7 @@ static int leds_gmc_probe(struct platform_device *pdev) > > struct mc_subled *subled; > > struct leds_multicolor *priv; > > unsigned int max_brightness = 0; > > - int i, ret, count = 0; > > + int i, ret, count, common_flags = 0; > > count is not initialized anymore. Isn't it a problem ? Yes, good catch, thanks! I'm not sure how I missed that when I tested this, I must've gotten (un)lucky with the value that was in ram before. - Aren > > priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); > > if (!priv) > > @@ -91,6 +91,7 @@ static int leds_gmc_probe(struct platform_device *pdev) > > if (!priv->monochromatics) > > return -ENOMEM; > > + common_flags |= led_cdev->flags; > > priv->monochromatics[count] = led_cdev; > > max_brightness = max(max_brightness, led_cdev->max_brightness); > > @@ -114,12 +115,15 @@ static int leds_gmc_probe(struct platform_device *pdev) > > /* Initialise the multicolor's LED class device */ > > cdev = &priv->mc_cdev.led_cdev; > > - cdev->flags = LED_CORE_SUSPENDRESUME; > > cdev->brightness_set_blocking = leds_gmc_set; > > cdev->max_brightness = max_brightness; > > cdev->color = LED_COLOR_ID_MULTI; > > priv->mc_cdev.num_colors = count; > > + /* we only need suspend/resume if a sub-led requests it */ > > + if (common_flags & LED_CORE_SUSPENDRESUME) > > + cdev->flags = LED_CORE_SUSPENDRESUME; > > + > > init_data.fwnode = dev_fwnode(dev); > > ret = devm_led_classdev_multicolor_register_ext(dev, &priv->mc_cdev, &init_data); > > if (ret)
diff --git a/drivers/leds/rgb/leds-group-multicolor.c b/drivers/leds/rgb/leds-group-multicolor.c index 39f58be32af5..194c6a33640b 100644 --- a/drivers/leds/rgb/leds-group-multicolor.c +++ b/drivers/leds/rgb/leds-group-multicolor.c @@ -69,7 +69,7 @@ static int leds_gmc_probe(struct platform_device *pdev) struct mc_subled *subled; struct leds_multicolor *priv; unsigned int max_brightness = 0; - int i, ret, count = 0; + int i, ret, count, common_flags = 0; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -91,6 +91,7 @@ static int leds_gmc_probe(struct platform_device *pdev) if (!priv->monochromatics) return -ENOMEM; + common_flags |= led_cdev->flags; priv->monochromatics[count] = led_cdev; max_brightness = max(max_brightness, led_cdev->max_brightness); @@ -114,12 +115,15 @@ static int leds_gmc_probe(struct platform_device *pdev) /* Initialise the multicolor's LED class device */ cdev = &priv->mc_cdev.led_cdev; - cdev->flags = LED_CORE_SUSPENDRESUME; cdev->brightness_set_blocking = leds_gmc_set; cdev->max_brightness = max_brightness; cdev->color = LED_COLOR_ID_MULTI; priv->mc_cdev.num_colors = count; + /* we only need suspend/resume if a sub-led requests it */ + if (common_flags & LED_CORE_SUSPENDRESUME) + cdev->flags = LED_CORE_SUSPENDRESUME; + init_data.fwnode = dev_fwnode(dev); ret = devm_led_classdev_multicolor_register_ext(dev, &priv->mc_cdev, &init_data); if (ret)