Skip to contentSkip to conversation

Bluetooth: btmrvl: add sysfs commands gpiogap and hscfgcmd

PATCH In review Amitkumar Karwar 2 participants 4 messages Nov 26, 2015 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: btmrvl: add sysfs commands gpiogap and hscfgcmd

From: Xinming Hu <[email protected]>

This patch adds support for driver's internal host sleep configuration via sysfs. gpiogap and hscfgcmd sysfs commands are added for this purpose.

Examples.
1. Get current gpiogap
cat /sys/class/bluetooth/hci0/gpiogap
2. Set gpio as 13 and gap as 100msecs
echo "0x0d64" > /sys/class/bluetooth/hci0/gpiogap
3. Download host sleep configuration to firmware. echo "1" > /sys/class/bluetooth/hci0/hscfgcmd

---
 drivers/bluetooth/Makefile       |   1 +
 drivers/bluetooth/btmrvl_drv.h   |   3 +
 drivers/bluetooth/btmrvl_main.c  |   2 +
 drivers/bluetooth/btmrvl_sysfs.c | 121 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 127 insertions(+)
 create mode 100644 drivers/bluetooth/btmrvl_sysfs.c
drivers/bluetooth/Makefile +1 -0
index 07c9cf3..d0fd0b1 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_BT_QCA)		+= btqca.o
 
 btmrvl-y			:= btmrvl_main.o
 btmrvl-$(CONFIG_DEBUG_FS)	+= btmrvl_debugfs.o
+btmrvl-y           += btmrvl_sysfs.o
 
 hci_uart-y				:= hci_ldisc.o
 hci_uart-$(CONFIG_BT_HCIUART_H4)	+= hci_h4.o
drivers/bluetooth/btmrvl_drv.h +3 -0
index 27a9aac..0fc0e7d 100644
@@ -174,6 +174,9 @@ int btmrvl_prepare_command(struct btmrvl_private *priv);
 int btmrvl_enable_hs(struct btmrvl_private *priv);
 void btmrvl_firmware_dump(struct btmrvl_private *priv);
 
+int btmrvl_sysfs_register(struct btmrvl_private *priv);
+void btmrvl_sysfs_unregister(struct btmrvl_private *priv);
+
 #ifdef CONFIG_DEBUG_FS
 void btmrvl_debugfs_init(struct hci_dev *hdev);
 void btmrvl_debugfs_remove(struct hci_dev *hdev);
drivers/bluetooth/btmrvl_main.c +2 -0
index f2b38c8..6a8faa2 100644
@@ -693,6 +693,7 @@ int btmrvl_register_hdev(struct btmrvl_private *priv)
 #ifdef CONFIG_DEBUG_FS
 	btmrvl_debugfs_init(hdev);
 #endif
+	btmrvl_sysfs_register(priv);
 
 	return 0;
 
@@ -768,6 +769,7 @@ int btmrvl_remove_card(struct btmrvl_private *priv)
 #ifdef CONFIG_DEBUG_FS
 	btmrvl_debugfs_remove(hdev);
 #endif
+	btmrvl_sysfs_unregister(priv);
 
 	hci_unregister_dev(hdev);
 
drivers/bluetooth/btmrvl_sysfs.c new file +121 -0

121 lines not on this page · raw message

Signature · 1 line
1.8.1.4
maintainer
#1 lore raw

Hi Amitkumar,

Quoted 11 lines

This patch adds support for driver's internal host sleep configuration via sysfs. gpiogap and hscfgcmd sysfs commands are added for this purpose.

Examples.
1. Get current gpiogap
cat /sys/class/bluetooth/hci0/gpiogap
2. Set gpio as 13 and gap as 100msecs
echo "0x0d64" > /sys/class/bluetooth/hci0/gpiogap
3. Download host sleep configuration to firmware. echo "1" > /sys/class/bluetooth/hci0/hscfgcmd

