From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH v2 08/20] fip: add fip_ prefix
Date: Wed, 12 Feb 2025 15:09:21 +0100 [thread overview]
Message-ID: <20250212-k3-emmc-v2-8-8dd1bb0ce60a@pengutronix.de> (raw)
In-Reply-To: <20250212-k3-emmc-v2-0-8dd1bb0ce60a@pengutronix.de>
Many functions of the FIP library do not have an indication what
they are about. Add a fip_ prefix to all FIP related functions.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/fiptool.c | 68 +++++++++++++++++++++++++++---------------------------
include/fiptool.h | 20 ++++++++--------
lib/fip.c | 40 ++++++++++++++++----------------
3 files changed, 64 insertions(+), 64 deletions(-)
diff --git a/commands/fiptool.c b/commands/fiptool.c
index eb7d9b5ac7..46b5ed29c3 100644
--- a/commands/fiptool.c
+++ b/commands/fiptool.c
@@ -62,7 +62,7 @@ static int info_cmd(struct fip_state *fip, int argc, char *argv[])
argc--, argv++;
- ret = parse_fip(fip, argv[0], &toc_header);
+ ret = fip_parse(fip, argv[0], &toc_header);
if (ret)
return ret;
@@ -195,10 +195,10 @@ static __maybe_unused int create_cmd(struct fip_state *fip, int argc, char *argv
case 'e': {
struct fip_image_desc *desc;
- desc = lookup_image_desc_from_opt(fip, &optarg);
+ desc = fip_lookup_image_desc_from_opt(fip, &optarg);
if (!desc)
return COMMAND_ERROR;
- set_image_desc_action(desc, DO_PACK, optarg);
+ fip_set_image_desc_action(desc, DO_PACK, optarg);
break;
}
case 'p':
@@ -222,13 +222,13 @@ static __maybe_unused int create_cmd(struct fip_state *fip, int argc, char *argv
if (uuid_is_null(&uuid) || filename[0] == '\0')
return COMMAND_ERROR_USAGE;
- desc = lookup_image_desc_from_uuid(fip, &uuid);
+ desc = fip_lookup_image_desc_from_uuid(fip, &uuid);
if (desc == NULL) {
snprintf(name, sizeof(name), "%pU", &uuid);
- desc = new_image_desc(&uuid, name, "blob");
- add_image_desc(fip, desc);
+ desc = fip_new_image_desc(&uuid, name, "blob");
+ fip_add_image_desc(fip, desc);
}
- set_image_desc_action(desc, DO_PACK, filename);
+ fip_set_image_desc_action(desc, DO_PACK, filename);
break;
}
default:
@@ -241,10 +241,10 @@ static __maybe_unused int create_cmd(struct fip_state *fip, int argc, char *argv
if (argc == 0)
return COMMAND_ERROR_USAGE;
- if (update_fip(fip))
+ if (fip_update(fip))
return COMMAND_ERROR;
- return pack_images(fip, argv[0], toc_flags, align);
+ return fip_pack_images(fip, argv[0], toc_flags, align);
}
@@ -265,10 +265,10 @@ static __maybe_unused int update_cmd(struct fip_state *fip, int argc, char *argv
case 'e': {
struct fip_image_desc *desc;
- desc = lookup_image_desc_from_opt(fip, &optarg);
+ desc = fip_lookup_image_desc_from_opt(fip, &optarg);
if (!desc)
return COMMAND_ERROR;
- set_image_desc_action(desc, DO_PACK, optarg);
+ fip_set_image_desc_action(desc, DO_PACK, optarg);
break;
}
case 'p':
@@ -289,13 +289,13 @@ static __maybe_unused int update_cmd(struct fip_state *fip, int argc, char *argv
filename[0] == '\0')
return COMMAND_ERROR_USAGE;
- desc = lookup_image_desc_from_uuid(fip, &uuid);
+ desc = fip_lookup_image_desc_from_uuid(fip, &uuid);
if (desc == NULL) {
snprintf(name, sizeof(name), "%pU", &uuid);
- desc = new_image_desc(&uuid, name, "blob");
- add_image_desc(fip, desc);
+ desc = fip_new_image_desc(&uuid, name, "blob");
+ fip_add_image_desc(fip, desc);
}
- set_image_desc_action(desc, DO_PACK, filename);
+ fip_set_image_desc_action(desc, DO_PACK, filename);
break;
}
case 'a':
@@ -320,7 +320,7 @@ static __maybe_unused int update_cmd(struct fip_state *fip, int argc, char *argv
snprintf(outfile, sizeof(outfile), "%s", argv[0]);
if (file_exists(argv[0])) {
- ret = parse_fip(fip, argv[0], &toc_header);
+ ret = fip_parse(fip, argv[0], &toc_header);
if (ret)
return ret;
}
@@ -329,10 +329,10 @@ static __maybe_unused int update_cmd(struct fip_state *fip, int argc, char *argv
toc_header.flags &= ~(0xffffULL << 32);
toc_flags = (toc_header.flags |= toc_flags);
- if (update_fip(fip))
+ if (fip_update(fip))
return COMMAND_ERROR;
- return pack_images(fip, outfile, toc_flags, align);
+ return fip_pack_images(fip, outfile, toc_flags, align);
}
static int unpack_cmd(struct fip_state *fip, int argc, char *argv[])
@@ -351,10 +351,10 @@ static int unpack_cmd(struct fip_state *fip, int argc, char *argv[])
case 'e': {
struct fip_image_desc *desc;
- desc = lookup_image_desc_from_opt(fip, &optarg);
+ desc = fip_lookup_image_desc_from_opt(fip, &optarg);
if (!desc)
return COMMAND_ERROR;
- set_image_desc_action(desc, DO_UNPACK, optarg);
+ fip_set_image_desc_action(desc, DO_UNPACK, optarg);
unpack_all = 0;
break;
}
@@ -370,13 +370,13 @@ static int unpack_cmd(struct fip_state *fip, int argc, char *argv[])
if (uuid_is_null(&uuid) || filename[0] == '\0')
return COMMAND_ERROR_USAGE;
- desc = lookup_image_desc_from_uuid(fip, &uuid);
+ desc = fip_lookup_image_desc_from_uuid(fip, &uuid);
if (desc == NULL) {
snprintf(name, sizeof(name), "%pU", &uuid);
- desc = new_image_desc(&uuid, name, "blob");
- add_image_desc(fip, desc);
+ desc = fip_new_image_desc(&uuid, name, "blob");
+ fip_add_image_desc(fip, desc);
}
- set_image_desc_action(desc, DO_UNPACK, filename);
+ fip_set_image_desc_action(desc, DO_UNPACK, filename);
unpack_all = 0;
break;
}
@@ -396,7 +396,7 @@ static int unpack_cmd(struct fip_state *fip, int argc, char *argv[])
if (argc == 0)
return COMMAND_ERROR_USAGE;
- ret = parse_fip(fip, argv[0], NULL);
+ ret = fip_parse(fip, argv[0], NULL);
if (ret)
return ret;
@@ -457,10 +457,10 @@ static __maybe_unused int remove_cmd(struct fip_state *fip, int argc, char *argv
case 'e': {
struct fip_image_desc *desc;
- desc = lookup_image_desc_from_opt(fip, &optarg);
+ desc = fip_lookup_image_desc_from_opt(fip, &optarg);
if (!desc)
return COMMAND_ERROR;
- set_image_desc_action(desc, DO_REMOVE, NULL);
+ fip_set_image_desc_action(desc, DO_REMOVE, NULL);
break;
}
case 'a':
@@ -479,13 +479,13 @@ static __maybe_unused int remove_cmd(struct fip_state *fip, int argc, char *argv
if (uuid_is_null(&uuid))
return COMMAND_ERROR_USAGE;
- desc = lookup_image_desc_from_uuid(fip, &uuid);
+ desc = fip_lookup_image_desc_from_uuid(fip, &uuid);
if (desc == NULL) {
snprintf(name, sizeof(name), "%pU", &uuid);
- desc = new_image_desc(&uuid, name, "blob");
- add_image_desc(fip, desc);
+ desc = fip_new_image_desc(&uuid, name, "blob");
+ fip_add_image_desc(fip, desc);
}
- set_image_desc_action(desc, DO_REMOVE, NULL);
+ fip_set_image_desc_action(desc, DO_REMOVE, NULL);
break;
}
case 'f':
@@ -511,7 +511,7 @@ static __maybe_unused int remove_cmd(struct fip_state *fip, int argc, char *argv
if (outfile[0] == '\0')
snprintf(outfile, sizeof(outfile), "%s", argv[0]);
- ret = parse_fip(fip, argv[0], &toc_header);
+ ret = fip_parse(fip, argv[0], &toc_header);
if (ret)
return ret;
@@ -528,7 +528,7 @@ static __maybe_unused int remove_cmd(struct fip_state *fip, int argc, char *argv
}
}
- return pack_images(fip, outfile, toc_header.flags, align);
+ return fip_pack_images(fip, outfile, toc_header.flags, align);
}
/* Available subcommands. */
@@ -567,7 +567,7 @@ static int do_fiptool(int argc, char *argv[])
if (argc == 0)
return COMMAND_ERROR_USAGE;
- fill_image_descs(fip);
+ fip_fill_image_descs(fip);
for (i = 0; i < ARRAY_SIZE(cmds); i++) {
if (strcmp(cmds[i].name, argv[0]) == 0) {
struct getopt_context gc;
diff --git a/include/fiptool.h b/include/fiptool.h
index 5a3fdee6e0..6a12466c29 100644
--- a/include/fiptool.h
+++ b/include/fiptool.h
@@ -49,31 +49,31 @@ struct fip_state {
struct fip_state *fip_new(void);
void fip_free(struct fip_state *fip);
-struct fip_image_desc *new_image_desc(const uuid_t *uuid,
+struct fip_image_desc *fip_new_image_desc(const uuid_t *uuid,
const char *name, const char *cmdline_name);
-void set_image_desc_action(struct fip_image_desc *desc, int action,
+void fip_set_image_desc_action(struct fip_image_desc *desc, int action,
const char *arg);
-void free_image_desc(struct fip_image_desc *desc);
+void fip_free_image_desc(struct fip_image_desc *desc);
-void add_image_desc(struct fip_state *fip, struct fip_image_desc *desc);
+void fip_add_image_desc(struct fip_state *fip, struct fip_image_desc *desc);
-void fill_image_descs(struct fip_state *fip);
+void fip_fill_image_descs(struct fip_state *fip);
-struct fip_image_desc *lookup_image_desc_from_uuid(struct fip_state *fip,
+struct fip_image_desc *fip_lookup_image_desc_from_uuid(struct fip_state *fip,
const uuid_t *uuid);
-struct fip_image_desc *lookup_image_desc_from_opt(struct fip_state *fip, char **arg);
+struct fip_image_desc *fip_lookup_image_desc_from_opt(struct fip_state *fip, char **arg);
-int parse_fip(struct fip_state *fip,
+int fip_parse(struct fip_state *fip,
const char *filename, fip_toc_header_t *toc_header_out);
-int pack_images(struct fip_state *fip,
+int fip_pack_images(struct fip_state *fip,
const char *filename,
uint64_t toc_flags, unsigned long align);
-int update_fip(struct fip_state *fip);
+int fip_update(struct fip_state *fip);
#define TOC_HEADER_SERIAL_NUMBER 0x12345678
diff --git a/lib/fip.c b/lib/fip.c
index 774de2ad1d..075cd0e1e6 100644
--- a/lib/fip.c
+++ b/lib/fip.c
@@ -26,7 +26,7 @@
#include <fip.h>
#include <fiptool.h>
-struct fip_image_desc *new_image_desc(const uuid_t *uuid,
+struct fip_image_desc *fip_new_image_desc(const uuid_t *uuid,
const char *name, const char *cmdline_name)
{
struct fip_image_desc *desc;
@@ -39,7 +39,7 @@ struct fip_image_desc *new_image_desc(const uuid_t *uuid,
return desc;
}
-void set_image_desc_action(struct fip_image_desc *desc, int action,
+void fip_set_image_desc_action(struct fip_image_desc *desc, int action,
const char *arg)
{
ASSERT(desc != NULL);
@@ -52,7 +52,7 @@ void set_image_desc_action(struct fip_image_desc *desc, int action,
desc->action_arg = xstrdup(arg);
}
-void free_image_desc(struct fip_image_desc *desc)
+void fip_free_image_desc(struct fip_image_desc *desc)
{
free(desc->name);
free(desc->cmdline_name);
@@ -64,7 +64,7 @@ void free_image_desc(struct fip_image_desc *desc)
free(desc);
}
-void add_image_desc(struct fip_state *fip, struct fip_image_desc *desc)
+void fip_add_image_desc(struct fip_state *fip, struct fip_image_desc *desc)
{
list_add_tail(&desc->list, &fip->descs);
fip->nr_image_descs++;
@@ -86,7 +86,7 @@ void fip_free(struct fip_state *fip)
struct fip_image_desc *desc, *tmp;
fip_for_each_desc_safe(fip, desc, tmp) {
- free_image_desc(desc);
+ fip_free_image_desc(desc);
fip->nr_image_descs--;
}
@@ -95,7 +95,7 @@ void fip_free(struct fip_state *fip)
free(fip);
}
-void fill_image_descs(struct fip_state *fip)
+void fip_fill_image_descs(struct fip_state *fip)
{
toc_entry_t *toc_entry;
@@ -104,24 +104,24 @@ void fill_image_descs(struct fip_state *fip)
toc_entry++) {
struct fip_image_desc *desc;
- desc = new_image_desc(&toc_entry->uuid,
+ desc = fip_new_image_desc(&toc_entry->uuid,
toc_entry->name,
toc_entry->cmdline_name);
- add_image_desc(fip, desc);
+ fip_add_image_desc(fip, desc);
}
for (toc_entry = plat_def_toc_entries;
toc_entry->cmdline_name != NULL;
toc_entry++) {
struct fip_image_desc *desc;
- desc = new_image_desc(&toc_entry->uuid,
+ desc = fip_new_image_desc(&toc_entry->uuid,
toc_entry->name,
toc_entry->cmdline_name);
- add_image_desc(fip, desc);
+ fip_add_image_desc(fip, desc);
}
}
-struct fip_image_desc *lookup_image_desc_from_uuid(struct fip_state *fip,
+struct fip_image_desc *fip_lookup_image_desc_from_uuid(struct fip_state *fip,
const uuid_t *uuid)
{
struct fip_image_desc *desc;
@@ -132,7 +132,7 @@ struct fip_image_desc *lookup_image_desc_from_uuid(struct fip_state *fip,
return NULL;
}
-struct fip_image_desc *lookup_image_desc_from_opt(struct fip_state *fip, char **arg)
+struct fip_image_desc *fip_lookup_image_desc_from_opt(struct fip_state *fip, char **arg)
{
int len = 0;
struct fip_image_desc *desc;
@@ -153,7 +153,7 @@ struct fip_image_desc *lookup_image_desc_from_opt(struct fip_state *fip, char **
return NULL;
}
-int parse_fip(struct fip_state *fip,
+int fip_parse(struct fip_state *fip,
const char *filename, fip_toc_header_t *toc_header_out)
{
struct stat st;
@@ -238,17 +238,17 @@ int parse_fip(struct fip_state *fip,
toc_entry->size);
/* If this is an unknown image, create a descriptor for it. */
- desc = lookup_image_desc_from_uuid(fip, &toc_entry->uuid);
+ desc = fip_lookup_image_desc_from_uuid(fip, &toc_entry->uuid);
if (desc == NULL) {
char name[UUID_STRING_LEN + 1], filename[PATH_MAX];
snprintf(name, sizeof(name), "%pU", &toc_entry->uuid);
snprintf(filename, sizeof(filename), "%s%s",
name, ".bin");
- desc = new_image_desc(&toc_entry->uuid, name, "blob");
+ desc = fip_new_image_desc(&toc_entry->uuid, name, "blob");
desc->action = DO_UNPACK;
desc->action_arg = xstrdup(filename);
- add_image_desc(fip, desc);
+ fip_add_image_desc(fip, desc);
}
ASSERT(desc->image == NULL);
@@ -266,7 +266,7 @@ int parse_fip(struct fip_state *fip,
return 0;
}
-static struct fip_image *read_image_from_file(const uuid_t *uuid, const char *filename)
+static struct fip_image *fip_read_image_from_file(const uuid_t *uuid, const char *filename)
{
struct stat st;
struct fip_image *image;
@@ -299,7 +299,7 @@ static struct fip_image *read_image_from_file(const uuid_t *uuid, const char *fi
return image;
}
-int pack_images(struct fip_state *fip,
+int fip_pack_images(struct fip_state *fip,
const char *filename,
uint64_t toc_flags, unsigned long align)
{
@@ -400,7 +400,7 @@ int pack_images(struct fip_state *fip,
* in update_fip() creating the new FIP file from scratch because the
* internal image table is not populated.
*/
-int update_fip(struct fip_state *fip)
+int fip_update(struct fip_state *fip)
{
struct fip_image_desc *desc;
@@ -411,7 +411,7 @@ int update_fip(struct fip_state *fip)
if (desc->action != DO_PACK)
continue;
- image = read_image_from_file(&desc->uuid,
+ image = fip_read_image_from_file(&desc->uuid,
desc->action_arg);
if (!image)
return -1;
--
2.39.5
next prev parent reply other threads:[~2025-02-12 14:10 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-12 14:09 [PATCH v2 00/20] ARM: K3 updates Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 01/20] ARM: k3: Add function to enable 32k crystal Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 02/20] ARM: k3: add function to detect eMMC boot Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 03/20] ARM: k3: do not mount /boot when booting from eMMC Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 04/20] fip: drop typedefs Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 05/20] fip: use linux list implementation Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 06/20] fip: use uuid_equal() and uuid_is_null() Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 07/20] fiptool: do not typedef structs Sascha Hauer
2025-02-12 14:09 ` Sascha Hauer [this message]
2025-02-12 14:09 ` [PATCH v2 09/20] fip: add fip_image_open() Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 10/20] ARM: k3: r5: add USB DFU and eMMC boot support Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 11/20] ARM: am625-sk: enable 32k crystal Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 12/20] mci: am654: parse generic mmc node properties Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 13/20] ARM: k3: limit eMMC frequency to 26MHz Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 14/20] ARM: k3: add eMMC barebox update handler Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 15/20] ARM: am625-sk: put environment on eMMC when booting from it Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 16/20] serial: omap: Use ttyS as Linux console name Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 17/20] ARM: k3: remove beagleplay FIT image Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 18/20] ARM: am625-sk: cleanup board entry Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 19/20] ARM: beagleplay: " Sascha Hauer
2025-02-12 14:09 ` [PATCH v2 20/20] ARM: k3: Add k3-r5_defconfig Sascha Hauer
2025-02-17 11:14 ` [PATCH v2 00/20] ARM: K3 updates Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250212-k3-emmc-v2-8-8dd1bb0ce60a@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox