blob: 5a8816d0a1d847d07f9b3a0d438c9d269c9207dc [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Simon Glass7d0f1a22016-05-08 16:55:17 -06002/*
3 * Copyright (C) 2014 Samsung Electronics
4 * Przemyslaw Marczak <p.marczak@samsung.com>
Simon Glass7d0f1a22016-05-08 16:55:17 -06005 */
Wolfgang Denk74aedc12010-06-12 00:19:46 +02006#ifndef _ERRNO_H
Simon Glass7d0f1a22016-05-08 16:55:17 -06007#define _ERRNO_H
Wolfgang Denk74aedc12010-06-12 00:19:46 +02008
Masahiro Yamada64e4f7f2016-09-21 11:28:57 +09009#include <linux/errno.h>
Wolfgang Denk74aedc12010-06-12 00:19:46 +020010
Marek BehĂșn7bd4e1d2021-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 Denk74aedc12010-06-12 00:19:46 +020018
19#define __set_errno(val) do { errno = val; } while (0)
20
Heinrich Schuchardt80bcd842019-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 Glassdb79e762022-02-28 12:08:21 -070028#if CONFIG_IS_ENABLED(ERRNO_STR)
Przemyslaw Marczak87e31612014-10-08 22:48:37 +020029const char *errno_str(int errno);
Simon Glass21adb082016-05-08 16:55:18 -060030#else
Heinrich Schuchardt80bcd842019-10-06 13:58:57 +020031static const char error_message[] = "";
32
Simon Glass21adb082016-05-08 16:55:18 -060033static inline const char *errno_str(int errno)
34{
Heinrich Schuchardt80bcd842019-10-06 13:58:57 +020035 return error_message;
Simon Glass21adb082016-05-08 16:55:18 -060036}
Przemyslaw Marczak87e31612014-10-08 22:48:37 +020037#endif
Wolfgang Denk74aedc12010-06-12 00:19:46 +020038#endif /* _ERRNO_H */