Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1390019imm; Fri, 22 Jun 2018 16:07:40 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK/KPvLHOQAidLmJIq31H9h4NfkmbYtzi5kKqRRt+CxIiPWluFNDp9RyOF0tc8iTSWYCD9X X-Received: by 2002:a65:62d9:: with SMTP id m25-v6mr2944145pgv.371.1529708860808; Fri, 22 Jun 2018 16:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529708860; cv=none; d=google.com; s=arc-20160816; b=V9XnYZjyZFGPNzhO5gVPQPFILk8mzI1BvZDSL27TGAq2xgKBZwXnh1bUL1nMSIyVls lWumy/YNVbnD5Mb1OmS1NMpJ89kyrypzYas+vdfNTjANiyElvFgFJ0dGbM+4uGH+Cl2y 4IIRFUxvmO3fT3b1V7qz5PJ3GwTgZGcsGIeYFajO7bMGNiQf0SgAbkN43pjyDinLGkTL Opu6wNmxxsMBUxljOOMce4wGrvjEcy+vgLpHqYijREcQ+oVEU0gWdBMCIT1tKuOhahxq 1dfRk6OOphGAQATNHRv4RzsWxZ3pD4AXpVHbWEGtrcIrBasr+ZbJu9VPzxpbTkfyNsrH tSvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=hNzkmK1RwyRCBhRgYtHgfx4SairokWbaH1n7UcW7kr8=; b=A5MmvobwoFc8qI3Hs+LlG8EfybPkGHqKGDvVrjAgI2R8ebU9TG55EZZZoEJdRt2dzt 3yWw1pA8+nJfWVwkoSGZZ54YCrk4oLBxVXkoB1t5+DhuO8ipclj/VpIgrNjbK1IKOb+a 95FU7w3tJSvx/vzt5iVXx8SVyg5FTf/krUi0RyoehEiDn42cUYBUpLUnCeiVDE+VUL0/ 3b3tThm82jpo+m6uCb0yIjZ/Jf7+QuTsWOJOkE2G1a4Akm8by3I2d6YPpFeJ+NfeLqJO p4M3sWygFkB0O4EzHBiB2vep+y5E92KH4W3hWwEKz3Ma8/Ir2nWhGBKyWX+unHX3YldC lQJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bO2LcwT3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t20-v6si3533453ply.146.2018.06.22.16.07.26; Fri, 22 Jun 2018 16:07:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bO2LcwT3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754683AbeFVXGq (ORCPT + 99 others); Fri, 22 Jun 2018 19:06:46 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:40387 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754580AbeFVXGo (ORCPT ); Fri, 22 Jun 2018 19:06:44 -0400 Received: by mail-pl0-f66.google.com with SMTP id t12-v6so4131594plo.7 for ; Fri, 22 Jun 2018 16:06:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=hNzkmK1RwyRCBhRgYtHgfx4SairokWbaH1n7UcW7kr8=; b=bO2LcwT3l91DmUc//6x9pXWugBqEXfhUHty4CnKIZ7BCvVca5v0LYWr6Yke5A62yqM ELgnvBvaL2MVNXDkNlDlvFkQlGJ1hPYsaX82XA/wIp8TBJuGEYhDqYY1yRnDardx/43V SL6YuzXwLHgc2GNTD2lezcb+FZpcxWl9GjYFk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=hNzkmK1RwyRCBhRgYtHgfx4SairokWbaH1n7UcW7kr8=; b=aLdF58dkcXUThHn/R1ei89tMmTfAKgcWodD49uA/zbfOB8I51ANcGUVZkfv5G5hlOu eVFS4PTdPlxHQ8ZjW3KgqQ56twhjr6UmqICLMiEFf1ZmZrji4vZT1bXTtY1a1kV7Ni+M xJpZXmElnM0deKYkCvgwoBr3JcB8l+pN0hMyBiZ9E90GXbckZdc4g0CcOrT2HZB7lvvl ++8WdTIQdlkq0UsT+2c5Fo84e97zJNBo4dwA6Z7bzUlB49/h2PIhSe+GE9Soc0+lwa7a NQ8KhWz6pKtQ6lMjh79pZ0vbQZlHE2dq7KzV/xfE62YDy/xwBviEM5TMro7yb+GrdBfX bi8A== X-Gm-Message-State: APt69E1QRinVKmK8xyszX2JZimTBOdE1wMHldSSNcsPXGpqO6UKJFuce cDkjB0N8T2g42NgpurkF8iUpnw== X-Received: by 2002:a17:902:850b:: with SMTP id bj11-v6mr3406281plb.210.1529708803675; Fri, 22 Jun 2018 16:06:43 -0700 (PDT) Received: from tuxbook-pro (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id t5-v6sm12677577pfh.32.2018.06.22.16.06.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 22 Jun 2018 16:06:42 -0700 (PDT) Date: Fri, 22 Jun 2018 16:09:03 -0700 From: Bjorn Andersson To: kgunda@codeaurora.org Cc: jingoohan1@gmail.com, lee.jones@linaro.org, b.zolnierkie@samsung.com, dri-devel@lists.freedesktop.org, Daniel Thompson , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-leds@vger.kernel.org, linux-arm-msm-owner@vger.kernel.org Subject: Re: [PATCH V3 5/7] backlight: qcom-wled: Add support for WLED4 peripheral Message-ID: <20180622230903.GM3402@tuxbook-pro> References: <1529406822-15379-1-git-send-email-kgunda@codeaurora.org> <1529406822-15379-6-git-send-email-kgunda@codeaurora.org> <20180620051417.GI15126@tuxbook-pro> <27aa7ff8f7e0cd8fdca5d3ee17bb1ef4@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <27aa7ff8f7e0cd8fdca5d3ee17bb1ef4@codeaurora.org> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 20 Jun 04:00 PDT 2018, kgunda@codeaurora.org wrote: > On 2018-06-20 10:44, Bjorn Andersson wrote: > > On Tue 19 Jun 04:13 PDT 2018, Kiran Gunda wrote: > > > > > WLED4 peripheral is present on some PMICs like pmi8998 and > > > pm660l. It has a different register map and configurations > > > are also different. Add support for it. > > > > > > Signed-off-by: Kiran Gunda > > > --- > > > drivers/video/backlight/qcom-wled.c | 635 > > > ++++++++++++++++++++++++++++-------- > > > 1 file changed, 503 insertions(+), 132 deletions(-) > > > > Split this further into a patch that does structural preparation of > > WLED3 support and then an addition of WLED4, the mixture makes parts of > > this patch almost impossible to review. Please find some comments below. > > > Sure. I will split it in the next series. Thanks! > > > > > > diff --git a/drivers/video/backlight/qcom-wled.c > > > b/drivers/video/backlight/qcom-wled.c > > [..] > > > > > > /* WLED3 sink registers */ > > > #define WLED3_SINK_REG_SYNC 0x47 > > > > Drop the 3 from this if it's common between the two. > > > > > -#define WLED3_SINK_REG_SYNC_MASK 0x07 > > > +#define WLED3_SINK_REG_SYNC_MASK GENMASK(2, 0) > > > +#define WLED4_SINK_REG_SYNC_MASK GENMASK(3, 0) > > > #define WLED3_SINK_REG_SYNC_LED1 BIT(0) > > > #define WLED3_SINK_REG_SYNC_LED2 BIT(1) > > > #define WLED3_SINK_REG_SYNC_LED3 BIT(2) > > > +#define WLED4_SINK_REG_SYNC_LED4 BIT(3) > > > #define WLED3_SINK_REG_SYNC_ALL 0x07 > > > +#define WLED4_SINK_REG_SYNC_ALL 0x0f > > > #define WLED3_SINK_REG_SYNC_CLEAR 0x00 > > > > > [..] > > > +static int wled4_set_brightness(struct wled *wled, u16 brightness) > > > > Afaict this is identical to wled3_set_brightness() with the exception > > that there's a minimum brightness and the base address for the > > brightness registers are different. > > > > I would suggest that you add a min_brightness to wled and that you > > figure out a way to carry the brightness base register address; and by > > that you squash these two functions. > > > There are four different parameters. 1) minimum brightness 2) WLED base > addresses > 3) Brightness base addresses 4) the brightness sink registers address > offsets also > different for wled 3 and wled4. (in wled3 0x40, 0x42, 0x44, where as in > wled4 0x57, 0x67, 0x77, 0x87). > Sorry, I must have gotten lost in the defines, I see the difference between the two register layouts now. If you retain the old mechanism of doing the math openly in the function this would have been obvious. > Irrelevant to this patch, but wled5 has some more extra registers to > set the brightness. Keeping this in mind, it is better to have > separate functions? Otherwise we will have to use the version checks > in the wled_set_brightness function, if we have the common function. Okay, so it sounds reasonable to split this out to some degree. Regards, Bjorn