diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2015-09-22 16:52:04 +0200 |
---|---|---|
committer | Jessica Wagantall <jwagantall@cyngn.com> | 2015-10-14 11:08:44 -0700 |
commit | e15cf1fda52995d44f74f0801c2fabcf5513cf94 (patch) | |
tree | da1b14c92540645dc5b95b98eacb26be9699b7be | |
parent | 6e7b90c750b2dde591b8b7d1a9e12ab033a15ac8 (diff) | |
download | android_hardware_broadcom_libbt-stable/cm-12.1-YOG7D.tar.gz android_hardware_broadcom_libbt-stable/cm-12.1-YOG7D.tar.bz2 android_hardware_broadcom_libbt-stable/cm-12.1-YOG7D.zip |
libbt-vendor: Fix Samsung patchfile detection.stable/cm-12.1-YOG7D
Issue-Id: RM-170
This is totally broken. If the chipset is bcm4530 then it added e.g.
_wisol to it and looked for bcm4530_wisol.hcd. The firmware files are
named e.g. bcm4350_V0301.0636_wisol.hcd. What we need to do if a special
flavor is needed to search for the string in the name of the file we are
currently inspecting.
Change-Id: If804de56064cf8993a32af98c7ec39126ebd349a
-rwxr-xr-x | src/hardware.c | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/src/hardware.c b/src/hardware.c index 21ff0a4..fa67f8a 100755 --- a/src/hardware.c +++ b/src/hardware.c @@ -439,33 +439,35 @@ static int hw_strncmp (const char *p_str1, const char *p_str2, const int len) ** Returns Returns char* (bluetooth type) ** *******************************************************************************/ -static char *hw_samsung_bluetooth_type() +static const char *hw_samsung_bluetooth_type() { char buf[10]; - int fd = open(CID_PATH, O_RDONLY); + int fd; + ssize_t nread; + + fd = open(CID_PATH, O_RDONLY); if (fd < 0) { ALOGE("Couldn't open file %s for reading", CID_PATH); return NULL; } - if (read(fd, buf, sizeof(buf)) < 0) { - close(fd); + nread = read(fd, buf, sizeof(buf)); + close(fd); + if (nread <= 0) { return NULL; } - close(fd); - if (strncmp(buf, "murata", 6) == 0) - return "_murata"; + return "murata"; if (strncmp(buf, "semcove", 7) == 0) - return "_semcove"; + return "semcove"; if (strncmp(buf, "semcosh", 7) == 0) - return "_semcosh"; + return "semcosh"; if (strncmp(buf, "wisol", 5) == 0) - return "_wisol"; + return "wisol"; return NULL; } @@ -516,26 +518,28 @@ static uint8_t hw_config_findpatch(char *p_chip_id_str) while ((dp = readdir(dirp)) != NULL) { /* Check if filename starts with chip-id name */ -#ifdef SAMSUNG_BLUETOOTH - char *type = hw_samsung_bluetooth_type(); - char samsung_patchfile_name[FW_PATCHFILE_PATH_MAXLEN] = { 0 }; - memset(samsung_patchfile_name, 0, FW_PATCHFILE_PATH_MAXLEN); - strcpy(samsung_patchfile_name, p_chip_id_str); - if (type != NULL) - { - strcat(samsung_patchfile_name, type); - } + int cmp; - if ((hw_strncmp(dp->d_name, samsung_patchfile_name, - strlen(samsung_patchfile_name))) == 0) - { - memset(p_chip_id_str, 0, FW_PATCHFILE_PATH_MAXLEN); - strcpy(p_chip_id_str, samsung_patchfile_name); -#else - if ((hw_strncmp(dp->d_name, p_chip_id_str, strlen(p_chip_id_str)) \ - ) == 0) + cmp = hw_strncmp(dp->d_name, p_chip_id_str, strlen(p_chip_id_str)); + if (cmp == 0) { +#ifdef SAMSUNG_BLUETOOTH + const char *type = hw_samsung_bluetooth_type(); + + if (type != NULL) { + const char *needle; + + BTHWDBG("Looking for Samsung %s patchfile flavour in %s", + type, + dp->d_name); + + needle = strstr(dp->d_name, type); + if (needle == NULL) { + continue; + } + } #endif + /* Check if it has .hcd extenstion */ filenamelen = strlen(dp->d_name); if ((filenamelen >= FW_PATCHFILE_EXTENSION_LEN) && |