fb: initialize devices at compile time

Initialize devices at compile time, allowing to constify device pointer.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas
2022-08-17 15:28:41 +02:00
parent 38448be57d
commit 6eb371ff4a

View File

@@ -19,7 +19,8 @@
#define HELP_INIT "call \"cfb init\" first"
#define HELP_PRINT "<col: pos> <row: pos> \"<text>\""
static const struct device *dev;
static const struct device *const dev =
DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
static const char * const param_name[] = {
"height", "width", "ppt", "rows", "cols"};
@@ -410,7 +411,6 @@ static int cmd_init(const struct shell *shell, size_t argc, char *argv[])
{
int err;
dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_display));
if (!device_is_ready(dev)) {
shell_error(shell, "Display device not ready");
return -ENODEV;