blob: 5a8816d0a1d847d07f9b3a0d438c9d269c9207dc [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass00e9e6d2016-05-08 16:55:17 -06002/*
3 * Copyright (C) 2014 Samsung Electronics
4 * Przemyslaw Marczak <p.marczak@samsung.com>
Simon Glass00e9e6d2016-05-08 16:55:17 -06005 */
Wolfgang Denk65cd3fa2010-06-12 00:19:46 +02006#ifndef _ERRNO_H
Simon Glass00e9e6d2016-05-08 16:55:17 -06007#define _ERRNO_H
Wolfgang Denk65cd3fa2010-06-12 00:19:46 +02008
Masahiro Yamada5d97dff2016-09-21 11:28:57 +09009#include <linux/errno.h>
Wolfgang Denk65cd3fa2010-06-12 00:19:46 +020010
Marek BehĂșnbe1e77f2021-05-20 13:24:05 +020011#ifdef __SANDBOX__
12#define __errno_asm_label asm("__u_boot_errno")
13#else
14#define __errno_asm_label
15#endif
16
17extern int errno __errno_asm_label;
Wolfgang Denk65cd3fa2010-06-12 00:19:46 +020018
19#define __set_errno(val) do { errno = val; } while (0)
20
Heinrich Schuchardtf279e1d2019-10-06 13:58:57 +020021/**
22 * errno_str() - get description for error number
23 *
24 * @errno: error number (negative in case of error)
25 * Return: string describing the error. If CONFIG_ERRNO_STR is not
26 * defined an empty string is returned.
27 */
Simon Glass64aefc42022-02-28 12:08:21 -070028#if CONFIG_IS_ENABLED(ERRNO_STR)
Przemyslaw Marczak59345b12014-10-08 22:48:37 +020029const char *errno_str(int errno);
Simon Glass862887d2016-05-08 16:55:18 -060030#else
Heinrich Schuchardtf279e1d2019-10-06 13:58:57 +020031static const char error_message[] = "";
32
Simon Glass862887d2016-05-08 16:55:18 -060033static inline const char *errno_str(int errno)
34{
Heinrich Schuchardtf279e1d2019-10-06 13:58:57 +020035 return error_message;
Simon Glass862887d2016-05-08 16:55:18 -060036}
Przemyslaw Marczak59345b12014-10-08 22:48:37 +020037#endif
Wolfgang Denk65cd3fa2010-06-12 00:19:46 +020038#endif /* _ERRNO_H */