blob: 883948355ca8edf3323876157e804f1f3146926c [file] [log] [blame]
Philippe Reynes5aa6cfb2019-03-15 15:14:36 +01001// SPDX-License-Identifier: GPL-2.0+
2
3#include <common.h>
4#include "brcmnand_compat.h"
5
Philippe Reynes5aa6cfb2019-03-15 15:14:36 +01006static char *devm_kvasprintf(struct udevice *dev, gfp_t gfp, const char *fmt,
7 va_list ap)
8{
9 unsigned int len;
10 char *p;
11 va_list aq;
12
13 va_copy(aq, ap);
14 len = vsnprintf(NULL, 0, fmt, aq);
15 va_end(aq);
16
17 p = devm_kmalloc(dev, len + 1, gfp);
18 if (!p)
19 return NULL;
20
21 vsnprintf(p, len + 1, fmt, ap);
22
23 return p;
24}
25
26char *devm_kasprintf(struct udevice *dev, gfp_t gfp, const char *fmt, ...)
27{
28 va_list ap;
29 char *p;
30
31 va_start(ap, fmt);
32 p = devm_kvasprintf(dev, gfp, fmt, ap);
33 va_end(ap);
34
35 return p;
36}