[PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value

Brigham Campbell posted 3 patches 2 months, 1 week ago
There is a newer version of this series
[PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value
Posted by Brigham Campbell 2 months, 1 week ago
Fix bug in nt35560_set_brightness() which causes the function to
erroneously report an error. mipi_dsi_dcs_write() returns either a
negative value when an error occurred or a positive number of bytes
written when no error occurred. The buggy code reports an error under
either condition.

Fixes: 7835ed6a9e86 ("drm/panel-sony-acx424akp: Modernize backlight handling")
Signed-off-by: Brigham Campbell <me@brighamcampbell.com>
---
 drivers/gpu/drm/panel/panel-novatek-nt35560.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-novatek-nt35560.c b/drivers/gpu/drm/panel/panel-novatek-nt35560.c
index 98f0782c8411..17898a29efe8 100644
--- a/drivers/gpu/drm/panel/panel-novatek-nt35560.c
+++ b/drivers/gpu/drm/panel/panel-novatek-nt35560.c
@@ -161,7 +161,7 @@ static int nt35560_set_brightness(struct backlight_device *bl)
 		par = 0x00;
 		ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_WRITE_CONTROL_DISPLAY,
 					 &par, 1);
-		if (ret) {
+		if (ret < 0) {
 			dev_err(nt->dev, "failed to disable display backlight (%d)\n", ret);
 			return ret;
 		}
-- 
2.50.1
Re: [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value
Posted by Doug Anderson 2 months, 1 week ago
Hi,

On Mon, Jul 28, 2025 at 10:44 PM Brigham Campbell
<me@brighamcampbell.com> wrote:
>
> Fix bug in nt35560_set_brightness() which causes the function to
> erroneously report an error. mipi_dsi_dcs_write() returns either a
> negative value when an error occurred or a positive number of bytes
> written when no error occurred. The buggy code reports an error under
> either condition.
>
> Fixes: 7835ed6a9e86 ("drm/panel-sony-acx424akp: Modernize backlight handling")

I think your Fixes tag is wrong, actually. I think it needs to be:

Fixes: 8152c2bfd780 ("drm/panel: Add driver for Sony ACX424AKP panel")

Even though that commit that you pointed at moved the code around, I
believe the code has been wrong since the start of the driver.

Other than that:

Reviewed-by: Douglas Anderson <dianders@chromium.org>
Re: [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value
Posted by Brigham Campbell 2 months, 1 week ago
On Tue Jul 29, 2025 at 3:33 PM MDT, Doug Anderson wrote:
>>
>> Fixes: 7835ed6a9e86 ("drm/panel-sony-acx424akp: Modernize backlight handling")
>
> I think your Fixes tag is wrong, actually. I think it needs to be:
>
> Fixes: 8152c2bfd780 ("drm/panel: Add driver for Sony ACX424AKP panel")

Oh, good catch! I thought that 7835ed6a9e86 introduced that code instead
of just reorganizing it. I'll remember to take a closer look at the git
tree next time I add a Fixes tag to a commit and I'll address this in
v3.

Thanks,
Brigham
Re: [PATCH v2 1/3] drm/panel: novatek-nt35560: Fix invalid return value
Posted by neil.armstrong@linaro.org 2 months, 1 week ago
On 29/07/2025 07:44, Brigham Campbell wrote:
> Fix bug in nt35560_set_brightness() which causes the function to
> erroneously report an error. mipi_dsi_dcs_write() returns either a
> negative value when an error occurred or a positive number of bytes
> written when no error occurred. The buggy code reports an error under
> either condition.
> 
> Fixes: 7835ed6a9e86 ("drm/panel-sony-acx424akp: Modernize backlight handling")
> Signed-off-by: Brigham Campbell <me@brighamcampbell.com>
> ---
>   drivers/gpu/drm/panel/panel-novatek-nt35560.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-novatek-nt35560.c b/drivers/gpu/drm/panel/panel-novatek-nt35560.c
> index 98f0782c8411..17898a29efe8 100644
> --- a/drivers/gpu/drm/panel/panel-novatek-nt35560.c
> +++ b/drivers/gpu/drm/panel/panel-novatek-nt35560.c
> @@ -161,7 +161,7 @@ static int nt35560_set_brightness(struct backlight_device *bl)
>   		par = 0x00;
>   		ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_WRITE_CONTROL_DISPLAY,
>   					 &par, 1);
> -		if (ret) {
> +		if (ret < 0) {
>   			dev_err(nt->dev, "failed to disable display backlight (%d)\n", ret);
>   			return ret;
>   		}

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>