@@ -449,6 +449,23 @@ static bool ps_wakeup(struct btnxpuart_dev *nxpdev)
449
449
return false;
450
450
}
451
451
452
+ static void ps_cleanup (struct btnxpuart_dev * nxpdev )
453
+ {
454
+ struct ps_data * psdata = & nxpdev -> psdata ;
455
+ u8 ps_state ;
456
+
457
+ mutex_lock (& psdata -> ps_lock );
458
+ ps_state = psdata -> ps_state ;
459
+ mutex_unlock (& psdata -> ps_lock );
460
+
461
+ if (ps_state != PS_STATE_AWAKE )
462
+ ps_control (psdata -> hdev , PS_STATE_AWAKE );
463
+
464
+ ps_cancel_timer (nxpdev );
465
+ cancel_work_sync (& psdata -> work );
466
+ mutex_destroy (& psdata -> ps_lock );
467
+ }
468
+
452
469
static int send_ps_cmd (struct hci_dev * hdev , void * data )
453
470
{
454
471
struct btnxpuart_dev * nxpdev = hci_get_drvdata (hdev );
@@ -1363,7 +1380,6 @@ static int btnxpuart_close(struct hci_dev *hdev)
1363
1380
{
1364
1381
struct btnxpuart_dev * nxpdev = hci_get_drvdata (hdev );
1365
1382
1366
- ps_wakeup (nxpdev );
1367
1383
serdev_device_close (nxpdev -> serdev );
1368
1384
skb_queue_purge (& nxpdev -> txq );
1369
1385
if (!IS_ERR_OR_NULL (nxpdev -> rx_skb )) {
@@ -1516,8 +1532,8 @@ static void nxp_serdev_remove(struct serdev_device *serdev)
1516
1532
nxpdev -> new_baudrate = nxpdev -> fw_init_baudrate ;
1517
1533
nxp_set_baudrate_cmd (hdev , NULL );
1518
1534
}
1519
- ps_cancel_timer (nxpdev );
1520
1535
}
1536
+ ps_cleanup (nxpdev );
1521
1537
hci_unregister_dev (hdev );
1522
1538
hci_free_dev (hdev );
1523
1539
}
0 commit comments