X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=drivers%2Fbluetooth%2Fvflash.c;h=bb37c739571860becfe89a706b3e54a44890dec7;hb=425dd637bb81aa66033adb93356976c393fa021a;hp=5987d9212a52ff73415378d1afee75fc9fc0f334;hpb=b0132ed08d94a0b9a7ede245263e412ee60ae4e8;p=firefly-linux-kernel-4.4.55.git diff --git a/drivers/bluetooth/vflash.c b/drivers/bluetooth/vflash.c index 5987d9212a52..bb37c7395718 100755 --- a/drivers/bluetooth/vflash.c +++ b/drivers/bluetooth/vflash.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #if 0 @@ -31,12 +32,12 @@ static struct miscdevice vflash_miscdev; #define READ_BDADDR_FROM_FLASH 0x01 extern char GetSNSectorInfo(char * pbuf); +extern unsigned char wlan_mac_addr[6]; -static int vflash_ioctl(struct inode *inode, struct file *file, +static long vflash_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; - unsigned long n = 0; DBG("%s---cmd=0x%x---arg=0x%x\n", __FUNCTION__, cmd, arg); @@ -47,8 +48,37 @@ static int vflash_ioctl(struct inode *inode, struct file *file, { case READ_BDADDR_FROM_FLASH: { +#ifdef CONFIG_WIFI_MAC + unsigned char bd_addr[6] = {0}; + int i; + + printk("vflash: wlan_mac_addr:%X:%X:%X:%x:%X:%x\n", wlan_mac_addr[0], + wlan_mac_addr[1], + wlan_mac_addr[2], + wlan_mac_addr[3], + wlan_mac_addr[4], + wlan_mac_addr[5] ); + for (i=1; i<6; i++) { + bd_addr[i] = wlan_mac_addr[5-i]; + } + + bd_addr[0] = wlan_mac_addr[5]+1; + + printk("vflash: bd_addr:%X:%X:%X:%x:%X:%x\n", bd_addr[5], + bd_addr[4], + bd_addr[3], + bd_addr[2], + bd_addr[1], + bd_addr[0] ); + + + if(copy_to_user(argp, bd_addr, 6)) { + printk("ERROR: copy_to_user---%s\n", __FUNCTION__); + return -EFAULT; + } +#else char *tempBuf = (char *)kmalloc(512, GFP_KERNEL); - char bd_addr[6] = {0}; + char bd_addr[7] = {0}; int i; GetSNSectorInfo(tempBuf); @@ -60,14 +90,17 @@ static int vflash_ioctl(struct inode *inode, struct file *file, } + //printk("%s: ====> get bt addr from flash=[%02x:%02x:%02x:%02x:%02x:%02x]\n", __FUNCTION__, + // bd_addr[5], bd_addr[4], bd_addr[3], bd_addr[2], bd_addr[1], bd_addr[0]); if(copy_to_user(argp, bd_addr, 6)) - { - printk("ERROR: copy_to_user---%s\n", __FUNCTION__); + { + printk("ERROR: copy_to_user---%s\n", __FUNCTION__); kfree(tempBuf); - return -EFAULT; + return -EFAULT; } kfree(tempBuf); +#endif } break; default: @@ -92,7 +125,7 @@ static int vflash_release(struct inode *inode, struct file *file) static const struct file_operations vflash_fops = { .owner = THIS_MODULE, - .ioctl = vflash_ioctl, + .unlocked_ioctl = vflash_ioctl, .open = vflash_open, .release = vflash_release, };