[PATCH] tools/hciattach_ath3k: Load BT board data based on country code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



BT board data file PS_ASIC-<country-code>.pst is loaded based
on country code. If not exist, default BT board data file
PS_ASIC.pst would be loaded.

This patch doesn't define how to get the country code at the moment, but
future patches can supply the country code in the region parameter of
get_ps_file_name.
---
 tools/hciattach_ath3k.c | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/tools/hciattach_ath3k.c b/tools/hciattach_ath3k.c
index d920050f6..eb2a2aeb6 100644
--- a/tools/hciattach_ath3k.c
+++ b/tools/hciattach_ath3k.c
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <ctype.h>
 #include <time.h>
+#include <sys/stat.h>
 #include <sys/time.h>
 #include <sys/types.h>
 #include <sys/param.h>
@@ -573,20 +574,33 @@ static int ps_config_download(int fd, int tag_count)
 	return 0;
 }
 
-#define PS_ASIC_FILE			"PS_ASIC.pst"
-#define PS_FPGA_FILE			"PS_FPGA.pst"
+#define PS_ASIC_FILE_PREFIX		"PS_ASIC"
+#define PS_FPGA_FILE_PREFIX		"PS_FPGA"
 
-static void get_ps_file_name(uint32_t devtype, uint32_t rom_version,
-							char *path)
+static void get_ps_file_name(uint32_t devtype, uint32_t rom_version, char *path,
+								char *region)
 {
-	char *filename;
+	char *file_prefix;
+	struct stat st;
 
 	if (devtype == 0xdeadc0de)
-		filename = PS_ASIC_FILE;
+		file_prefix = PS_ASIC_FILE_PREFIX;
 	else
-		filename = PS_FPGA_FILE;
+		file_prefix = PS_FPGA_FILE_PREFIX;
 
-	snprintf(path, MAXPATHLEN, "%s%x/%s", FW_PATH, rom_version, filename);
+	if (!region)
+		goto default_ps_file;
+
+	snprintf(path, MAXPATHLEN, "%s%x/%s-%s.pst", FW_PATH, rom_version,
+			file_prefix, region);
+	if (stat(path, &st) == 0)
+		return;
+
+	perror("PS file with region code not exist, use default PS file\n");
+
+default_ps_file:
+	snprintf(path, MAXPATHLEN, "%s%x/%s.pst", FW_PATH, rom_version,
+			file_prefix);
 }
 
 #define PATCH_FILE        "RamPatch.txt"
@@ -823,7 +837,7 @@ static int ath_ps_download(int fd)
 		goto download_cmplete;
 	}
 
-	get_ps_file_name(dev_type, rom_version, ps_file);
+	get_ps_file_name(dev_type, rom_version, ps_file, NULL);
 	get_patch_file_name(dev_type, rom_version, build_version, patch_file);
 
 	stream = fopen(ps_file, "r");
-- 
2.17.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux