Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3913952pxb; Mon, 4 Oct 2021 12:30:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCJO7MmRLeVN6q6MFODNB1fyamJTfbMJ3PjrPIZyJQq4LsTREm3n0MrZnnBq/CZGaYtoUj X-Received: by 2002:a17:902:7d8c:b0:13d:e593:cdf3 with SMTP id a12-20020a1709027d8c00b0013de593cdf3mr1320791plm.28.1633375817516; Mon, 04 Oct 2021 12:30:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633375817; cv=none; d=google.com; s=arc-20160816; b=Rhzbo7Srf/XrnTOj4n5V7PzKHUwMG2tqyGFWmgjLAzr4Sj9Lm1QqgPtXGqRJiDena6 S1diJh+kXW1zDzmBAjiEJlJRxiX5V9xKX+glxzecoOTrQcmegiLdQUXnUADDjB7+LqdJ leDXcuh8hnkKqg5/TEZDYoU+w6Em1JFg3YNXqp0J16gz68MN1rrOFPbZQHNFxipLqPPE TQErvf6TK/KHRdGkKDbLHVTzP1BHnvc/XKLADr0w+/cZL3VGj35qtQYuW7GP8CKHuN4h 474Xaq/MQTNdXdlVRCrDwh7NBGa+beBpI6X/pVXTfsRh6aKYuVAJscH0AqGCNgjMqC34 Bbog== 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=D8GR2czZUPRAVcmMr/p0Y/jlSfTC+76YDkoratoF6Dk=; b=Dc8C2zxmjqlVCrKDvjPut3bBbKJ4BZ5KXIZ+1KqubmdmLJP7mbAaQbdaNN6D4/rSmc qo7ruhhobZG3g8+eHnBQ1Bgw1xSYNV78p5dNOHeEwGSYsoUt1l4NcrvprrCriYhtavYq CxMRgvCBNFVnvn85ihwvf/J/a3PrF9NYjHT9bGj4xjKEEfkO7W7mftLvTkNADoYd/xmd //rYkx48AALXD5f7CyaTrNAoBFOlD7HuqFV4R3BU0CHeET5vI+oONlwdM2GOw8HTC+Wm EXd4ApB7zNqbZURq8UyXeQIPwtPxn07oaP/GWX6Zs4HPHAL2aLGdM6eMJiNHHj8C9tzc mscA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h3si18947674plo.334.2021.10.04.12.30.03; Mon, 04 Oct 2021 12:30:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239138AbhJDT3y (ORCPT + 99 others); Mon, 4 Oct 2021 15:29:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239042AbhJDT3n (ORCPT ); Mon, 4 Oct 2021 15:29:43 -0400 Received: from relay01.th.seeweb.it (relay01.th.seeweb.it [IPv6:2001:4b7a:2000:18::162]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32CD8C061753; Mon, 4 Oct 2021 12:27:53 -0700 (PDT) Received: from Marijn-Arch-PC.localdomain (94-209-165-62.cable.dynamic.v4.ziggo.nl [94.209.165.62]) (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 m-r1.th.seeweb.it (Postfix) with ESMTPSA id 24F5B1F6D5; Mon, 4 Oct 2021 21:27:51 +0200 (CEST) From: Marijn Suijten To: phone-devel@vger.kernel.org, Andy Gross , Bjorn Andersson , Lee Jones , Daniel Thompson , Jingoo Han Cc: ~postmarketos/upstreaming@lists.sr.ht, AngeloGioacchino Del Regno , Konrad Dybcio , Martin Botka , Jami Kettunen , Pavel Dubrova , Marijn Suijten , Kiran Gunda , Courtney Cavin , Bryan Wu , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/10] backlight: qcom-wled: Consistently use enabled-strings in set_brightness Date: Mon, 4 Oct 2021 21:27:40 +0200 Message-Id: <20211004192741.621870-10-marijn.suijten@somainline.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211004192741.621870-1-marijn.suijten@somainline.org> References: <20211004192741.621870-1-marijn.suijten@somainline.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The hardware is capable of controlling any non-contiguous sequence of LEDs specified in the DT using qcom,enabled-strings as u32 array, and this also follows from the DT-bindings documentation. The numbers specified in this array represent indices of the LED strings that are to be enabled and disabled. Its value is appropriately used to setup and enable string modules, but completely disregarded in the set_brightness paths which only iterate over the number of strings linearly. Take an example where only string 2 is enabled with qcom,enabled_strings=<2>: this string is appropriately enabled but subsequent brightness changes would have only touched the zero'th brightness register because num_strings is 1 here. This is simply addressed by looking up the string for this index in the enabled_strings array just like the other codepaths that iterate over num_strings. Fixes: 775d2ffb4af6 ("backlight: qcom-wled: Restructure the driver for WLED3") Fixes: 03b2b5e86986 ("backlight: qcom-wled: Add support for WLED4 peripheral") Signed-off-by: Marijn Suijten Reviewed-by: AngeloGioacchino Del Regno --- drivers/video/backlight/qcom-wled.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/backlight/qcom-wled.c b/drivers/video/backlight/qcom-wled.c index dbe503007ada..c0b8d10c20a2 100644 --- a/drivers/video/backlight/qcom-wled.c +++ b/drivers/video/backlight/qcom-wled.c @@ -237,7 +237,7 @@ static int wled3_set_brightness(struct wled *wled, u16 brightness) for (i = 0; i < wled->cfg.num_strings; ++i) { rc = regmap_bulk_write(wled->regmap, wled->ctrl_addr + - WLED3_SINK_REG_BRIGHT(i), + WLED3_SINK_REG_BRIGHT(wled->cfg.enabled_strings[i]), &v, sizeof(v)); if (rc < 0) return rc; @@ -259,7 +259,7 @@ static int wled4_set_brightness(struct wled *wled, u16 brightness) for (i = 0; i < wled->cfg.num_strings; ++i) { rc = regmap_bulk_write(wled->regmap, wled->sink_addr + - WLED4_SINK_REG_BRIGHT(i), + WLED4_SINK_REG_BRIGHT(wled->cfg.enabled_strings[i]), &v, sizeof(v)); if (rc < 0) return rc; -- 2.33.0