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

Commit 538e7773 authored by zhangjie's avatar zhangjie Committed by Daniel Jacob Chittoor
Browse files

[ALM:11132375] Enable wifi macaddr

&&&%%%comment:Enable wifi macaddr
&&&%%%bug number:11132375
&&&%%%product name:sm7225_r_fp4
&&&%%%root cause:Coding
&&&%%%Bug category:T2M
&&&%%%Module_Impact:wifi
&&&%%%Test_Suggestion:.
&&&%%%Solution:.
&&&%%%Test_Report:.
&&&%%%VAL Can Test:Yes
parent f4d55d43
Loading
Loading
Loading
Loading
+14 −17
Original line number Original line Diff line number Diff line
@@ -1977,6 +1977,8 @@ static void hdd_update_tgt_vht_cap(struct hdd_context *hdd_ctx,
#define MAC_LEN		6
#define MAC_LEN		6
#define MAC_STR_LEN	17
#define MAC_STR_LEN	17
#define MAC_CHAR_NUM	2
#define MAC_CHAR_NUM	2
#define CMDLINE "/proc/cmdline"
#define CMDLINE_LEN 1024
static inline int is_in_range(unsigned char c,
static inline int is_in_range(unsigned char c,
		unsigned char low, unsigned char high)
		unsigned char low, unsigned char high)
{
{
@@ -2051,39 +2053,34 @@ static int jrd_get_mac_addr(unsigned char *eaddr)
{
{
	struct file *fp = NULL;
	struct file *fp = NULL;
	char fn[100] = {0};
	char fn[100] = {0};
	char dp[MAC_STR_LEN + 1] = {0};
    char dp[CMDLINE_LEN + 1] = {0};
	int l,len;
	int  len;
	char *wifimac_pos = NULL;
	char WifiMac[MAC_STR_LEN + 1] = {0};
	loff_t pos;
	loff_t pos;
	mm_segment_t old_fs;
	mm_segment_t old_fs;
	//FIXME:hard code.
	//FIXME:hard code.
	//Modify wifi mac address file location
	//Modify wifi mac address file location
	strcpy(fn, "/mnt/vendor/persist/t2m_param/wlan_macaddr");
	strcpy(fn, CMDLINE);
	fp = filp_open(fn, O_RDONLY, 0);
	fp = filp_open(fn, O_RDONLY, 0);
	if(IS_ERR(fp)){
	if(IS_ERR(fp)){
		printk(KERN_INFO "Unable to open '%s'.\n", fn);
		printk(KERN_INFO "Unable to open '%s'.\n", fn);
		goto err_open;
		goto err_open;
	}
	}

	l = fp->f_path.dentry->d_inode->i_size;
	if(l < MAC_STR_LEN){
		printk(KERN_INFO "Invalid macaddr file '%s' %d\n", fn,l);
		goto err_format;
	}

	pos = 0;
	pos = 0;
	old_fs=get_fs();
	old_fs=get_fs();
	set_fs(KERNEL_DS);
	set_fs(KERNEL_DS);
	len=vfs_read(fp, dp, MAC_STR_LEN, &pos);
    len=vfs_read(fp, dp, CMDLINE_LEN, &pos);
	set_fs(old_fs);
	set_fs(old_fs);
	if(len!= MAC_STR_LEN)
	wifimac_pos = strstr(dp, "WifiMac");
	if (!wifimac_pos)
	{
	{
		printk(KERN_INFO "Failed to read '%s'  %d  %s.\n", fn,len,dp );
		printk(KERN_INFO "Can't find wifimac\n'");
		goto err_format;
		goto err_format;
	}
	}

    strncpy(WifiMac, wifimac_pos+8, 17);
	dp[MAC_STR_LEN] = '\0';
	WifiMac[MAC_STR_LEN] = '\0';
	str2wa(dp, eaddr);
	str2wa(WifiMac, eaddr);

	filp_close(fp, NULL);
	filp_close(fp, NULL);
	return 0;
	return 0;