Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp305229ybi; Thu, 1 Aug 2019 19:29:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoV1vjOd78qLt5d7+SYFSdrnhq+w+mY3+9cPrwOAoLElDzFLUdMp49g57t88+DmX2FcWfA X-Received: by 2002:aed:3e7c:: with SMTP id m57mr93662221qtf.204.1564712956854; Thu, 01 Aug 2019 19:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564712956; cv=none; d=google.com; s=arc-20160816; b=Y/0LpNNTAubbnTBJ1im7O7mENUI0H+Xaf0TQ8tjoXFerF/t3pSY4ONF99SC1YCPUQz AUb7sW7nw45RV4NhDcV1T1wYOmADKKsHr1SKKnD24STKPbdIgYqAWHS8JJs+cTFZrf+8 T5R/C7lTeXhYfgJ8n3ESOzp6CA5W/hydhgRPuZ8lFsRXMYO68cLsLQbA/o45+AGQuwog D/MlHeW1jWhamu0F531GZbO88bWeqoJu+kGrYW/SwoGdswX3LlF7zYHZhJTq/azIBwvU P4kiY17Mk6Uh3Si7VXu8Ly8bjJfjK7v/GQ6X3EIsz9PWevQN0vhH14zwpHrAhR9UAdCr IM5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=JPE8/NA+otNSQgKjCkF3O2VPfxJQy2lptz0Icmukqvg=; b=EByOs83QLIANnun8KWCI9T4oxXIfiG99y9YOllLdhsbdpzrCytzmXzx4NMHEQNWkNm /eGGTiCb82M1xFI9J//eNTsI5Zu++I2Qja9vGSWfplZZ1Qd/X1KAkXhjnFoY3JRnZO8p DDIDNY6TDcgApmcNfHrBGYqdpiA0CgUevAm0rSgXiLNTqQh6FOV6vX/dYdS4e9AtkyXu C9EVfURRj5xvo5Qo/Wxu3mmwD+pYi2OpDKZg9j171W8w1G+dWGdk8dIH0Dye8Cgo62I+ +I/4IyUE9RzufOyAUx9PpzZOqf5r1TJSoe/kabFwbMD3uKHUGR0X2vcEpG53auzEGsG9 NlSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=prfBV9ct; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n40si45595519qvn.34.2019.08.01.19.29.03; Thu, 01 Aug 2019 19:29:16 -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=@ti.com header.s=ti-com-17Q1 header.b=prfBV9ct; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390522AbfHBACf (ORCPT + 99 others); Thu, 1 Aug 2019 20:02:35 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:33098 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731258AbfHBACe (ORCPT ); Thu, 1 Aug 2019 20:02:34 -0400 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x7202LwS079622; Thu, 1 Aug 2019 19:02:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1564704141; bh=JPE8/NA+otNSQgKjCkF3O2VPfxJQy2lptz0Icmukqvg=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=prfBV9ctXodPzUT23xo90cQEWAnAX6tL+06BorNRljZBJRYe2oRfHsBiqIdAMGs7O PPVh71UDGq9Tq8UkDT9Ku69n88u9XM87wiMg9Y7d2NvrW0xI7nekoHul2xNjNzHJwv mMQkfomteHfr6UD/6KBsmEvhwWvFpPiMYVrZrrJw= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x7202Ll6036373 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 1 Aug 2019 19:02:21 -0500 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 1 Aug 2019 19:02:20 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE111.ent.ti.com (10.64.6.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 1 Aug 2019 19:02:20 -0500 Received: from [10.250.65.13] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x7202K7Q048015; Thu, 1 Aug 2019 19:02:20 -0500 Subject: Re: [PATCH 1/3] leds: lm3532: Fix brightness control for i2c mode To: Pavel Machek , Jacek Anaszewski CC: , , , , , , References: <20190801151421.21486-1-dmurphy@ti.com> <3e304b9a-e7fc-9294-1950-ee9bc5956305@gmail.com> <20190801213620.GA30096@amd> From: Dan Murphy Message-ID: Date: Thu, 1 Aug 2019 19:02:20 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190801213620.GA30096@amd> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Pavel Thanks for the review On 8/1/19 4:36 PM, Pavel Machek wrote: > Hi! > > If we are going to complain about coding style... this should really > be split, one change per patch. > >>> @@ -161,18 +167,18 @@ struct lm3532_data { >>> }; >>> >>> static const struct reg_default lm3532_reg_defs[] = { >>> - {LM3532_REG_OUTPUT_CFG, 0xe4}, >>> + {LM3532_REG_OUTPUT_CFG, 0x24}, >>> {LM3532_REG_STARTSHUT_RAMP, 0xc0}, >>> {LM3532_REG_RT_RAMP, 0xc0}, >>> {LM3532_REG_PWM_A_CFG, 0x82}, >>> {LM3532_REG_PWM_B_CFG, 0x82}, >>> {LM3532_REG_PWM_C_CFG, 0x82}, >>> {LM3532_REG_ZONE_CFG_A, 0xf1}, >>> - {LM3532_REG_CTRL_A_BRT, 0xf3}, >>> + {LM3532_REG_CTRL_A_FS_CURR, 0x13}, >>> {LM3532_REG_ZONE_CFG_B, 0xf1}, >>> - {LM3532_REG_CTRL_B_BRT, 0xf3}, >>> + {LM3532_REG_CTRL_B_FS_CURR, 0x13}, >>> {LM3532_REG_ZONE_CFG_C, 0xf1}, >>> - {LM3532_REG_CTRL_C_BRT, 0xf3}, >>> + {LM3532_REG_CTRL_C_FS_CURR, 0x13}, >>> {LM3532_REG_ENABLE, 0xf8}, >>> {LM3532_ALS_CONFIG, 0x44}, >>> {LM3532_REG_ZN_0_HI, 0x35}, > Default register values; are they related to the rest? Yes and no. I changed the #define so we would see a change anyway. And the default is 0x13. I can move it to a clean up patch > >>> @@ -302,7 +308,7 @@ static int lm3532_led_disable(struct lm3532_led *led_data) >>> int ret; >>> >>> ret = regmap_update_bits(led_data->priv->regmap, LM3532_REG_ENABLE, >>> - ctrl_en_val, ~ctrl_en_val); >>> + ctrl_en_val, 0); >>> if (ret) { >>> dev_err(led_data->priv->dev, "Failed to set ctrl:%d\n", ret); >>> return ret; > This should have no functional impact, its just a clenaup, probably > should go separately. I took it from your patch.? Thought it was a good clean up. I can move it to a separate patch and give you credit > >>> @@ -339,11 +345,9 @@ static int lm3532_brightness_set(struct led_classdev *led_cdev, >>> if (ret) >>> goto unlock; >>> >>> - brightness_reg = LM3532_REG_CTRL_A_BRT + led->control_bank * 2; >>> - brt_val = brt_val / LM3532_BRT_VAL_ADJUST; >>> - >>> + brightness_reg = LM3532_REG_ZONE_TRGT_A + led->control_bank * 5 + >>> + (led->ctrl_brt_pointer >> 2); >>> ret = regmap_write(led->priv->regmap, brightness_reg, brt_val); >>> - >>> unlock: >>> mutex_unlock(&led->priv->lock); >>> return ret; > This is the core change, AFAICT. Yep.? This is the fix you want. > >>> @@ -356,8 +360,29 @@ static int lm3532_init_registers(struct lm3532_led *led) >>> unsigned int output_cfg_val = 0; >>> unsigned int output_cfg_shift = 0; >>> unsigned int output_cfg_mask = 0; >>> + int brightness_config_reg; >>> + int brightness_config_val; >>> int ret, i; >>> >>> + if (drvdata->enable_gpio) >>> + gpiod_direction_output(drvdata->enable_gpio, 1); >>> + >>> + brightness_config_reg = LM3532_REG_ZONE_CFG_A + led->control_bank * 2; >>> + /* This could be hard coded to the default value but the control > Code is moved, probably should go in separately. We'll have less fun > bisecting problems when things are separate... On my Droid4 moving this enable call allowed the init to pass without a regmap failure. But I did not see the same issue on the BBB with the LM3532 EVM. Without this change in this patch the backlight failed to register.? I think we want to keep this change here. Dan > > Thanks and best regards, > Pavel >