explain to me how this is a good API. Keep in mind this is an userspace API and needs to be stable.

If you want to expose a GPIO, why not expose it through the standard Linux kernel GPIO API. Then it becomes easily discoverable via standard sysfs tools. Also you can use standard tools to modify it.

I also do not understand why you need something to set host sleep configuration. Just do this all the time and be done with it.

Regards

Marcel

#2 lore raw

Hi Marcel,

Quoted 20 lines

From: Marcel Holtmann [mailto:[email protected]]
Sent: Thursday, November 26, 2015 6:37 PM
To: Amitkumar Karwar
Cc: [email protected]; Cathy Luo; Xinming Hu
Subject: Re: [PATCH] Bluetooth: btmrvl: add sysfs commands gpiogap and hscfgcmd
=20
Hi Amitkumar,
=20

Quoted 11 lines

This patch adds support for driver's internal host sleep configuration via sysfs. gpiogap and hscfgcmd sysfs commands are added for this purpose.

Examples.
1. Get current gpiogap
cat /sys/class/bluetooth/hci0/gpiogap 2. Set gpio as 13 and gap as
100msecs
echo "0x0d64" > /sys/class/bluetooth/hci0/gpiogap 3. Download host
sleep configuration to firmware.
echo "1" > /sys/class/bluetooth/hci0/hscfgcmd

Quoted 10 lines

=20
explain to me how this is a good API. Keep in mind this is an userspace API and needs to be stable.
=20
If you want to expose a GPIO, why not expose it through the standard Linux kernel GPIO API. Then it becomes easily discoverable via standard sysfs tools. Also you can use standard tools to modify it. =20
I also do not understand why you need something to set host sleep configuration. Just do this all the time and be done with it.

Thanks for the review.=20
I wasn't aware about standard linux kernel GPIO API. I will go through belo= w link and check how we can make use of it.
http://lxr.free-electrons.com/source/Documentation/gpio/sysfs.txt

Basically we have gpiogap and hscfgcmd debugfs commands. As production kern= el doesn't enable CONFIG_DEBUGFS, we tried to do same thing via sysfs.

Regards,
Amitkumar

maintainer
#3 lore raw

Hi Amitkumar,

Quoted 19 lines
Quoted 19 lines
Quoted 11 lines

This patch adds support for driver's internal host sleep configuration via sysfs. gpiogap and hscfgcmd sysfs commands are added for this purpose.

Examples.
1. Get current gpiogap
cat /sys/class/bluetooth/hci0/gpiogap 2. Set gpio as 13 and gap as
100msecs
echo "0x0d64" > /sys/class/bluetooth/hci0/gpiogap 3. Download host
sleep configuration to firmware.
echo "1" > /sys/class/bluetooth/hci0/hscfgcmd

explain to me how this is a good API. Keep in mind this is an userspace API and needs to be stable.

If you want to expose a GPIO, why not expose it through the standard Linux kernel GPIO API. Then it becomes easily discoverable via standard sysfs tools. Also you can use standard tools to modify it.

Quoted 8 lines
Quoted 2 lines

I also do not understand why you need something to set host sleep configuration. Just do this all the time and be done with it.

Thanks for the review.
I wasn't aware about standard linux kernel GPIO API. I will go through below link and check how we can make use of it.
http://lxr.free-electrons.com/source/Documentation/gpio/sysfs.txt

Basically we have gpiogap and hscfgcmd debugfs commands. As production kernel doesn't enable CONFIG_DEBUGFS, we tried to do same thing via sysfs.

debugfs things are for testing / debugging purposes and should not be required in production. debugfs is also not an API guarantee. So you can change it any time. With sysfs that is no longer the case. And I am really careful letting any driver add any sysfs APIs.

If you are the first driver needing this, then you need a proper explanation why this would be needed at all. There is no driver / hardware from any manufacturer having the need for anything special exposed via sysfs.

Regards

Marcel