Skip to content

Commit

Permalink
[nrfconnect] Fix USB device initialization (#36747)
Browse files Browse the repository at this point in the history
Ensure proper initialization of the USB device by allowing the
`usb_enable` API to be called multiple times without errors.

Signed-off-by: Łukasz Duda <[email protected]>
  • Loading branch information
LuDuda authored Dec 6, 2024
1 parent 2be9877 commit 84fb78f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions examples/all-clusters-app/nrfconnect/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ static int InitUSB()
{
int err = usb_enable(nullptr);

if (err)
if ((err != 0) && (err != -EALREADY))
{
LOG_ERR("Failed to initialize USB device");
LOG_ERR("Failed to initialize USB device %d", err);
return err;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/all-clusters-minimal-app/nrfconnect/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ static int InitUSB()
{
int err = usb_enable(nullptr);

if (err)
if ((err != 0) && (err != -EALREADY))
{
LOG_ERR("Failed to initialize USB device");
LOG_ERR("Failed to initialize USB device %d", err);
return err;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/nrfconnect/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ static int InitUSB()
{
int err = usb_enable(nullptr);

if (err)
if ((err != 0) && (err != -EALREADY))
{
LOG_ERR("Failed to initialize USB device");
LOG_ERR("Failed to initialize USB device %d", err);
return err;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern "C" void pw_sys_io_Init()

#ifdef CONFIG_USB
err = usb_enable(nullptr);
assert(err == 0);
assert(err == 0 || err == (-EALREADY));
#endif

err = console_init();
Expand Down

0 comments on commit 84fb78f

Please sign in to comment.