Commit 584eb94a authored by Mattias Jacobsson's avatar Mattias Jacobsson Committed by Kleber Sacilotto de Souza

USB: misc: appledisplay: fix backlight update_status return code

BugLink: https://bugs.launchpad.net/bugs/1854855

[ Upstream commit 09015855 ]

Upon success the update_status handler returns a positive number
corresponding to the number of bytes transferred by usb_control_msg.
However the return code of the update_status handler should indicate if
an error occurred(negative) or how many bytes of the user's input to sysfs
that was consumed. Return code zero indicates all bytes were consumed.

The bug can for example result in the update_status handler being called
twice, the second time with only the "unconsumed" part of the user's input
to sysfs. Effectively setting an incorrect brightness.

Change the update_status handler to return zero for all successful
transactions and forward usb_control_msg's error code upon failure.
Signed-off-by: default avatarMattias Jacobsson <2pi@mok.nu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarConnor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 8a6e77ab
...@@ -161,8 +161,11 @@ static int appledisplay_bl_update_status(struct backlight_device *bd) ...@@ -161,8 +161,11 @@ static int appledisplay_bl_update_status(struct backlight_device *bd)
pdata->msgdata, 2, pdata->msgdata, 2,
ACD_USB_TIMEOUT); ACD_USB_TIMEOUT);
mutex_unlock(&pdata->sysfslock); mutex_unlock(&pdata->sysfslock);
return retval; if (retval < 0)
return retval;
else
return 0;
} }
static int appledisplay_bl_get_brightness(struct backlight_device *bd) static int appledisplay_bl_get_brightness(struct backlight_device *bd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment