From patchwork Thu Jun 23 04:58:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guodong Xu X-Patchwork-Id: 9194457 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C7C7D6075A for ; Thu, 23 Jun 2016 05:01:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B92CE28428 for ; Thu, 23 Jun 2016 05:01:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC31C2842D; Thu, 23 Jun 2016 05:01:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B43C28428 for ; Thu, 23 Jun 2016 05:01:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bFwjw-0002Nt-Fw; Thu, 23 Jun 2016 04:59:44 +0000 Received: from mail-pf0-x236.google.com ([2607:f8b0:400e:c00::236]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bFwju-0002Mo-FB for linux-arm-kernel@lists.infradead.org; Thu, 23 Jun 2016 04:59:43 +0000 Received: by mail-pf0-x236.google.com with SMTP id t190so24698830pfb.3 for ; Wed, 22 Jun 2016 21:59:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=TJ9sawmGL3DQLXwLdvy+iKXThTg6VT16yLGq0e7BcU4=; b=GXzv27NaCtEmT7gdlAvrBiWAdfN6nDbLAAOvPPBMx1CBrxLLvD1cjgBisiLArTE+xk od9QiS4Lo2fUF+16NeYDgCNtwk/DTt45KoGfMRUVJKFx/bp7GB5e/5sdiI3WZZTLSXke WMVu1ZpxNxsn7Eu7uwdBX1G4aaVWByAWUMCG0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TJ9sawmGL3DQLXwLdvy+iKXThTg6VT16yLGq0e7BcU4=; b=dnfQabJ6FXqI/uCfEUb5SqISn3agdqHC/AMWH/9iH2qoJ5ugAo7Dd46vvKErFCs3Ha y2ZveEdm40zxKL444QGM8MbgCwEZC0zAyC7Rv6X2qCsqHYHg2vfY8AY63UdDsXdBGxvW Tbw8NSQRECmqAJ+jMBfWWgaxCcoeMl82ax4kVTPHMhjuie5lAXrO5fTabK4sAzLQRIba xqb7fs7owhNrZul7DlZQEpOm25Vs3TqJv+9QUgnTzCTl3vty6l0ymgvnMaQ5iJ03H2kK MavAAAzVcHW9vlAlXrZwLDiGWZiyuaS9nWtJJuC0QAYv9nfL4n/bNumi03pQ5fXlS9x+ r35g== X-Gm-Message-State: ALyK8tKk8YKR10hFgFUvK/H9W3ONt7NCXAB5Gb1X+IfxCaLv8cXle+fYHFGB30Eg3WhMIfiX X-Received: by 10.98.68.84 with SMTP id r81mr40167045pfa.26.1466657961072; Wed, 22 Jun 2016 21:59:21 -0700 (PDT) Received: from localhost.localdomain ([45.56.152.22]) by smtp.gmail.com with ESMTPSA id bt5sm3435099pac.47.2016.06.22.21.59.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 22 Jun 2016 21:59:20 -0700 (PDT) From: Guodong Xu To: marcel@holtmann.org, gustavo@padovan.org, johan.hedberg@gmail.com, davem@davemloft.net, xuwei5@hisilicon.com, robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com, ijc+devicetree@hellion.org.uk, galak@codeaurora.org, catalin.marinas@arm.com, will.deacon@arm.com, haojian.zhuang@linaro.org, linus.walleij@linaro.org, tony@atomide.com Subject: [PATCH 1/2] Bluetooth: Add LED triggers for HCI frames tx and rx Date: Thu, 23 Jun 2016 12:58:42 +0800 Message-Id: <1466657923-5776-1-git-send-email-guodong.xu@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160622_215942_547153_EA331CDB X-CRM114-Status: GOOD ( 13.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Guodong Xu , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Two LED triggers are defined: tx_led and rx_led. Upon frames available in HCI core layer, for tx or for rx, the combined LED can blink. Verified on HiKey, 96boards. It uses hi6220 SoC and TI WL1835 combo chip. Signed-off-by: Guodong Xu --- include/net/bluetooth/hci_core.h | 1 + net/bluetooth/hci_core.c | 3 +++ net/bluetooth/leds.c | 15 +++++++++++++++ net/bluetooth/leds.h | 2 ++ 4 files changed, 21 insertions(+) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index dc71473..37b8dd9 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -398,6 +398,7 @@ struct hci_dev { bdaddr_t rpa; struct led_trigger *power_led; + struct led_trigger *tx_led, *rx_led; int (*open)(struct hci_dev *hdev); int (*close)(struct hci_dev *hdev); diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 45a9fc6..c6e1210 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c @@ -3248,6 +3248,7 @@ int hci_recv_frame(struct hci_dev *hdev, struct sk_buff *skb) skb_queue_tail(&hdev->rx_q, skb); queue_work(hdev->workqueue, &hdev->rx_work); + hci_leds_blink_oneshot(hdev->rx_led); return 0; } EXPORT_SYMBOL(hci_recv_frame); @@ -3325,6 +3326,8 @@ static void hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb) BT_ERR("%s sending frame failed (%d)", hdev->name, err); kfree_skb(skb); } + + hci_leds_blink_oneshot(hdev->tx_led); } /* Send HCI command */ diff --git a/net/bluetooth/leds.c b/net/bluetooth/leds.c index 8319c84..c4825d5 100644 --- a/net/bluetooth/leds.c +++ b/net/bluetooth/leds.c @@ -19,6 +19,8 @@ struct hci_basic_led_trigger { #define to_hci_basic_led_trigger(arg) container_of(arg, \ struct hci_basic_led_trigger, led_trigger) +#define BLUETOOTH_BLINK_DELAY 50 /* ms */ + void hci_leds_update_powered(struct hci_dev *hdev, bool enabled) { if (hdev->power_led) @@ -37,6 +39,15 @@ static void power_activate(struct led_classdev *led_cdev) led_trigger_event(led_cdev->trigger, powered ? LED_FULL : LED_OFF); } +void hci_leds_blink_oneshot(struct led_trigger *trig) +{ + unsigned long led_delay = BLUETOOTH_BLINK_DELAY; + + if (!trig) + return; + led_trigger_blink_oneshot(trig, &led_delay, &led_delay, 0); +} + static struct led_trigger *led_allocate_basic(struct hci_dev *hdev, void (*activate)(struct led_classdev *led_cdev), const char *name) @@ -71,4 +82,8 @@ void hci_leds_init(struct hci_dev *hdev) { /* initialize power_led */ hdev->power_led = led_allocate_basic(hdev, power_activate, "power"); + /* initialize tx_led */ + hdev->tx_led = led_allocate_basic(hdev, NULL, "tx"); + /* initialize rx_led */ + hdev->rx_led = led_allocate_basic(hdev, NULL, "rx"); } diff --git a/net/bluetooth/leds.h b/net/bluetooth/leds.h index a9c4d6e..9b1cccd 100644 --- a/net/bluetooth/leds.h +++ b/net/bluetooth/leds.h @@ -9,8 +9,10 @@ #if IS_ENABLED(CONFIG_BT_LEDS) void hci_leds_update_powered(struct hci_dev *hdev, bool enabled); void hci_leds_init(struct hci_dev *hdev); +void hci_leds_blink_oneshot(struct led_trigger *trig); #else static inline void hci_leds_update_powered(struct hci_dev *hdev, bool enabled) {} static inline void hci_leds_init(struct hci_dev *hdev) {} +static inline void hci_leds_blink_oneshot(struct led_trigger *trig) {} #endif