Skip to content

flashmap default layout - #344

Open
edsj-sony wants to merge 3 commits into
linux-msm:masterfrom
edsj-sony:flashmap-default-layout
Open

edsj-sony wants to merge 3 commits into
linux-msm:masterfrom
edsj-sony:flashmap-default-layout

Conversation

@edsj-sony

@edsj-sony edsj-sony commented Oct 19, 2026 •

Copy link
Copy Markdown

When no selector is given and multiple layouts exist, select the one
marked with "default": true. The single-layout fallback is retained.
If several layouts are marked default, the first is chosen.

@edsj-sony
edsj-sony requested a review from a team as a code owner October 19, 2026 08:10
@edsj-sony
edsj-sony force-pushed the flashmap-default-layout branch from e54b016 to db1f4e7 Compare October 19, 2026 10:53

@igoropaniuk igoropaniuk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I've added some inline comments

Could you document the new key next to the existing layout selector text?

Comment thread src/flashmap.c Outdated
if (selector)
ux_err_tag(UX_TAG_FLASHMAP, "layout \"%s\" not found\n", selector);
else
ux_err_tag(UX_TAG_FLASHMAP, "no default layout found\n");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a hint for a user for this case, so he knows what to do? Something like multiple layouts found and none is marked default, select one with ::<layout>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread src/flashmap.c Outdated
ret = json_get_bool(layout, "default", &default_layout);
if (!selector && !ret && default_layout) {
ux_debug_tag(UX_TAG_FLASHMAP,
"flashmap: selected default layout: %s\n",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need for "flashmap:", UX_TAG_FLASHMAP already prints the FLASHMAP: prefix

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread src/flashmap.c
layout = json_get_element_object(layouts, i);
name = json_get_string(layout, "name");
if (name && !strcmp(name, selector)) {
ret = json_get_bool(layout, "default", &default_layout);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If several layouts are marked default, we silently take the first.

That is almost certainly a mistake in the flashmap, and the user would flash a layout they may not expect. I'd rather treat it as an error (or at least add ux_warn_tag) and list the layouts. Rejecting it now is easier than tightening it later

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread src/json.c
return NULL;
}

int json_get_bool(struct json_value *object, const char *key, bool *value)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since json_get_child() already does the key lookup, it can be just:

it = json_get_child(object, key);
if (!it || (it->type != JSON_TYPE_TRUE && it->type != JSON_TYPE_FALSE))
	return -1;

I'd also re-work json_get_number() if possible

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Hans Månsson added 3 commits November 13, 2026 10:54
Use json_get_child() instead of duplicating its lookup loop.

Signed-off-by: Hans Månsson <hans.mansson@sony.com>
Add a helper to read boolean values from JSON objects.

Signed-off-by: Hans Månsson <hans.mansson@sony.com>
When no selector is given and multiple layouts exist, select the one
marked with "default": true. A single layout is still selected
automatically. If several layouts are marked default, error out.

Signed-off-by: Hans Månsson <hans.mansson@sony.com>
@edsj-sony
edsj-sony force-pushed the flashmap-default-layout branch from db1f4e7 to 5e0b268 Compare November 13, 2026 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants