mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-08-20 17:08:52 +09:00
![Simon Glass](/assets/img/avatar_default.png)
At present dm/device.h includes the linux-compatible features. This requires including linux/compat.h which in turn includes a lot of headers. One of these is malloc.h which we thus end up including in every file in U-Boot. Apart from the inefficiency of this, it is problematic for sandbox which needs to use the system malloc() in some files. Move the compatibility features into a separate header file. Signed-off-by: Simon Glass <sjg@chromium.org>
39 lines
642 B
C
39 lines
642 B
C
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
#include <common.h>
|
|
#include <malloc.h>
|
|
#include <dm/devres.h>
|
|
#include "brcmnand_compat.h"
|
|
|
|
static char *devm_kvasprintf(struct udevice *dev, gfp_t gfp, const char *fmt,
|
|
va_list ap)
|
|
{
|
|
unsigned int len;
|
|
char *p;
|
|
va_list aq;
|
|
|
|
va_copy(aq, ap);
|
|
len = vsnprintf(NULL, 0, fmt, aq);
|
|
va_end(aq);
|
|
|
|
p = devm_kmalloc(dev, len + 1, gfp);
|
|
if (!p)
|
|
return NULL;
|
|
|
|
vsnprintf(p, len + 1, fmt, ap);
|
|
|
|
return p;
|
|
}
|
|
|
|
char *devm_kasprintf(struct udevice *dev, gfp_t gfp, const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
char *p;
|
|
|
|
va_start(ap, fmt);
|
|
p = devm_kvasprintf(dev, gfp, fmt, ap);
|
|
va_end(ap);
|
|
|
|
return p;
|
|
}
|