mirror of
https://github.com/sheumann/hush.git
synced 2025-01-28 13:31:12 +00:00
mdev: tell kernel that we didn't find the firmware
function old new delta mdev_main 797 801 +4 Signed-off-by: Christoph Lohmann <20h@r-36.net> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
aaf827203d
commit
25cb5aae2b
@ -756,37 +756,45 @@ static int FAST_FUNC dirAction(const char *fileName UNUSED_PARAM,
|
|||||||
static void load_firmware(const char *firmware, const char *sysfs_path)
|
static void load_firmware(const char *firmware, const char *sysfs_path)
|
||||||
{
|
{
|
||||||
int cnt;
|
int cnt;
|
||||||
int firmware_fd, loading_fd, data_fd;
|
int firmware_fd, loading_fd;
|
||||||
|
|
||||||
/* check for /lib/firmware/$FIRMWARE */
|
/* check for /lib/firmware/$FIRMWARE */
|
||||||
xchdir("/lib/firmware");
|
xchdir("/lib/firmware");
|
||||||
firmware_fd = xopen(firmware, O_RDONLY);
|
firmware_fd = open(firmware, O_RDONLY); /* can fail */
|
||||||
|
|
||||||
/* in case we goto out ... */
|
|
||||||
data_fd = -1;
|
|
||||||
|
|
||||||
/* check for /sys/$DEVPATH/loading ... give 30 seconds to appear */
|
/* check for /sys/$DEVPATH/loading ... give 30 seconds to appear */
|
||||||
xchdir(sysfs_path);
|
xchdir(sysfs_path);
|
||||||
for (cnt = 0; cnt < 30; ++cnt) {
|
for (cnt = 0; cnt < 30; ++cnt) {
|
||||||
loading_fd = open("loading", O_WRONLY);
|
loading_fd = open("loading", O_WRONLY);
|
||||||
if (loading_fd != -1)
|
if (loading_fd >= 0)
|
||||||
goto loading;
|
goto loading;
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
loading:
|
loading:
|
||||||
/* tell kernel we're loading by "echo 1 > /sys/$DEVPATH/loading" */
|
cnt = 0;
|
||||||
if (full_write(loading_fd, "1", 1) != 1)
|
if (firmware_fd >= 0) {
|
||||||
goto out;
|
int data_fd;
|
||||||
|
|
||||||
/* load firmware into /sys/$DEVPATH/data */
|
/* tell kernel we're loading by "echo 1 > /sys/$DEVPATH/loading" */
|
||||||
data_fd = open("data", O_WRONLY);
|
if (full_write(loading_fd, "1", 1) != 1)
|
||||||
if (data_fd == -1)
|
goto out;
|
||||||
goto out;
|
|
||||||
cnt = bb_copyfd_eof(firmware_fd, data_fd);
|
|
||||||
|
|
||||||
/* tell kernel result by "echo [0|-1] > /sys/$DEVPATH/loading" */
|
/* load firmware into /sys/$DEVPATH/data */
|
||||||
|
data_fd = open("data", O_WRONLY);
|
||||||
|
if (data_fd < 0)
|
||||||
|
goto out;
|
||||||
|
cnt = bb_copyfd_eof(firmware_fd, data_fd);
|
||||||
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
|
close(data_fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Tell kernel result by "echo [0|-1] > /sys/$DEVPATH/loading"
|
||||||
|
* Note: we emit -1 also if firmware file wasn't found.
|
||||||
|
* There are cases when otherwise kernel would wait for minutes
|
||||||
|
* before timing out.
|
||||||
|
*/
|
||||||
if (cnt > 0)
|
if (cnt > 0)
|
||||||
full_write(loading_fd, "0", 1);
|
full_write(loading_fd, "0", 1);
|
||||||
else
|
else
|
||||||
@ -796,7 +804,6 @@ static void load_firmware(const char *firmware, const char *sysfs_path)
|
|||||||
if (ENABLE_FEATURE_CLEAN_UP) {
|
if (ENABLE_FEATURE_CLEAN_UP) {
|
||||||
close(firmware_fd);
|
close(firmware_fd);
|
||||||
close(loading_fd);
|
close(loading_fd);
|
||||||
close(data_fd);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user