linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacek Anaszewski <jacek.anaszewski@gmail.com>
To: Dan Murphy <dmurphy@ti.com>,
	pavel@ucw.cz, tony@atomide.com, sre@kernel.org,
	nekit1000@gmail.com, mpartap@gmx.net, merlijn@wizzup.org
Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] leds: lm3532: Fix brightness control for i2c mode
Date: Thu, 1 Aug 2019 21:48:41 +0200	[thread overview]
Message-ID: <1fb65b16-a558-37ba-30a9-26819849f336@gmail.com> (raw)
In-Reply-To: <3716262b-64e5-e236-1c35-7cfe9e0d935a@ti.com>

Dan,

On 8/1/19 9:17 PM, Dan Murphy wrote:
> Jacek
> 
> On 8/1/19 1:52 PM, Jacek Anaszewski wrote:
>> Hi Dan,
>>
>> Thank you for the patch set. Please find my comments
>> in the code below.
>>
>> On 8/1/19 5:14 PM, Dan Murphy wrote:
>>> Fix the brightness control for I2C mode.  Instead of
>>> changing the full scale current register update the ALS target
>>> register for the appropriate banks.
>>>
>>> In addition clean up some code errors and random misspellings found
>>> during coding.
>>>
>>> Tested on Droid4 as well as LM3532 EVM connected to a BeagleBoneBlack
>>>
>>> Fixes: e37a7f8d77e1 ("leds: lm3532: Introduce the lm3532 LED driver")
>>> Reported-by: Pavel Machek <pavel@ucw.cz>
>>> Signed-off-by: Dan Murphy <dmurphy@ti.com>
>>> ---
>>>   drivers/leds/leds-lm3532.c | 78 ++++++++++++++++++++++++--------------
>>>   1 file changed, 50 insertions(+), 28 deletions(-)
>>>
[...]
>>> +     * brightness register may have changed during boot.
>>> +     */> +    ret = regmap_read(drvdata->regmap, brightness_config_reg,
>>> +              &led->ctrl_brt_pointer);
>>> +    if (ret)
>>> +        return ret;
>>> +
>>> +    led->ctrl_brt_pointer &= LM3532_ZONE_MASK;
>> Could you shed more light on this hardware peculiarity?
>> What kind of pointer is it?
> 
> The bits in the register are called Control A,B or C Brightness Pointer
> in the data sheet.
> 
> Basically BITS(4:2) control or points to which Zone target register will
> be used to control
> 
> the output current for the particular control bank
> 
> 000 = Control A Zone Target 0
> 001 = Control A Zone Target 1
> 010 = Control A Zone Target 2
> 011 = Control A Zone Target 3
> 1XX = Control A Zone Target 4 (default)
> 
> I was trying to keep the variable and register bits name some what the
> same.

Thanks for the explanation.

If that's the name from data sheet then it's indeed reasonable to
keep the same name for the variable.

>>
>>> +    brightness_config_val = led->ctrl_brt_pointer | led->mode;
>>> +    ret = regmap_write(drvdata->regmap, brightness_config_reg,
>>> +               brightness_config_val);
>>> +    if (ret)>>> +        return ret;
>>> +
>>>       for (i = 0; i < led->num_leds; i++) {
>>>           output_cfg_shift = led->led_strings[i] * 2;
>>>           output_cfg_val |= (led->control_bank << output_cfg_shift);
>>> @@ -382,7 +407,6 @@ static int lm3532_als_configure(struct
>>> lm3532_data *priv,
>>>       struct lm3532_als_data *als = priv->als_data;
>>>       u32 als_vmin, als_vmax, als_vstep;
>>>       int zone_reg = LM3532_REG_ZN_0_HI;
>>> -    int brightnes_config_reg;
>>>       int ret;
>>>       int i;
>>>   @@ -411,14 +435,7 @@ static int lm3532_als_configure(struct
>>> lm3532_data *priv,
>>>       als->config = (als->als_avrg_time | (LM3532_ENABLE_ALS) |
>>>           (als->als_input_mode << LM3532_ALS_SEL_SHIFT));
>>>   -    ret = regmap_write(priv->regmap, LM3532_ALS_CONFIG, als->config);
>>> -    if (ret)
>>> -        return ret;
>>> -
>>> -    brightnes_config_reg = LM3532_REG_ZONE_CFG_A + led->control_bank
>>> * 2;
>>> -
>>> -    return regmap_update_bits(priv->regmap, brightnes_config_reg,
>>> -                  LM3532_I2C_CTRL, LM3532_ALS_CTRL);
>>> +    return regmap_write(priv->regmap, LM3532_ALS_CONFIG, als->config);
>>>   }
>>>     static int lm3532_parse_als(struct lm3532_data *priv)
>>> @@ -542,12 +559,14 @@ static int lm3532_parse_node(struct lm3532_data
>>> *priv)
>>>           }
>>>             if (led->mode == LM3532_BL_MODE_ALS) {
>>> +            led->mode = LM3532_ALS_CTRL;
>>>               ret = lm3532_parse_als(priv);
>>>               if (ret)
>>>                   dev_err(&priv->client->dev, "Failed to parse als\n");
>>>               else
>>>                   lm3532_als_configure(priv, led);
>>> -        }
>>> +        } else
>>> +            led->mode = LM3532_I2C_CTRL;
>> Coding style issue: you need curly braces around the body of "else"
>> in this case as well.
> 
> No checkpatch complaint I will fix it.

Check section 3) Placing Braces and Spaces from
Documentation/process/coding-style.rst.

-- 
Best regards,
Jacek Anaszewski

  reply	other threads:[~2019-08-01 19:48 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-01 15:14 [PATCH 1/3] leds: lm3532: Fix brightness control for i2c mode Dan Murphy
2019-08-01 15:14 ` [PATCH 2/3] dt: lm3532: Add property for full scale current Dan Murphy
2019-08-01 18:53   ` Jacek Anaszewski
2019-08-01 19:12     ` Dan Murphy
2019-08-01 15:14 ` [PATCH 3/3] leds: lm3532: Add full scale current configuration Dan Murphy
2019-08-01 18:52 ` [PATCH 1/3] leds: lm3532: Fix brightness control for i2c mode Jacek Anaszewski
2019-08-01 19:17   ` Dan Murphy
2019-08-01 19:48     ` Jacek Anaszewski [this message]
2019-08-01 21:36   ` Pavel Machek
2019-08-02  0:02     ` Dan Murphy

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=1fb65b16-a558-37ba-30a9-26819849f336@gmail.com \
    --to=jacek.anaszewski@gmail.com \
    --cc=dmurphy@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=merlijn@wizzup.org \
    --cc=mpartap@gmx.net \
    --cc=nekit1000@gmail.com \
    --cc=pavel@ucw.cz \
    --cc=sre@kernel.org \
    --cc=tony@atomide.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).