Please review and upstream to bluetooth-next
flat view
From: G, Jaya P <hidden>
Date: 2016-07-15 06:33:50
Subsystem:
bluetooth drivers, the rest · Maintainers:
Marcel Holtmann, Luiz Augusto von Dentz, Linus Torvalds
Hi, Patch is for creating a kobject file from btusb which creates a file under kobject Which exposes HW Variant, FW Variant and Patch number for Intel specific SKU's Which is required to differentiate different chips from intel manufacturer. Please review and upstream the Patch to bluetooth-next.
From 01e904148f4de6d8d48d61b01b08da7a771fe998 Mon Sep 17 00:00:00 2001
From: Jaya Praveen G <redacted> Date: Fri, 15 Jul 2016 17:25:31 +0530 Subject: [PATCH] btusb: Export the Intel HW/FW/Patch variants to /sysfs Intel will have different SKU and version with the same VID/PID. Different SKU use different BT version this means different HW and FW. To check this, we have read version for the intel SKU which is unique, the same data is put in a file create with kobject in /sys/kernel/intel_hw_version_kobject/ with the name /intel_hw_version where it shows the HW variant, FW variant and Patch number which will different for each SKU. Signed-off-by: Jaya Praveen G <redacted> --- drivers/bluetooth/btusb.c | 57 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-)
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 811f9b9..720f14f 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c@@ -24,6 +24,10 @@#include <linux/module.h> #include <linux/usb.h> #include <linux/firmware.h> +#include <linux/kobject.h> +#include <linux/sysfs.h> +#include <linux/fs.h> +#include <linux/string.h> #include <asm/unaligned.h> #include <net/bluetooth/bluetooth.h>
@@ -42,6 +46,30 @@ static bool reset = true; static struct usb_driver btusb_driver; +static struct kobject *intel_hw_version_kobject; +struct intel_version ver; + +/* + * This file which is under /sys/kernel/intel_hw_version_kobject kobject which has the file name as intel_hw_version + * contains the intel FW version in terms of HW variant, FW variant and Patch number which are different for + * different SKU's. + */ +static ssize_t intel_hw_showrev(struct kobject *k, struct attribute *a, char *buf) +{ + return sprintf(buf, "HW_Variant: 0x%02x%02x%02x\nFW_variant: 0x%02x%02x%02x%02x%02x\nPatch Num: 0x%02x\n",ver.hw_platform, ver.hw_variant, ver.hw_revision, + ver.fw_variant, ver.fw_revision, ver.fw_build_num, + ver.fw_build_ww, ver.fw_build_yy, ver.fw_patch_num); +} + +/* Sysfs attributes made as user readable and writable*/ +static const struct { + struct attribute attr; + ssize_t (*show)(struct kobject *k, struct attribute *a, char *buf); +} intel_hw_version_attr = { + .attr = { .name = "intel_hw_version", .mode = S_IWUSR | S_IRUSR}, + .show = intel_hw_showrev, +}; +
#define BTUSB_IGNORE 0x01 #define BTUSB_DIGIANSWER 0x02 #define BTUSB_CSR 0x04
@@ -1655,7 +1683,7 @@ static int btusb_setup_intel(struct hci_dev *hdev) const struct firmware *fw; const u8 *fw_ptr; int disable_patch, err; - struct intel_version ver; + int error = 0; BT_DBG("%s", hdev->name);
@@ -1690,6 +1718,19 @@ static int btusb_setup_intel(struct hci_dev *hdev) ver.fw_variant, ver.fw_revision, ver.fw_build_num, ver.fw_build_ww, ver.fw_build_yy, ver.fw_patch_num); + /* Create a kobject with the name "intel_hw_version_kobject", located + * under /sys/kernel/. + */ + intel_hw_version_kobject = kobject_create_and_add("intel_hw_version_kobject", kernel_kobj); + if(!intel_hw_version_kobject) + return -ENOMEM; + + /* Create a file associated with the kobject */ + error = sysfs_create_file(intel_hw_version_kobject, &intel_hw_version_attr.attr); + if(error) { + BT_DBG("failed to create the version file in /sys/kernel/intel_hw_version_kobject \n"); + } + /* fw_patch_num indicates the version of patch the device currently * have. If there is no patch data in the device, it is always 0x00. * So, if it is other than 0x00, no need to patch the device again.
@@ -1974,7 +2015,6 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) 0x00, 0x08, 0x04, 0x00 }; struct btusb_data *data = hci_get_drvdata(hdev); struct sk_buff *skb; - struct intel_version ver; struct intel_boot_params *params; const struct firmware *fw; const u8 *fw_ptr;
@@ -1983,6 +2023,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) ktime_t calltime, delta, rettime; unsigned long long duration; int err; + int error = 0; BT_DBG("%s", hdev->name);
@@ -1996,6 +2037,18 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) if (err) return err; + /* Create a kobject with the name "intel_hw_version_kobject", located + * under /sys/kernel/. + */ + intel_hw_version_kobject = kobject_create_and_add("intel_hw_version_kobject", kernel_kobj); + if(!intel_hw_version_kobject) + return -ENOMEM; + + /* Create a file associated with the kobject */ + error = sysfs_create_file(intel_hw_version_kobject, &intel_hw_version_attr.attr); + if(error) { + BT_DBG("failed to create the version file in /sys/kernel/intel_hw_version_kobject \n"); + } /* The hardware platform number has a fixed value of 0x37 and * for now only accept this single value. */ --
1.9.1 Regards, Jaya Praveen G