From 6924014484d3406e3d2da384efc20e40e8a5ae80 Mon Sep 17 00:00:00 2001
From: Jacky Cheung <jackyc@google.com>
Date: Mon, 25 Jan 2016 15:31:28 -0800
Subject: [PATCH] Fix issue with Rfkill core and Nitrous BT power states out of
 sync.

Tidy up the initial states of both Rfkill and Nitrous to be blocked
(powered down) initially.  There was a mismatch in the states of
these two components that caused the rfkill_resume() to power the BT
back on erroneously when it should be stayed off.

Change-Id: I44ae0c58d697122475a5df77d5e015a6059000e0
---
 drivers/bluetooth/nitrous.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/bluetooth/nitrous.c b/drivers/bluetooth/nitrous.c
index 24ec6efe86f5..f9c7d4638ec9 100644
--- a/drivers/bluetooth/nitrous.c
+++ b/drivers/bluetooth/nitrous.c
@@ -383,14 +383,13 @@ static int nitrous_rfkill_init(struct platform_device *pdev,
 		goto err_rfkill_alloc;
 	}
 
+	/* Make sure rfkill core is initialized to be blocked initially. */
+	rfkill_init_sw_state(lpm->rfkill, true);
 	rc = rfkill_register(lpm->rfkill);
 	if (unlikely(rc))
 		goto err_rfkill_register;
 
-	rfkill_set_states(lpm->rfkill, true, false);
-	/* Set blocked state to false, so the call to
-	   bt_rfkill_set_power can run and set blocked to true */
-	lpm->rfkill_blocked = false;
+	/* Power off chip at startup. */
 	nitrous_rfkill_set_power(lpm, true);
 	return 0;
 
-- 
GitLab