linux-leds.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Cc: Dan Murphy <dmurphy@ti.com>,
	tony@atomide.com, sre@kernel.org, nekit1000@gmail.com,
	mpartap@gmx.net, merlijn@wizzup.org, 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 23:36:20 +0200	[thread overview]
Message-ID: <20190801213620.GA30096@amd> (raw)
In-Reply-To: <3e304b9a-e7fc-9294-1950-ee9bc5956305@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2892 bytes --]

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?

> > @@ -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. 

> > @@ -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.

> > @@ -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...

Thanks and best regards,
									Pavel

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  parent reply	other threads:[~2019-08-01 21:36 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
2019-08-01 21:36   ` Pavel Machek [this message]
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=20190801213620.GA30096@amd \
    --to=pavel@ucw.cz \
    --cc=dmurphy@ti.com \
    --cc=jacek.anaszewski@gmail.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=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).