fix loading of firmware with user mode helper
PATCH 1/1 fix loading of firmware with user mode helper
This patch fixes loading of firmware when using the user mode helper. I have seen the problems with the coda driver. Using this patch the coda driver loads without any problems. Please check if this is the right way to fix the problem.
Zahari Doychev (1):
drivers: base: fw: fix ret value when loading fw
drivers/base/firmware_class.c | 4 ++++ 1 file changed, 4 insertions(+)
Signature · 1 line
2.3.0
PATCH 1/1 drivers: base: fw: fix ret value when loading fw
When using the user mode helper to load firmwares the function _request_firmware gets a positive return value from fw_load_from_user_helper and because of this the firmware buffer is not assigned. This happens only when the return value is zero. This patch fixes this problem in _request_firmware_load. When the completion is ready the return value is set to zero.
--- drivers/base/firmware_class.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/base/firmware_class.c +4 -0
@@ -920,6 +920,10 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,else if (!buf->data) retval = -ENOMEM ; +/* wait for completion was successful so return ok */ +if (retval >0 ) + retval =0 ; +device_remove_file (f_dev, &dev_attr_loading); err_del_bin_attr:device_remove_bin_file (f_dev, &firmware_attr_data);
Signature · 1 line
2.3.0
Re: [PATCH] drivers: base: fw: fix ret value when loading fw
Quoted 7 lines · Zahari Doychev
When using the user mode helper to load firmwares the function
_request_firmwaregets a positive return value fromfw_load_from_user_helperand because of this the firmware buffer is not assigned. This happens only when the return value is zero. This patch fixes this problem in_request_firmware_load. When the completion is ready the return value is set to zero.Signed-off-by Zahari Doychev <[email protected]>
Quoted 9 lines
--- drivers/base/firmware_class.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/base/firmware_class.c +0
-0
drivers/base/firmware_class.c static int _request_firmware_load(struct firmware_priv *fw_priv, · line 925
Quoted 6 lines
drivers/base/firmware_class.c +3
-0@@ -920,6 +920,10 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,else if (!buf->data) retval = -ENOMEM ; +/* wait for completion was successful so return ok */ +if (retval >0 ) + retval =0 ;
Suggest to move the check backward and handle return value from wait_for_completion_interruptible_timeout() in one place, like below:
if (retval == -ERESTARTSYS || !retval) {
...
} else if (retval > 0) {
retval = 0;
}Quoted 7 lines
drivers/base/firmware_class.c +1
-1+device_remove_file (f_dev, &dev_attr_loading); err_del_bin_attr:device_remove_bin_file (f_dev, &firmware_attr_data); --2.3.0
PATCH v2 1/1 drivers: base: fw: fix ret value when loading fw
When using the user mode helper to load firmwares the function _request_firmware gets a positive return value from fw_load_from_user_helper and because of this the firmware buffer is not assigned. This happens only when the return value is zero. This patch fixes this problem in _request_firmware_load. When the completion is ready the return value is set to zero.
---
Changes from v1:
- move handling of wait_for_completion_interruptible_timeout() return value
drivers/base/firmware_class.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/base/firmware_class.c +2 -0
@@ -913,6 +913,8 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,mutex_lock (&fw_lock);fw_load_abort (fw_priv);mutex_unlock (&fw_lock); + }else if (retval >0 ) { + retval =0 ; }if (is_fw_load_aborted (buf))
Signature · 1 line
2.3.0
Re: [PATCH v2] drivers: base: fw: fix ret value when loading fw
Quoted 6 lines · Zahari Doychev
When using the user mode helper to load firmwares the function
_request_firmwaregets a positive return value fromfw_load_from_user_helperand because of this the firmware buffer is not assigned. This happens only when the return value is zero. This patch fixes this problem in_request_firmware_load. When the completion is ready the return value is set to zero.
Quoted 6 lines
Signed-off-by Zahari Doychev <[email protected]>---
Changes from v1:
- move handling ofwait_for_completion_interruptible_timeout()return value
Hi,
what is the status of the patch? Is there something wrong with it?
Regards,
Zahari