Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Simon Glass | 7d0f1a2 | 2016-05-08 16:55:17 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2014 Samsung Electronics |
| 4 | * Przemyslaw Marczak <p.marczak@samsung.com> |
Simon Glass | 7d0f1a2 | 2016-05-08 16:55:17 -0600 | [diff] [blame] | 5 | */ |
Wolfgang Denk | 74aedc1 | 2010-06-12 00:19:46 +0200 | [diff] [blame] | 6 | #ifndef _ERRNO_H |
Simon Glass | 7d0f1a2 | 2016-05-08 16:55:17 -0600 | [diff] [blame] | 7 | #define _ERRNO_H |
Wolfgang Denk | 74aedc1 | 2010-06-12 00:19:46 +0200 | [diff] [blame] | 8 | |
Masahiro Yamada | 64e4f7f | 2016-09-21 11:28:57 +0900 | [diff] [blame] | 9 | #include <linux/errno.h> |
Wolfgang Denk | 74aedc1 | 2010-06-12 00:19:46 +0200 | [diff] [blame] | 10 | |
Marek BehĂșn | 7bd4e1d | 2021-05-20 13:24:05 +0200 | [diff] [blame] | 11 | #ifdef __SANDBOX__ |
| 12 | #define __errno_asm_label asm("__u_boot_errno") |
| 13 | #else |
| 14 | #define __errno_asm_label |
| 15 | #endif |
| 16 | |
| 17 | extern int errno __errno_asm_label; |
Wolfgang Denk | 74aedc1 | 2010-06-12 00:19:46 +0200 | [diff] [blame] | 18 | |
| 19 | #define __set_errno(val) do { errno = val; } while (0) |
| 20 | |
Heinrich Schuchardt | 80bcd84 | 2019-10-06 13:58:57 +0200 | [diff] [blame] | 21 | /** |
| 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 | */ |
Przemyslaw Marczak | 87e3161 | 2014-10-08 22:48:37 +0200 | [diff] [blame] | 28 | #ifdef CONFIG_ERRNO_STR |
| 29 | const char *errno_str(int errno); |
Simon Glass | 21adb08 | 2016-05-08 16:55:18 -0600 | [diff] [blame] | 30 | #else |
Heinrich Schuchardt | 80bcd84 | 2019-10-06 13:58:57 +0200 | [diff] [blame] | 31 | static const char error_message[] = ""; |
| 32 | |
Simon Glass | 21adb08 | 2016-05-08 16:55:18 -0600 | [diff] [blame] | 33 | static inline const char *errno_str(int errno) |
| 34 | { |
Heinrich Schuchardt | 80bcd84 | 2019-10-06 13:58:57 +0200 | [diff] [blame] | 35 | return error_message; |
Simon Glass | 21adb08 | 2016-05-08 16:55:18 -0600 | [diff] [blame] | 36 | } |
Przemyslaw Marczak | 87e3161 | 2014-10-08 22:48:37 +0200 | [diff] [blame] | 37 | #endif |
Wolfgang Denk | 74aedc1 | 2010-06-12 00:19:46 +0200 | [diff] [blame] | 38 | #endif /* _ERRNO_H */ |