Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2149765ybh; Sun, 8 Mar 2020 23:29:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt9kkPG6jfjtvDKM/iogLoSCpU3r1Nre3RXabdH9Rp9xr65YuFTQIj5gBZh5T7EFqjxWFNX X-Received: by 2002:a54:4e8d:: with SMTP id c13mr10351851oiy.27.1583735374931; Sun, 08 Mar 2020 23:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583735374; cv=none; d=google.com; s=arc-20160816; b=OzdlJkHlPPkk30W0UKFTHgkmo7vtU7a+xxNeIk2DMew0+lK0rTJ8axchepusEUvm+T bZS6QZYbEVRhaGIKV65MC8sz0R92OOg1H9+9Se68/06SYfe1PFBY9RTOZhw8+NTIQeSU lyLiX7Cj74ebyNzTnHv8L4oEZ6YKC4Ix0XOFaepPVeU7NCTZlp5OusaAIq2tounthrh+ NWro88an7PEBu5UvKbp5f+0q+T87Y3/eePKXv1jA6ViEy+wq2SFJkECz+3gsQgJZGeNV riCO0LXD8NQxya2YOuy86y0KT4sbKPtM2211NoI3U7ye8A/0rfBgUjnCbzVtsoNEAiqL fvoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=qy2xY/dZyMiOpfQufKuG+wtf2moSQrlU/AD39JqMigc=; b=CxC5o1FK/5WOwWKbjmnfFhPd+zVPeA8i4BFGh4LYubxlyBQgczzQJu/teHxAaBwOMD BMscNl7TiyQLTj2y5xTC9rQFw0eR/flri/wCmbozf6Vz87yeKyed9CXzwq00l6S3dR9O GhZsruPkIbli3KPTCvzFrRUnnr2ulhIWZ+48DZGaVWuwVKT9nTOeXpjVrFNih+FfzeOd zmcsPxneOu9LdcFiGdKmzO1r7kznYbbFzUQ8cHBpt+O5UtXYgV0PdphfzUahdxo1apWW 7jjDIMRy6e0CfWh4BgaxuIwFKHZsF9IVkhf3ZFgng5NS112jFt391CHmcNsbK42ixP7h pQlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=tcvkwFkf; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i1si3718850oiy.42.2020.03.08.23.29.23; Sun, 08 Mar 2020 23:29:34 -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=fail header.i=@mg.codeaurora.org header.s=smtp header.b=tcvkwFkf; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726463AbgCIG2F (ORCPT + 99 others); Mon, 9 Mar 2020 02:28:05 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:47684 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726071AbgCIG2F (ORCPT ); Mon, 9 Mar 2020 02:28:05 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1583735284; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=qy2xY/dZyMiOpfQufKuG+wtf2moSQrlU/AD39JqMigc=; b=tcvkwFkfnLNgGWAL7+JjvbUqGZoNbBSaRs8wNhQaND710vNnpGe9GBfsdHoTlA6kij3Optjq yFiTbtIONQb9doQAfab8LB+QxVAXBxNdzkZj9tEuQ1CuEiaqB4ljWv4clzaZeFbgCnIaZUIv 6K+RfYY9OR9S0Xvt9+8yElYQES4= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e65e1e6.7efdb514f340-smtp-out-n03; Mon, 09 Mar 2020 06:27:50 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 930BDC433BA; Mon, 9 Mar 2020 06:27:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: kgunda) by smtp.codeaurora.org (Postfix) with ESMTPSA id E94B8C433D2; Mon, 9 Mar 2020 06:27:48 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 09 Mar 2020 11:57:48 +0530 From: kgunda@codeaurora.org To: Bjorn Andersson Cc: jingoohan1@gmail.com, lee.jones@linaro.org, b.zolnierkie@samsung.com, dri-devel@lists.freedesktop.org, daniel.thompson@linaro.org, jacek.anaszewski@gmail.com, pavel@ucw.cz, robh+dt@kernel.org, mark.rutland@arm.com, linux-leds@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Dan Murphy , Andy Gross , linux-arm-msm@vger.kernel.org, linux-fbdev@vger.kernel.org, linux-arm-msm-owner@vger.kernel.org Subject: Re: [PATCH V1 2/2] backlight: qcom-wled: Add support for WLED5 peripheral in PM8150L In-Reply-To: <20200308214748.GL1094083@builder> References: <1583153739-19170-1-git-send-email-kgunda@codeaurora.org> <1583153739-19170-3-git-send-email-kgunda@codeaurora.org> <20200308214748.GL1094083@builder> Message-ID: X-Sender: kgunda@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-03-09 03:17, Bjorn Andersson wrote: > On Mon 02 Mar 04:55 PST 2020, Kiran Gunda wrote: >> diff --git a/drivers/video/backlight/qcom-wled.c >> b/drivers/video/backlight/qcom-wled.c > [..] >> @@ -147,14 +187,39 @@ struct wled { >> u32 max_brightness; >> u32 short_count; >> u32 auto_detect_count; >> + u32 version; >> bool disabled_by_short; >> bool has_short_detect; >> + bool cabc_disabled; >> int short_irq; >> int ovp_irq; >> >> struct wled_config cfg; >> struct delayed_work ovp_work; >> int (*wled_set_brightness)(struct wled *wled, u16 brightness); >> + int (*cabc_config)(struct wled *wled, bool enable); >> + int (*wled_sync_toggle)(struct wled *wled); > > Please split this patch in one that adds these and breaks out the wled3 > support, and then a second patch that adds wled5. > Sure. Will make this change in the next post. >> +}; >> + > [..] >> +static int wled5_set_brightness(struct wled *wled, u16 brightness) >> +{ >> + int rc, offset; >> + u16 low_limit = wled->max_brightness * 1 / 1000; >> + u8 v[2], brightness_msb_mask; >> + >> + /* WLED5's lower limit is 0.1% */ >> + if (brightness > 0 && brightness < low_limit) >> + brightness = low_limit; >> + >> + brightness_msb_mask = 0xf; >> + if (wled->max_brightness == WLED5_SINK_REG_BRIGHT_MAX_15B) >> + brightness_msb_mask = 0x7f; > > Why not just brightness &= wled->max_brightness? But given that it > seems > like the framework ensures that brightness <= max_brightness, why not > skip this altogether? > Okay. I will modify the code to remove the min/max, low_limit checks in next post. >> + >> + v[0] = brightness & 0xff; >> + v[1] = (brightness >> 8) & brightness_msb_mask; >> + >> + offset = wled5_brightness_reg[wled->cfg.mod_sel]; >> + rc = regmap_bulk_write(wled->regmap, wled->sink_addr + offset, >> + v, 2); >> + return rc; >> +} >> + >> static int wled4_set_brightness(struct wled *wled, u16 brightness) >> { >> int rc, i; >> @@ -237,7 +325,28 @@ static int wled_module_enable(struct wled *wled, >> int val) >> return 0; >> } >> >> -static int wled_sync_toggle(struct wled *wled) >> +static int wled5_sync_toggle(struct wled *wled) >> +{ >> + int rc; >> + u8 val; >> + >> + val = (wled->cfg.mod_sel == MOD_A) ? WLED5_SINK_REG_SYNC_MOD_A_BIT : >> + WLED5_SINK_REG_SYNC_MOD_B_BIT; >> + rc = regmap_update_bits(wled->regmap, >> + wled->sink_addr + WLED5_SINK_REG_MOD_SYNC_BIT, >> + WLED5_SINK_REG_SYNC_MASK, val); >> + if (rc < 0) >> + return rc; >> + >> + val = 0; > > Just plug 0 in the function call. > Sure. Will do it in next post. >> + rc = regmap_update_bits(wled->regmap, >> + wled->sink_addr + WLED5_SINK_REG_MOD_SYNC_BIT, >> + WLED5_SINK_REG_SYNC_MASK, val); >> + >> + return rc; > > And return regmap_update_bits(...); > Sure. Will do it in next post. >> +} >> + > > Regards, > Bjorn