Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 148ec935 authored by Soumya Managoli's avatar Soumya Managoli
Browse files

hal: Fix incorrect wsa count update during platform_init

buf is not reset after each read_line_from_file call.
Hence buf is matching with wsa after first wsa thermal
zone is found. This results in wsa_count being more than 2.

Buffer is reset after each iteration to fix this issue.

Change-Id: I73b1bd350c0a8659e7a42b5ccdb7600935254ae6
parent 1d6fb48a
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2005,7 +2005,6 @@ static bool check_and_get_wsa_info(char *snd_card_name, int *wsaCount,
    }

    while ((tdirent = readdir(tdir))) {
        char buf[50];
        struct dirent *tzdirent;
        DIR *tzdir = NULL;

@@ -2013,6 +2012,7 @@ static bool check_and_get_wsa_info(char *snd_card_name, int *wsaCount,
        if (!tzdir)
            continue;
        while ((tzdirent = readdir(tzdir))) {
            char buf[50] = {0};
            if (strcmp(tzdirent->d_name, "type"))
                continue;
            snprintf(name, MAX_PATH, TZ_TYPE, tzn);
@@ -2020,12 +2020,12 @@ static bool check_and_get_wsa_info(char *snd_card_name, int *wsaCount,
            read_line_from_file(name, buf, sizeof(buf));
            if (strstr(buf, file)) {
                wsa_count++;
            }
            tzn++;
            /*We support max only two WSA speakers*/
            if (wsa_count == 2)
                break;
        }
            tzn++;
        }
        closedir(tzdir);
    }
    if (wsa_count > 0){