Skip to content

Commit

Permalink
lk2nd: device: Add an api to get dtb filename hints
Browse files Browse the repository at this point in the history
  • Loading branch information
TravMurav authored and stephan-gh committed Nov 4, 2023
1 parent 1b60ab8 commit bc751c9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lk2nd/device/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@
#include <string.h>

#include <libfdt.h>
#include <lk2nd/util/lkfdt.h>
#include <lk2nd/device.h>
#include <lk2nd/init.h>

#include "device.h"

struct lk2nd_device lk2nd_dev;

/**
* lk2nd_device_get_dtb_hints() - Get a null-terminated array of DTB names.
*/
char **lk2nd_device_get_dtb_hints(void)
{
return lk2nd_dev.dtbfiles;
}

static int find_device_node(const void *dtb)
{
int lk2nd_node, node, ret;
Expand Down Expand Up @@ -108,6 +117,10 @@ static void parse_dtb(const void *dtb)
else
dprintf(CRITICAL, "Failed to read 'model': %d\n", len);

lk2nd_dev.dtbfiles = lkfdt_stringlist_get_all(dtb, node, "lk2nd,dtb-files", &len);
if (len < 0)
dprintf(CRITICAL, "Failed to read 'lk2nd,dtb-files': %d\n", len);

dprintf(INFO, "Detected device: %s (compatible: %s)\n",
lk2nd_dev.model, lk2nd_dev.compatible);

Expand Down
2 changes: 2 additions & 0 deletions lk2nd/device/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ struct lk2nd_device {
const char *model;
const char *battery;

char **dtbfiles;

struct lk2nd_panel panel;

#if WITH_LK2ND_DEVICE_2ND
Expand Down
6 changes: 6 additions & 0 deletions lk2nd/include/lk2nd/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ bool lk2nd_device2nd_have_atags(void) __PURE;
void lk2nd_device2nd_copy_atags(void *tags, const char *cmdline,
void *ramdisk, unsigned ramdisk_size);

#if WITH_LK2ND_DEVICE
char **lk2nd_device_get_dtb_hints(void);
#else
static inline char **lk2nd_device_get_dtb_hints(void) { return NULL; };
#endif

#endif /* LK2ND_DEVICE_H */

0 comments on commit bc751c9

Please sign in to comment.