return ret;
}
- printf("node '%s' offset=%d\n", "display", off);
ret = fdt_subnode_offset(blob, off, subnode);
if (ret < 0) {
debug("Could not find node '%s' in FDT: %d\n", subnode, ret);
}
}
- printf("node '%s' offset=%d\n", subnode, ret);
ret = fdt_add_subnode(blob, ret, name);
if (ret < 0) {
printf("Failed to add %s subnode: %d\n", name, ret);
return ret;
}
-char *karo_fdt_set_display(char *video_mode, const char *lcd_path,
- const char *lvds_path)
+const char *karo_fdt_set_display(const char *video_mode, const char *lcd_path,
+ const char *lvds_path)
{
- char *vm;
+ static char buffer[128];
+ char *vm, *vmode = buffer;
int ret;
int off;
void *blob = (void *)gd->fdt_blob;
- if (video_mode == NULL)
+ if (video_mode == NULL || strlen(video_mode) == 0)
return NULL;
+ if (strlen(video_mode) >= sizeof(buffer)) {
+ printf("video_mode string too long\n");
+ return NULL;
+ }
+ strcpy(buffer, video_mode);
+
off = fdt_path_offset(blob, "/aliases");
ret = fdt_resize(blob);
if (ret < 0) {
printf("%s: Failed to resize FDT: %s\n",
__func__, fdt_strerror(ret));
}
- vm = strsep(&video_mode, ":");
+ vm = strsep(&vmode, ":");
if (off < 0) {
off = fdt_add_subnode(blob, off, "aliases");
if (off < 0) {
printf("%s: Failed to create 'aliases' node: %s\n",
__func__, fdt_strerror(off));
- return video_mode ?: vm;
+ return vmode ?: vm;
}
}
- if (video_mode != NULL) {
+ if (vmode != NULL) {
char display[strlen(lvds_path) + sizeof("/lvds-channel@x")];
strncpy(display, lvds_path, sizeof(display));
} else if (strcmp(vm, "LVDS1") == 0) {
strncat(display, "/lvds-channel@1", sizeof(display));
} else {
- printf("%s: Syntax error in video_mode\n",
- __func__);
- return video_mode;
+ debug("%s: Syntax error in video_mode\n", __func__);
+ return vmode;
}
ret = fdt_setprop_string(blob, off, "display", display);
debug("setprop_string(display='%s') returned %d\n", display, ret);
ret = fdt_set_node_status(blob, off,
FDT_STATUS_DISABLED, 0);
}
- video_mode = vm;
+ vmode = vm;
}
if (ret) {
printf("%s: failed to set 'display' alias: %s\n",
__func__, fdt_strerror(ret));
}
- return video_mode;
+ return vmode;
}
int karo_fdt_update_fb_mode(void *blob, const char *name)
int karo_fdt_update_fb_mode(void *blob, const char *name);
int karo_fdt_create_fb_mode(void *blob, const char *name,
struct fb_videomode *mode);
-char *karo_fdt_set_display(char *video_mode, const char *lcd_path,
- const char *lvds_path);
+const char *karo_fdt_set_display(const char *video_mode, const char *lcd_path,
+ const char *lvds_path);
#else
static inline void karo_fdt_remove_node(void *blob, const char *node)
{
{
return 0;
}
-static inline char *karo_fdt_set_display(char *video_mode, const char *lcd_path,
+static inline const char *karo_fdt_set_display(const char *video_mode, const char *lcd_path,
const char *lvds_path)
{
return video_mode;
void lcd_ctrl_init(void *lcdbase)
{
int color_depth = 24;
- char *video_mode = getenv("video_mode");
- char *vm;
+ const char *video_mode = getenv("video_mode");
+ const char *vm;
unsigned long val;
int refresh = 60;
struct fb_videomode *p = &tx53_fb_modes[0];
if (p != &fb_mode) {
int ret;
- printf("Creating new display-timing node from '%s'\n",
+ debug("Creating new display-timing node from '%s'\n",
video_mode);
ret = karo_fdt_create_fb_mode(working_fdt, video_mode, p);
if (ret)
{
const char *baseboard = getenv("baseboard");
int stk5_v5 = baseboard != NULL && (strcmp(baseboard, "stk5-v5") == 0);
- char *video_mode = getenv("video_mode");
+ const char *video_mode = getenv("video_mode");
fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes));
fdt_fixup_ethernet(blob);
void lcd_ctrl_init(void *lcdbase)
{
int color_depth = 24;
- char *video_mode = getenv("video_mode");
- char *vm;
+ const char *video_mode = getenv("video_mode");
+ const char *vm;
unsigned long val;
int refresh = 60;
struct fb_videomode *p = &tx6_fb_modes[0];
if (p != &fb_mode) {
int ret;
- printf("Creating new display-timing node from '%s'\n",
+ debug("Creating new display-timing node from '%s'\n",
video_mode);
ret = karo_fdt_create_fb_mode(working_fdt, video_mode, p);
if (ret)
{
const char *baseboard = getenv("baseboard");
int stk5_v5 = baseboard != NULL && (strcmp(baseboard, "stk5-v5") == 0);
- char *video_mode = getenv("video_mode");
+ const char *video_mode = getenv("video_mode");
karo_fdt_enable_node(blob, "stk5led", !stk5_v5);