diff options
author | Linaro CI <ci_notify@linaro.org> | 2017-09-24 20:35:18 +0000 |
---|---|---|
committer | Linaro CI <ci_notify@linaro.org> | 2017-09-24 20:35:18 +0000 |
commit | c03adb6848aa7e80ad0c0e46b9f6d96ba0a91822 (patch) | |
tree | 05de08cd2d77fc5697e9e6fc1fae5ef23a1d0a85 /net/bluetooth/led.c | |
parent | 6ce85a78b6151e8ab2eac57e1447d90d3efb551d (diff) | |
parent | 357fdc8959dc79696d9c43c2a3f7a93e3a503d87 (diff) |
Merge remote-tracking branch 'sumit-lts/lts-4.4.y-hikey' into linux-4.4.y4.4.89-rc1-hikey-20170924
Diffstat (limited to 'net/bluetooth/led.c')
-rw-r--r-- | net/bluetooth/led.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/net/bluetooth/led.c b/net/bluetooth/led.c new file mode 100644 index 000000000000..1f53c1a5c195 --- /dev/null +++ b/net/bluetooth/led.c @@ -0,0 +1,72 @@ +/* + * Copyright 2015, Guodong Xu <guodong.xu@linaro.org> + * Copyright 2006, Johannes Berg <johannes@sipsolutions.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include <linux/slab.h> +#include "led.h" + +#define BLUETOOTH_BLINK_DELAY 50 /* ms */ + +void bluetooth_led_rx(struct hci_dev *hdev) +{ + unsigned long led_delay = BLUETOOTH_BLINK_DELAY; + if (unlikely(!hdev->rx_led)) + return; + led_trigger_blink_oneshot(hdev->rx_led, &led_delay, &led_delay, 0); +} +EXPORT_SYMBOL_GPL(bluetooth_led_rx); + +void bluetooth_led_tx(struct hci_dev *hdev) +{ + unsigned long led_delay = BLUETOOTH_BLINK_DELAY; + if (unlikely(!hdev->tx_led)) + return; + led_trigger_blink_oneshot(hdev->tx_led, &led_delay, &led_delay, 0); +} +EXPORT_SYMBOL_GPL(bluetooth_led_tx); + +void bluetooth_led_names(struct hci_dev *hdev) +{ + snprintf(hdev->rx_led_name, sizeof(hdev->rx_led_name), + "%srx", hdev->name); + snprintf(hdev->tx_led_name, sizeof(hdev->tx_led_name), + "%stx", hdev->name); +} + +void bluetooth_led_init(struct hci_dev *hdev) +{ + hdev->rx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); + if (hdev->rx_led) { + hdev->rx_led->name = hdev->rx_led_name; + if (led_trigger_register(hdev->rx_led)) { + kfree(hdev->rx_led); + hdev->rx_led = NULL; + } + } + + hdev->tx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); + if (hdev->tx_led) { + hdev->tx_led->name = hdev->tx_led_name; + if (led_trigger_register(hdev->tx_led)) { + kfree(hdev->tx_led); + hdev->tx_led = NULL; + } + } +} + +void bluetooth_led_exit(struct hci_dev *hdev) +{ + if (hdev->tx_led) { + led_trigger_unregister(hdev->tx_led); + kfree(hdev->tx_led); + } + if (hdev->rx_led) { + led_trigger_unregister(hdev->rx_led); + kfree(hdev->rx_led); + } +} |