Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uboot_env.c: add flagstype field to yaml #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 46 additions & 18 deletions src/uboot_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ enum yaml_state {
STATE_NPATH,
STATE_NOFFSET,
STATE_NSECTORSIZE,
STATE_NFLAGSTYPE,
STATE_NUNLOCK,
STATE_STOP /* end state */
};
Expand Down Expand Up @@ -491,26 +492,28 @@ static int check_env_device(struct uboot_flash_env *dev)
}
}

switch (dev->device_type) {
case DEVICE_FILE:
dev->flagstype = FLAGS_INCREMENTAL;
break;
case DEVICE_MTD:
switch (dev->mtdinfo.type) {
case MTD_NORFLASH:
dev->flagstype = FLAGS_BOOLEAN;
if (dev->flagstype == FLAGS_NONE) {
switch (dev->device_type) {
case DEVICE_FILE:
dev->flagstype = FLAGS_INCREMENTAL;
break;
case MTD_NANDFLASH:
case DEVICE_MTD:
switch (dev->mtdinfo.type) {
case MTD_NORFLASH:
dev->flagstype = FLAGS_BOOLEAN;
break;
case MTD_NANDFLASH:
dev->flagstype = FLAGS_INCREMENTAL;
};
break;
case DEVICE_UBI:
dev->flagstype = FLAGS_INCREMENTAL;
break;
default:
close(fd);
return -EBADF;
};
break;
case DEVICE_UBI:
dev->flagstype = FLAGS_INCREMENTAL;
break;
default:
close(fd);
return -EBADF;
};
}

/*
* Check for negative offsets, treat it as backwards offset
Expand Down Expand Up @@ -1210,7 +1213,9 @@ static int consume_event(struct parser_state *s, yaml_event_t *event)
s->state = STATE_NOFFSET;
} else if (!strcmp(value, "sectorsize")) {
s->state = STATE_NSECTORSIZE;
} else if (!strcmp(value, "disablelock")) {
} else if (!strcmp(value, "flagstype")) {
s->state = STATE_NFLAGSTYPE;
} else if (!strcmp(value, "disablelock")) {
s->state = STATE_NUNLOCK;
} else {
s->error = YAML_UNEXPECTED_KEY;
Expand Down Expand Up @@ -1338,6 +1343,29 @@ static int consume_event(struct parser_state *s, yaml_event_t *event)
}
break;

case STATE_NFLAGSTYPE:
switch (event->type) {
case YAML_SCALAR_EVENT:
dev = &s->ctx->envdevs[s->cdev];
value = (char *)event->data.scalar.value;
if (!strcmp(value, "boolean")) {
dev->flagstype = FLAGS_BOOLEAN;
} else if (!strcmp(value, "incremental")) {
dev->flagstype = FLAGS_INCREMENTAL;
} else {
s->error = YAML_BAD_DEVNAME;
s->event_type = event->type;
return FAILURE;
}
s->state = STATE_DEVVALUES;
break;
default:
s->error = YAML_UNEXPECTED_STATE;
s->event_type = event->type;
return FAILURE;
}
break;

case STATE_NUNLOCK:
switch (event->type) {
case YAML_SCALAR_EVENT:
Expand Down