mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
BT: bt mac write [1/3]
PD#OTT-1590 Problem: bt mac write Solution: Accept the MAC address from uboot and create nodes Verify: Verifying on Public Edition P212 Change-Id: I77ff3543aff937adc07bf3a0933a350c27e9dd20 Signed-off-by: Qiu Zeng <qiu.zeng@amlogic.com>
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
#include <linux/amlogic/iomap.h>
|
||||
#include <linux/io.h>
|
||||
#include <linux/amlogic/bt_device.h>
|
||||
#include <linux/random.h>
|
||||
#ifdef CONFIG_AM_WIFI_SD_MMC
|
||||
#include <linux/amlogic/wifi_dt.h>
|
||||
#endif
|
||||
@@ -48,6 +49,48 @@ static struct early_suspend bt_early_suspend;
|
||||
|
||||
#define BT_RFKILL "bt_rfkill"
|
||||
|
||||
char bt_addr[18] = "";
|
||||
static struct class *bt_addr_class;
|
||||
static ssize_t bt_addr_show(struct class *cls,
|
||||
struct class_attribute *attr, char *_buf)
|
||||
{
|
||||
char local_addr[6];
|
||||
|
||||
if (!_buf)
|
||||
return -EINVAL;
|
||||
|
||||
if (strlen(bt_addr) == 0) {
|
||||
local_addr[0] = 0x22;
|
||||
local_addr[1] = 0x22;
|
||||
local_addr[2] = prandom_u32();
|
||||
local_addr[3] = prandom_u32();
|
||||
local_addr[4] = prandom_u32();
|
||||
local_addr[5] = prandom_u32();
|
||||
sprintf(bt_addr, "%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
local_addr[0], local_addr[1], local_addr[2],
|
||||
local_addr[3], local_addr[4], local_addr[5]);
|
||||
}
|
||||
|
||||
return sprintf(_buf, "%s\n", bt_addr);
|
||||
}
|
||||
static ssize_t bt_addr_store(struct class *cls,
|
||||
struct class_attribute *attr, const char __user *buf, size_t count)
|
||||
{
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (!buf)
|
||||
return ret;
|
||||
|
||||
snprintf(bt_addr, sizeof(bt_addr), "%s", buf);
|
||||
|
||||
if (bt_addr[strlen(bt_addr)-1] == '\n')
|
||||
bt_addr[strlen(bt_addr)-1] = '\0';
|
||||
|
||||
pr_info("bt_addr=%s\n", bt_addr);
|
||||
return count;
|
||||
}
|
||||
static CLASS_ATTR(value, 0644, bt_addr_show, bt_addr_store);
|
||||
|
||||
struct bt_dev_runtime_data {
|
||||
struct rfkill *bt_rfk;
|
||||
struct bt_dev_data *pdata;
|
||||
@@ -310,6 +353,9 @@ static int bt_probe(struct platform_device *pdev)
|
||||
#else
|
||||
pdata = (struct bt_dev_data *)(pdev->dev.platform_data);
|
||||
#endif
|
||||
bt_addr_class = class_create(THIS_MODULE, "bt_addr");
|
||||
ret = class_create_file(bt_addr_class, &class_attr_value);
|
||||
|
||||
bt_device_init(pdata);
|
||||
if (pdata->power_down_disable == 1) {
|
||||
pdata->power_down_disable = 0;
|
||||
@@ -453,3 +499,21 @@ module_exit(bt_exit);
|
||||
MODULE_DESCRIPTION("bt rfkill");
|
||||
MODULE_AUTHOR("");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
/**************** bt mac *****************/
|
||||
|
||||
static int __init mac_addr_set(char *line)
|
||||
{
|
||||
|
||||
if (line) {
|
||||
pr_info("try to read bt mac from emmc key!\n");
|
||||
strncpy(bt_addr, line, sizeof(bt_addr)-1);
|
||||
bt_addr[sizeof(bt_addr)-1] = '\0';
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
__setup("mac_bt=", mac_addr_set);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user