From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH v2 04/20] fip: drop typedefs
Date: Wed, 12 Feb 2025 15:09:17 +0100 [thread overview]
Message-ID: <20250212-k3-emmc-v2-4-8dd1bb0ce60a@pengutronix.de> (raw)
In-Reply-To: <20250212-k3-emmc-v2-0-8dd1bb0ce60a@pengutronix.de>
Do not typedef struct types.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
commands/fiptool.c | 28 ++++++++++++++--------------
include/fiptool.h | 26 +++++++++++++-------------
lib/fip.c | 44 ++++++++++++++++++++++----------------------
3 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/commands/fiptool.c b/commands/fiptool.c
index 2d766f895b..a4370c9eef 100644
--- a/commands/fiptool.c
+++ b/commands/fiptool.c
@@ -31,7 +31,7 @@ typedef struct cmd {
} cmd_t;
-static int write_image_to_file(const image_t *image, const char *filename)
+static int write_image_to_file(const struct fip_image *image, const char *filename)
{
int fd;
@@ -53,7 +53,7 @@ static int write_image_to_file(const image_t *image, const char *filename)
static int info_cmd(struct fip_state *fip, int argc, char *argv[])
{
- image_desc_t *desc;
+ struct fip_image_desc *desc;
fip_toc_header_t toc_header;
int ret;
@@ -74,7 +74,7 @@ static int info_cmd(struct fip_state *fip, int argc, char *argv[])
(unsigned long long)toc_header.flags);
for (desc = fip->image_desc_head; desc != NULL; desc = desc->next) {
- image_t *image = desc->image;
+ struct fip_image *image = desc->image;
if (image == NULL)
continue;
@@ -193,7 +193,7 @@ static __maybe_unused int create_cmd(struct fip_state *fip, int argc, char *argv
while ((opt = getopt(argc, argv, "e:p:a:b:")) > 0) {
switch (opt) {
case 'e': {
- image_desc_t *desc;
+ struct fip_image_desc *desc;
desc = lookup_image_desc_from_opt(fip, &optarg);
if (!desc)
@@ -214,7 +214,7 @@ static __maybe_unused int create_cmd(struct fip_state *fip, int argc, char *argv
char name[UUID_STRING_LEN + 1];
char filename[PATH_MAX] = { 0 };
uuid_t uuid = uuid_null;
- image_desc_t *desc;
+ struct fip_image_desc *desc;
parse_blob_opt(optarg, &uuid,
filename, sizeof(filename));
@@ -264,7 +264,7 @@ static __maybe_unused int update_cmd(struct fip_state *fip, int argc, char *argv
while ((opt = getopt(argc, argv, "e:p:b:a:o:")) > 0) {
switch (opt) {
case 'e': {
- image_desc_t *desc;
+ struct fip_image_desc *desc;
desc = lookup_image_desc_from_opt(fip, &optarg);
if (!desc)
@@ -281,7 +281,7 @@ static __maybe_unused int update_cmd(struct fip_state *fip, int argc, char *argv
char name[UUID_STRING_LEN + 1];
char filename[PATH_MAX] = { 0 };
uuid_t uuid = uuid_null;
- image_desc_t *desc;
+ struct fip_image_desc *desc;
parse_blob_opt(optarg, &uuid,
filename, sizeof(filename));
@@ -339,7 +339,7 @@ static __maybe_unused int update_cmd(struct fip_state *fip, int argc, char *argv
static int unpack_cmd(struct fip_state *fip, int argc, char *argv[])
{
char outdir[PATH_MAX] = { 0 };
- image_desc_t *desc;
+ struct fip_image_desc *desc;
int fflag = 0;
int unpack_all = 1;
int ret, opt;
@@ -350,7 +350,7 @@ static int unpack_cmd(struct fip_state *fip, int argc, char *argv[])
while ((opt = getopt(argc, argv, "e:b:fo:")) > 0) {
switch (opt) {
case 'e': {
- image_desc_t *desc;
+ struct fip_image_desc *desc;
desc = lookup_image_desc_from_opt(fip, &optarg);
if (!desc)
@@ -363,7 +363,7 @@ static int unpack_cmd(struct fip_state *fip, int argc, char *argv[])
char name[UUID_STRING_LEN + 1];
char filename[PATH_MAX] = { 0 };
uuid_t uuid = uuid_null;
- image_desc_t *desc;
+ struct fip_image_desc *desc;
parse_blob_opt(optarg, &uuid,
filename, sizeof(filename));
@@ -411,7 +411,7 @@ static int unpack_cmd(struct fip_state *fip, int argc, char *argv[])
/* Unpack all specified images. */
for (desc = fip->image_desc_head; desc != NULL; desc = desc->next) {
char file[PATH_MAX];
- image_t *image = desc->image;
+ struct fip_image *image = desc->image;
if (!unpack_all && desc->action != DO_UNPACK)
continue;
@@ -447,7 +447,7 @@ static __maybe_unused int remove_cmd(struct fip_state *fip, int argc, char *argv
{
char outfile[PATH_MAX] = { 0 };
fip_toc_header_t toc_header;
- image_desc_t *desc;
+ struct fip_image_desc *desc;
long align = 1;
int ret, opt, fflag = 0;
@@ -457,7 +457,7 @@ static __maybe_unused int remove_cmd(struct fip_state *fip, int argc, char *argv
while ((opt = getopt(argc, argv, "e:a:b:fo:")) > 0) {
switch (opt) {
case 'e': {
- image_desc_t *desc;
+ struct fip_image_desc *desc;
desc = lookup_image_desc_from_opt(fip, &optarg);
if (!desc)
@@ -473,7 +473,7 @@ static __maybe_unused int remove_cmd(struct fip_state *fip, int argc, char *argv
case 'b': {
char name[UUID_STRING_LEN + 1], filename[PATH_MAX];
uuid_t uuid = uuid_null;
- image_desc_t *desc;
+ struct fip_image_desc *desc;
parse_blob_opt(optarg, &uuid,
filename, sizeof(filename));
diff --git a/include/fiptool.h b/include/fiptool.h
index 704845f456..6f1d69d178 100644
--- a/include/fiptool.h
+++ b/include/fiptool.h
@@ -16,23 +16,23 @@ enum {
DO_REMOVE = 3
};
-typedef struct image_desc {
+struct fip_image_desc {
uuid_t uuid;
char *name;
char *cmdline_name;
int action;
char *action_arg;
- struct image *image;
- struct image_desc *next;
-} image_desc_t;
+ struct fip_image *image;
+ struct fip_image_desc *next;
+};
-typedef struct image {
+struct fip_image {
struct fip_toc_entry toc_e;
void *buffer;
-} image_t;
+};
struct fip_state {
- image_desc_t *image_desc_head;
+ struct fip_image_desc *image_desc_head;
size_t nr_image_descs;
int verbose;
};
@@ -45,24 +45,24 @@ struct fip_state {
} \
} while (0)
-image_desc_t *new_image_desc(const uuid_t *uuid,
+struct fip_image_desc *new_image_desc(const uuid_t *uuid,
const char *name, const char *cmdline_name);
-void set_image_desc_action(image_desc_t *desc, int action,
+void set_image_desc_action(struct fip_image_desc *desc, int action,
const char *arg);
-void free_image_desc(image_desc_t *desc);
+void free_image_desc(struct fip_image_desc *desc);
-void add_image_desc(struct fip_state *fip, image_desc_t *desc);
+void add_image_desc(struct fip_state *fip, struct fip_image_desc *desc);
void free_image_descs(struct fip_state *fip);
void fill_image_descs(struct fip_state *fip);
-image_desc_t *lookup_image_desc_from_uuid(struct fip_state *fip,
+struct fip_image_desc *lookup_image_desc_from_uuid(struct fip_state *fip,
const uuid_t *uuid);
-image_desc_t *lookup_image_desc_from_opt(struct fip_state *fip, char **arg);
+struct fip_image_desc *lookup_image_desc_from_opt(struct fip_state *fip, char **arg);
int parse_fip(struct fip_state *fip,
const char *filename, fip_toc_header_t *toc_header_out);
diff --git a/lib/fip.c b/lib/fip.c
index ae7ff8b3ad..e7589ff4c2 100644
--- a/lib/fip.c
+++ b/lib/fip.c
@@ -26,10 +26,10 @@
#include <fip.h>
#include <fiptool.h>
-image_desc_t *new_image_desc(const uuid_t *uuid,
+struct fip_image_desc *new_image_desc(const uuid_t *uuid,
const char *name, const char *cmdline_name)
{
- image_desc_t *desc;
+ struct fip_image_desc *desc;
desc = xzalloc(sizeof(*desc));
memcpy(&desc->uuid, uuid, sizeof(uuid_t));
@@ -39,7 +39,7 @@ image_desc_t *new_image_desc(const uuid_t *uuid,
return desc;
}
-void set_image_desc_action(image_desc_t *desc, int action,
+void 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(image_desc_t *desc, int action,
desc->action_arg = xstrdup(arg);
}
-void free_image_desc(image_desc_t *desc)
+void free_image_desc(struct fip_image_desc *desc)
{
free(desc->name);
free(desc->cmdline_name);
@@ -64,9 +64,9 @@ void free_image_desc(image_desc_t *desc)
free(desc);
}
-void add_image_desc(struct fip_state *fip, image_desc_t *desc)
+void add_image_desc(struct fip_state *fip, struct fip_image_desc *desc)
{
- image_desc_t **p = &fip->image_desc_head;
+ struct fip_image_desc **p = &fip->image_desc_head;
while (*p)
p = &(*p)->next;
@@ -78,7 +78,7 @@ void add_image_desc(struct fip_state *fip, image_desc_t *desc)
void free_image_descs(struct fip_state *fip)
{
- image_desc_t *desc = fip->image_desc_head, *tmp;
+ struct fip_image_desc *desc = fip->image_desc_head, *tmp;
while (desc != NULL) {
tmp = desc->next;
@@ -96,7 +96,7 @@ void fill_image_descs(struct fip_state *fip)
for (toc_entry = toc_entries;
toc_entry->cmdline_name != NULL;
toc_entry++) {
- image_desc_t *desc;
+ struct fip_image_desc *desc;
desc = new_image_desc(&toc_entry->uuid,
toc_entry->name,
@@ -106,7 +106,7 @@ void fill_image_descs(struct fip_state *fip)
for (toc_entry = plat_def_toc_entries;
toc_entry->cmdline_name != NULL;
toc_entry++) {
- image_desc_t *desc;
+ struct fip_image_desc *desc;
desc = new_image_desc(&toc_entry->uuid,
toc_entry->name,
@@ -115,10 +115,10 @@ void fill_image_descs(struct fip_state *fip)
}
}
-image_desc_t *lookup_image_desc_from_uuid(struct fip_state *fip,
+struct fip_image_desc *lookup_image_desc_from_uuid(struct fip_state *fip,
const uuid_t *uuid)
{
- image_desc_t *desc;
+ struct fip_image_desc *desc;
for (desc = fip->image_desc_head; desc != NULL; desc = desc->next)
if (memcmp(&desc->uuid, uuid, sizeof(uuid_t)) == 0)
@@ -126,10 +126,10 @@ image_desc_t *lookup_image_desc_from_uuid(struct fip_state *fip,
return NULL;
}
-image_desc_t *lookup_image_desc_from_opt(struct fip_state *fip, char **arg)
+struct fip_image_desc *lookup_image_desc_from_opt(struct fip_state *fip, char **arg)
{
int len = 0;
- image_desc_t *desc;
+ struct fip_image_desc *desc;
char *eq;
eq = strchrnul(*arg, '=');
@@ -200,8 +200,8 @@ int parse_fip(struct fip_state *fip,
/* Walk through each ToC entry in the file. */
while ((char *)toc_entry + sizeof(*toc_entry) - 1 < bufend) {
- image_t *image;
- image_desc_t *desc;
+ struct fip_image *image;
+ struct fip_image_desc *desc;
/* Found the ToC terminator, we are done. */
if (memcmp(&toc_entry->uuid, &uuid_null, sizeof(uuid_t)) == 0) {
@@ -260,10 +260,10 @@ int parse_fip(struct fip_state *fip,
return 0;
}
-static image_t *read_image_from_file(const uuid_t *uuid, const char *filename)
+static struct fip_image *read_image_from_file(const uuid_t *uuid, const char *filename)
{
struct stat st;
- image_t *image;
+ struct fip_image *image;
int fd;
ASSERT(uuid != NULL);
@@ -298,7 +298,7 @@ int pack_images(struct fip_state *fip,
uint64_t toc_flags, unsigned long align)
{
int fd;
- image_desc_t *desc;
+ struct fip_image_desc *desc;
fip_toc_header_t *toc_header;
fip_toc_entry_t *toc_entry;
char *buf;
@@ -325,7 +325,7 @@ int pack_images(struct fip_state *fip,
entry_offset = buf_size;
for (desc = fip->image_desc_head; desc != NULL; desc = desc->next) {
- image_t *image = desc->image;
+ struct fip_image *image = desc->image;
if (image == NULL || (image->toc_e.size == 0ULL))
continue;
@@ -361,7 +361,7 @@ int pack_images(struct fip_state *fip,
pr_verbose("Payload size: %llu bytes\n", payload_size);
for (desc = fip->image_desc_head; desc != NULL; desc = desc->next) {
- image_t *image = desc->image;
+ struct fip_image *image = desc->image;
if (image == NULL)
continue;
@@ -396,11 +396,11 @@ int pack_images(struct fip_state *fip,
*/
int update_fip(struct fip_state *fip)
{
- image_desc_t *desc;
+ struct fip_image_desc *desc;
/* Add or replace images in the FIP file. */
for (desc = fip->image_desc_head; desc != NULL; desc = desc->next) {
- image_t *image;
+ struct fip_image *image;
if (desc->action != DO_PACK)
continue;
--
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 ` Sascha Hauer [this message]
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 ` [PATCH v2 08/20] fip: add fip_ prefix Sascha Hauer
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-4-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