Skip to content

Commit effe4bb

Browse files
ndrs-pstnashif
authored andcommitted
fb: cfb_shell: remove dev null check
Remove `dev` null check as `DEVICE_DT_GET` ensures compile-time initialization. Refer to commit 6eb371f (fb: initialize devices at compile time) Signed-off-by: Pisit Sawangvonganan <[email protected]>
1 parent cff8b60 commit effe4bb

File tree

1 file changed

+0
-100
lines changed

1 file changed

+0
-100
lines changed

subsys/fb/cfb_shell.c

-100
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ static int cmd_clear(const struct shell *sh, size_t argc, char *argv[])
3535
ARG_UNUSED(argc);
3636
ARG_UNUSED(argv);
3737

38-
if (!dev) {
39-
shell_error(sh, HELP_INIT);
40-
return -ENODEV;
41-
}
42-
4338
err = cfb_framebuffer_clear(dev, true);
4439
if (err) {
4540
shell_error(sh, "Framebuffer clear error=%d", err);
@@ -62,11 +57,6 @@ static int cmd_cfb_print(const struct shell *sh, int col, int row, char *str)
6257
int err;
6358
uint8_t ppt;
6459

65-
if (!dev) {
66-
shell_error(sh, HELP_INIT);
67-
return -ENODEV;
68-
}
69-
7060
ppt = cfb_get_display_parameter(dev, CFB_DISPLAY_PPT);
7161

7262
err = cfb_framebuffer_clear(dev, false);
@@ -97,11 +87,6 @@ static int cmd_print(const struct shell *sh, size_t argc, char *argv[])
9787
int err;
9888
int col, row;
9989

100-
if (!dev) {
101-
shell_error(sh, HELP_INIT);
102-
return -ENODEV;
103-
}
104-
10590
col = strtol(argv[1], NULL, 10);
10691
if (col > cfb_get_display_parameter(dev, CFB_DISPLAY_COLS)) {
10792
shell_error(sh, "Invalid col=%d position", col);
@@ -128,11 +113,6 @@ static int cmd_draw_text(const struct shell *sh, size_t argc, char *argv[])
128113
int err;
129114
int x, y;
130115

131-
if (!dev) {
132-
shell_error(sh, HELP_INIT);
133-
return -ENODEV;
134-
}
135-
136116
x = strtol(argv[1], NULL, 10);
137117
y = strtol(argv[2], NULL, 10);
138118
err = cfb_draw_text(dev, argv[3], x, y);
@@ -151,11 +131,6 @@ static int cmd_draw_point(const struct shell *sh, size_t argc, char *argv[])
151131
int err;
152132
struct cfb_position pos;
153133

154-
if (!dev) {
155-
shell_error(sh, HELP_INIT);
156-
return -ENODEV;
157-
}
158-
159134
pos.x = strtol(argv[1], NULL, 10);
160135
pos.y = strtol(argv[2], NULL, 10);
161136

@@ -175,11 +150,6 @@ static int cmd_draw_line(const struct shell *sh, size_t argc, char *argv[])
175150
int err;
176151
struct cfb_position start, end;
177152

178-
if (!dev) {
179-
shell_error(sh, HELP_INIT);
180-
return -ENODEV;
181-
}
182-
183153
start.x = strtol(argv[1], NULL, 10);
184154
start.y = strtol(argv[2], NULL, 10);
185155
end.x = strtol(argv[3], NULL, 10);
@@ -201,11 +171,6 @@ static int cmd_draw_rect(const struct shell *sh, size_t argc, char *argv[])
201171
int err;
202172
struct cfb_position start, end;
203173

204-
if (!dev) {
205-
shell_error(sh, HELP_INIT);
206-
return -ENODEV;
207-
}
208-
209174
start.x = strtol(argv[1], NULL, 10);
210175
start.y = strtol(argv[2], NULL, 10);
211176
end.x = strtol(argv[3], NULL, 10);
@@ -228,11 +193,6 @@ static int cmd_scroll_vert(const struct shell *sh, size_t argc, char *argv[])
228193
int col, row;
229194
int boundary;
230195

231-
if (!dev) {
232-
shell_error(sh, HELP_INIT);
233-
return -ENODEV;
234-
}
235-
236196
col = strtol(argv[1], NULL, 10);
237197
if (col > cfb_get_display_parameter(dev, CFB_DISPLAY_COLS)) {
238198
shell_error(sh, "Invalid col=%d position", col);
@@ -269,11 +229,6 @@ static int cmd_scroll_horz(const struct shell *sh, size_t argc, char *argv[])
269229
int col, row;
270230
int boundary;
271231

272-
if (!dev) {
273-
shell_error(sh, HELP_INIT);
274-
return -ENODEV;
275-
}
276-
277232
col = strtol(argv[1], NULL, 10);
278233
if (col > cfb_get_display_parameter(dev, CFB_DISPLAY_COLS)) {
279234
shell_error(sh, "Invalid col=%d position", col);
@@ -312,11 +267,6 @@ static int cmd_set_font(const struct shell *sh, size_t argc, char *argv[])
312267
uint8_t height;
313268
uint8_t width;
314269

315-
if (!dev) {
316-
shell_error(sh, HELP_INIT);
317-
return -ENODEV;
318-
}
319-
320270
idx = strtol(argv[1], NULL, 10);
321271

322272
err = cfb_get_font_size(dev, idx, &width, &height);
@@ -343,11 +293,6 @@ static int cmd_set_kerning(const struct shell *sh, size_t argc, char *argv[])
343293
int err = 0;
344294
long kerning;
345295

346-
if (!dev) {
347-
shell_error(sh, HELP_INIT);
348-
return -ENODEV;
349-
}
350-
351296
kerning = shell_strtol(argv[1], 10, &err);
352297
if (err) {
353298
shell_error(sh, HELP_INIT);
@@ -367,11 +312,6 @@ static int cmd_invert(const struct shell *sh, size_t argc, char *argv[])
367312
{
368313
int err;
369314

370-
if (!dev) {
371-
shell_error(sh, HELP_INIT);
372-
return -ENODEV;
373-
}
374-
375315
if (argc == 1) {
376316
err = cfb_framebuffer_invert(dev);
377317
if (err) {
@@ -412,11 +352,6 @@ static int cmd_get_fonts(const struct shell *sh, size_t argc, char *argv[])
412352
ARG_UNUSED(argc);
413353
ARG_UNUSED(argv);
414354

415-
if (!dev) {
416-
shell_error(sh, HELP_INIT);
417-
return -ENODEV;
418-
}
419-
420355
for (int idx = 0; idx < cfb_get_numof_fonts(dev); idx++) {
421356
if (cfb_get_font_size(dev, idx, &font_width, &font_height)) {
422357
break;
@@ -435,11 +370,6 @@ static int cmd_get_device(const struct shell *sh, size_t argc, char *argv[])
435370
ARG_UNUSED(argc);
436371
ARG_UNUSED(argv);
437372

438-
if (!dev) {
439-
shell_error(sh, HELP_INIT);
440-
return -ENODEV;
441-
}
442-
443373
shell_print(sh, "Framebuffer Device: %s", dev->name);
444374

445375
return err;
@@ -451,11 +381,6 @@ static int cmd_get_param_all(const struct shell *sh, size_t argc,
451381
ARG_UNUSED(argc);
452382
ARG_UNUSED(argv);
453383

454-
if (!dev) {
455-
shell_error(sh, HELP_INIT);
456-
return -ENODEV;
457-
}
458-
459384
for (unsigned int i = 0; i <= CFB_DISPLAY_COLS; i++) {
460385
shell_print(sh, "param: %s=%d", param_name[i],
461386
cfb_get_display_parameter(dev, i));
@@ -471,11 +396,6 @@ static int cmd_get_param_height(const struct shell *sh, size_t argc,
471396
ARG_UNUSED(argc);
472397
ARG_UNUSED(argv);
473398

474-
if (!dev) {
475-
shell_error(sh, HELP_INIT);
476-
return -ENODEV;
477-
}
478-
479399
shell_print(sh, "param: %s=%d", param_name[CFB_DISPLAY_HEIGH],
480400
cfb_get_display_parameter(dev, CFB_DISPLAY_HEIGH));
481401

@@ -488,11 +408,6 @@ static int cmd_get_param_width(const struct shell *sh, size_t argc,
488408
ARG_UNUSED(argc);
489409
ARG_UNUSED(argv);
490410

491-
if (!dev) {
492-
shell_error(sh, HELP_INIT);
493-
return -ENODEV;
494-
}
495-
496411
shell_print(sh, "param: %s=%d", param_name[CFB_DISPLAY_WIDTH],
497412
cfb_get_display_parameter(dev, CFB_DISPLAY_WIDTH));
498413

@@ -505,11 +420,6 @@ static int cmd_get_param_ppt(const struct shell *sh, size_t argc,
505420
ARG_UNUSED(argc);
506421
ARG_UNUSED(argv);
507422

508-
if (!dev) {
509-
shell_error(sh, HELP_INIT);
510-
return -ENODEV;
511-
}
512-
513423
shell_print(sh, "param: %s=%d", param_name[CFB_DISPLAY_PPT],
514424
cfb_get_display_parameter(dev, CFB_DISPLAY_PPT));
515425

@@ -522,11 +432,6 @@ static int cmd_get_param_rows(const struct shell *sh, size_t argc,
522432
ARG_UNUSED(argc);
523433
ARG_UNUSED(argv);
524434

525-
if (!dev) {
526-
shell_error(sh, HELP_INIT);
527-
return -ENODEV;
528-
}
529-
530435
shell_print(sh, "param: %s=%d", param_name[CFB_DISPLAY_ROWS],
531436
cfb_get_display_parameter(dev, CFB_DISPLAY_ROWS));
532437

@@ -539,11 +444,6 @@ static int cmd_get_param_cols(const struct shell *sh, size_t argc,
539444
ARG_UNUSED(argc);
540445
ARG_UNUSED(argv);
541446

542-
if (!dev) {
543-
shell_error(sh, HELP_INIT);
544-
return -ENODEV;
545-
}
546-
547447
shell_print(sh, "param: %s=%d", param_name[CFB_DISPLAY_COLS],
548448
cfb_get_display_parameter(dev, CFB_DISPLAY_COLS));
549449

0 commit comments

Comments
 (0)