All of lore.kernel.org
 help / color / mirror / Atom feed
From: DonDrews <donovancarldrews@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: pavel@ucw.cz, linux-leds@vger.kernel.org,
	DonDrews <donovancarldrews@gmail.com>
Subject: [PATCH] leds: lp50xx: Fix bank enable mask
Date: Sat, 28 Aug 2021 14:42:53 -0700	[thread overview]
Message-ID: <20210828214253.16207-1-donovancarldrews@gmail.com> (raw)

	Fixes an issue where previously 0 is used as a sentinel when
	moving device tree configuration into the bank enable mask. This
	prevented the first LED from being added to bank control.

Signed-off-by: DonDrews <donovancarldrews@gmail.com>
---
 drivers/leds/leds-lp50xx.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c
index 401df1e2e05d..45f56caea182 100644
--- a/drivers/leds/leds-lp50xx.c
+++ b/drivers/leds/leds-lp50xx.c
@@ -347,17 +347,15 @@ static int lp50xx_brightness_set(struct led_classdev *cdev,
 	return ret;
 }
 
-static int lp50xx_set_banks(struct lp50xx *priv, u32 led_banks[])
+static int lp50xx_set_banks(struct lp50xx *priv, u32 led_banks[], int num_leds)
 {
 	u8 led_config_lo, led_config_hi;
 	u32 bank_enable_mask = 0;
 	int ret;
 	int i;
 
-	for (i = 0; i < priv->chip_info->max_modules; i++) {
-		if (led_banks[i])
-			bank_enable_mask |= (1 << led_banks[i]);
-	}
+	for (i = 0; i < num_leds; i++)
+		bank_enable_mask |= (1 << led_banks[i]);
 
 	led_config_lo = bank_enable_mask;
 	led_config_hi = bank_enable_mask >> 8;
@@ -413,7 +411,7 @@ static int lp50xx_probe_leds(struct fwnode_handle *child, struct lp50xx *priv,
 			return ret;
 		}
 
-		ret = lp50xx_set_banks(priv, led_banks);
+		ret = lp50xx_set_banks(priv, led_banks, num_leds);
 		if (ret) {
 			dev_err(priv->dev, "Cannot setup banked LEDs\n");
 			return ret;
-- 
2.17.1


             reply	other threads:[~2021-08-28 21:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-28 21:42 DonDrews [this message]
     [not found] ` <CAHP10D8mwCb-_dacVDiLTQkr-YzppNAydR76kSG=YP-xZhK0Uw@mail.gmail.com>
2021-09-13  9:16   ` [PATCH] leds: lp50xx: Fix bank enable mask Pavel Machek
2021-09-14  9:16     ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210828214253.16207-1-donovancarldrews@gmail.com \
    --to=donovancarldrews@gmail.com \
    --cc=linux-leds@vger.kernel.org \
    --cc=pavel@ucw.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.