lkml.org 
[lkml]   [2019]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/3] leds: lm3532: Fix brightness control for i2c mode
From
Date
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

\
 
 \ /
  Last update: 2019-08-01 21:48    [W:0.339 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site