Hi Johan, >-----Original Message----- >From: Johan Hedberg [mailto:johan.hedberg@xxxxxxxxx] >Sent: Thursday, April 19, 2012 3:46 PM >To: Wang, Arron >Cc: linux-bluetooth@xxxxxxxxxxxxxxx >Subject: Re: [PATCH 2/2] rfkill: Set device powered even adapter is not created > >Hi, > >On Mon, Jan 16, 2012, Yu A Wang wrote: >> --- >> src/rfkill.c | 13 ++++++++++--- >> 1 files changed, 10 insertions(+), 3 deletions(-) >> >> diff --git a/src/rfkill.c b/src/rfkill.c index b40c6e7..5d32fac 100644 >> --- a/src/rfkill.c >> +++ b/src/rfkill.c >> @@ -128,11 +128,18 @@ static gboolean rfkill_event(GIOChannel *chan, >> if (id < 0) >> return TRUE; >> >> + DBG("RFKILL unblock for hci%d", id); >> + >> adapter = manager_find_adapter_by_id(id); >> - if (!adapter) >> + if (!adapter) { >> + /* >> + * If device is rfkilled, the initialize operation >> + * may failed and adapter is not created, then we >> + * need to set the device powered directly. >> + */ >> + adapter_ops_set_powered(id, TRUE); >> return TRUE; >> - >> - DBG("RFKILL unblock for hci%d", id); >> + } >> >> btd_adapter_restore_powered(adapter); > >This looks more like a workaround to another issue: if the kernel is aware of the >adapter but user space isn't it means that something has gone wrong during the >initialization process and *that* should be fixed instead of blindly attempting to >power on the adapter id anyway. Kernel works well and can detect the adapter, Bluetooth initialize failed due to when we init HCI device, we try to start the device, however the device is hardware/software rfkilled. From the code, we only init the adapter when the device is up, this result in the current code in rfkill.c can't bring up the device because adapter is NULL. Also only the kernel detected the device we can get the rfkill event, the code in rfkill.c also checked the device, then it is safe to power on the device in rfkill.c Thanks Arron
Attachment:
smime.p7s
Description: S/MIME cryptographic signature