bluetooth: Move the lower half null check to common place

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-01-18 04:07:37 +08:00 committed by Brennan Ashton
parent 9103184722
commit 7df322c6be
5 changed files with 23 additions and 27 deletions

View File

@ -75,25 +75,17 @@
int hciuart_dev_initialize(void)
{
const struct btuart_lowerhalf_s *lower;
int ret;
/* Perform one-time initialization */
hciuart_initialize();
/* Instantiate the HCI UART lower half interface */
/* Instantiate the HCI UART lower half interface
* Then initialize the HCI UART upper half driver with the bluetooth stack
*/
lower = hciuart_instantiate(HCIUART_SERDEV);
if (lower == NULL)
{
wlerr("ERROR: Failed to instantiate HCIUART%d\n", HCIUART_SERDEV + 1);
return -ENODEV;
}
/* Then initialize the HCI UART upper half driver with the bluetooth stack */
ret = btuart_register(lower);
ret = btuart_register(hciuart_instantiate(HCIUART_SERDEV));
if (ret < 0)
{
wlerr("ERROR: btuart_register() failed: %d\n", ret);

View File

@ -75,25 +75,17 @@
int hciuart_dev_initialize(void)
{
const struct btuart_lowerhalf_s *lower;
int ret;
/* Perform one-time initialization */
hciuart_initialize();
/* Instantiate the HCI UART lower half interface */
/* Instantiate the HCI UART lower half interface
* Then initialize the HCI UART upper half driver with the bluetooth stack
*/
lower = hciuart_instantiate(HCIUART_SERDEV);
if (lower == NULL)
{
wlerr("ERROR: Failed to instantiate HCIUART%d\n", HCIUART_SERDEV + 1);
return -ENODEV;
}
/* Then initialize the HCI UART upper half driver with the bluetooth stack */
ret = btuart_register(lower);
ret = btuart_register(hciuart_instantiate(HCIUART_SERDEV));
if (ret < 0)
{
wlerr("ERROR: btuart_register() failed: %d\n", ret);

View File

@ -416,7 +416,11 @@ int btuart_register(FAR const struct btuart_lowerhalf_s *lower)
wlinfo("lower %p\n", lower);
DEBUGASSERT(lower != NULL);
if (lower == NULL)
{
wlerr("ERROR: btuart lower half is NULL\n");
return -ENODEV;
}
/* Allocate a new instance of the upper half driver state structure */

View File

@ -181,7 +181,11 @@ int btuart_register(FAR const struct btuart_lowerhalf_s *lower)
wlinfo("lower %p\n", lower);
DEBUGASSERT(lower != NULL);
if (lower == NULL)
{
wlerr("ERROR: btuart lower half is NULL\n");
return -ENODEV;
}
/* Allocate a new instance of the upper half driver state structure */

View File

@ -75,7 +75,11 @@ int btuart_register(FAR const struct btuart_lowerhalf_s *lower)
wlinfo("lower %p\n", lower);
DEBUGASSERT(lower != NULL);
if (lower == NULL)
{
wlerr("ERROR: btuart lower half is NULL\n");
return -ENODEV;
}
/* Allocate a new instance of the upper half driver state structure */