lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240704165000.GA501857@google.com>
Date: Thu, 4 Jul 2024 17:50:00 +0100
From: Lee Jones <lee@...nel.org>
To: Jack Chen <zenghuchen@...gle.com>
Cc: Pavel Machek <pavel@....cz>, Mark Brown <broonie@...nel.org>,
	Vadim Pasternak <vadimp@...dia.com>,
	Randy Dunlap <rdunlap@...radead.org>, linux-kernel@...r.kernel.org,
	linux-leds@...r.kernel.org
Subject: Re: [PATCH] leds:lm3601x:calculate max_brightness and brightness
 properly

Subject line needs fixing.

`git log --oneline -- drivers/<subsystem>` is your friend.

> 1) check the range of torch_current_max,
> 2) calcualtes max_brightness precisely,
> 3) lm3601x torch brightness register starts from 0 (2.4 mA).

Please write this out as a proper paragraph.

This isn't really a numbered list type situation.

> Tested: tested with a lm36011 and it can set its brightness to lowest
> value (2.4 mA)

What is the Tested: trailer?  Again, please write this out properly.

> Signed-off-by: Jack Chen <zenghuchen@...gle.com>
> ---
>  drivers/leds/flash/leds-lm3601x.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/leds/flash/leds-lm3601x.c b/drivers/leds/flash/leds-lm3601x.c
> index 7e93c447fec5..fc4df904ea90 100644
> --- a/drivers/leds/flash/leds-lm3601x.c
> +++ b/drivers/leds/flash/leds-lm3601x.c
> @@ -190,7 +190,7 @@ static int lm3601x_brightness_set(struct led_classdev *cdev,
>  		goto out;
>  	}
>  
> -	ret = regmap_write(led->regmap, LM3601X_LED_TORCH_REG, brightness);
> +	ret = regmap_write(led->regmap, LM3601X_LED_TORCH_REG, brightness - 1);

Why is there now a need to start adding/subtracting 1s to make the maths work?

>  	if (ret < 0)
>  		goto out;
>  
> @@ -341,8 +341,9 @@ static int lm3601x_register_leds(struct lm3601x_led *led,
>  
>  	led_cdev = &led->fled_cdev.led_cdev;
>  	led_cdev->brightness_set_blocking = lm3601x_brightness_set;
> -	led_cdev->max_brightness = DIV_ROUND_UP(led->torch_current_max,
> -						LM3601X_TORCH_REG_DIV);
> +	led_cdev->max_brightness = DIV_ROUND_UP(

This is no place to break a line.

Break after the '=' and wrap at 100-chars instead.

> +			led->torch_current_max - LM3601X_MIN_TORCH_I_UA + 1,
> +			LM3601X_TORCH_REG_DIV);
>  	led_cdev->flags |= LED_DEV_CAP_FLASH;
>  
>  	init_data.fwnode = fwnode;
> @@ -386,6 +387,14 @@ static int lm3601x_parse_node(struct lm3601x_led *led,
>  		goto out_err;
>  	}
>  
> +	if (led->torch_current_max > LM3601X_MAX_TORCH_I_UA) {
> +		dev_warn(&led->client->dev,
> +			 "led-max-microamp cannot be higher than %d\n",
> +			 LM3601X_MAX_TORCH_I_UA);

"Max torch current set too high (%d vs %d)"

> +		led->torch_current_max = LM3601X_MAX_TORCH_I_UA;
> +	}
> +
> +

2 lines?

>  	ret = fwnode_property_read_u32(child, "flash-max-microamp",
>  				&led->flash_current_max);
>  	if (ret) {
> -- 
> 2.45.2.803.g4e1b14247a-goog
> 

-- 
Lee Jones [李琼斯]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