Skip to content

Commit

Permalink
drivers: adc: adc_ad559x: fix driver init
Browse files Browse the repository at this point in the history
k_thread_name_set() function returns an error if CONFIG_THREAD_NAME is
not enabled which may make the driver not functional.

Fix the issue by adding a check against CONFIG_THREAD_NAME avaliability
before calling k_thread_name_set() function so the driver can operate
properly with CONFIG_THREAD_NAME disabled.

(cherry picked from commit f565f4c)

Original-Signed-off-by: Lukasz Madej <l.madej@grinn-global.com>
GitOrigin-RevId: f565f4c
Change-Id: I0002f6f852c428103817ab43e0fdf578e1b80b65
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/5488597
Tested-by: ChromeOS Prod (Robot) <chromeos-ci-prod@chromeos-bot.iam.gserviceaccount.com>
Reviewed-by: Dawid Niedźwiecki <dawidn@google.com>
Commit-Queue: Dawid Niedźwiecki <dawidn@google.com>
Tested-by: Dawid Niedźwiecki <dawidn@google.com>
  • Loading branch information
LukaszMadejGrinn authored and Chromeos LUCI committed Apr 25, 2024
1 parent cb72512 commit 43ec3ea
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/adc/adc_ad559x.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,11 @@ static int adc_ad559x_init(const struct device *dev)
(k_thread_entry_t)adc_ad559x_acquisition_thread, data, NULL, NULL,
CONFIG_ADC_AD559X_ACQUISITION_THREAD_PRIO, 0, K_NO_WAIT);

ret = k_thread_name_set(tid, "adc_ad559x");
if (ret < 0) {
return ret;
if (IS_ENABLED(CONFIG_THREAD_NAME)) {
ret = k_thread_name_set(tid, "adc_ad559x");
if (ret < 0) {
return ret;
}
}

adc_context_unlock_unconditionally(&data->ctx);
Expand Down

0 comments on commit 43ec3ea

Please sign in to comment.