Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 1 | #ifndef __WILC_ERRORSUPPORT_H__ |
| 2 | #define __WILC_ERRORSUPPORT_H__ |
| 3 | |
| 4 | /*! |
| 5 | * @file wilc_errorsupport.h |
| 6 | * @brief Error reporting and handling support |
| 7 | * @author syounan |
| 8 | * @sa wilc_oswrapper.h top level OS wrapper file |
| 9 | * @date 10 Aug 2010 |
| 10 | * @version 1.0 |
| 11 | */ |
| 12 | |
| 13 | #include "linux_wlan_common.h" |
| 14 | |
| 15 | /* Psitive Numbers to indicate sucess with special status */ |
Chaehyun Lim | 635c931 | 2015-06-15 12:35:48 +0900 | [diff] [blame] | 16 | #define WILC_ALREADY_EXSIT (+100) /** The requested object already exists */ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 17 | |
| 18 | /* Generic success will return 0 */ |
Chaehyun Lim | 635c931 | 2015-06-15 12:35:48 +0900 | [diff] [blame] | 19 | #define WILC_SUCCESS 0 /** Generic success */ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 20 | |
| 21 | /* Negative numbers to indicate failures */ |
Chaehyun Lim | 635c931 | 2015-06-15 12:35:48 +0900 | [diff] [blame] | 22 | #define WILC_FAIL -100 /** Generic Fail */ |
| 23 | #define WILC_BUSY -101 /** Busy with another operation*/ |
| 24 | #define WILC_INVALID_ARGUMENT -102 /** A given argument is invalid*/ |
| 25 | #define WILC_INVALID_STATE -103 /** An API request would violate the Driver state machine (i.e. to start PID while not camped)*/ |
| 26 | #define WILC_BUFFER_OVERFLOW -104 /** In copy operations if the copied data is larger than the allocated buffer*/ |
| 27 | #define WILC_NULL_PTR -105 /** null pointer is passed or used */ |
| 28 | #define WILC_EMPTY -107 |
| 29 | #define WILC_FULL -108 |
| 30 | #define WILC_TIMEOUT -109 |
| 31 | #define WILC_CANCELED -110 /** The required operation have been canceled by the user*/ |
| 32 | #define WILC_INVALID_FILE -112 /** The Loaded file is corruped or having an invalid format */ |
| 33 | #define WILC_NOT_FOUND -113 /** Cant find the file to load */ |
| 34 | #define WILC_NO_MEM -114 |
| 35 | #define WILC_UNSUPPORTED_VERSION -115 |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 36 | #define WILC_FILE_EOF -116 |
| 37 | |
| 38 | |
| 39 | /* Error type */ |
Chaehyun Lim | fb4ec9c | 2015-06-11 14:35:59 +0900 | [diff] [blame] | 40 | typedef s32 WILC_ErrNo; |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 41 | |
| 42 | #define WILC_IS_ERR(__status__) (__status__ < WILC_SUCCESS) |
| 43 | |
| 44 | #define WILC_ERRORCHECK(__status__) do { \ |
| 45 | if (WILC_IS_ERR(__status__)) { \ |
| 46 | PRINT_ER("PRINT_ER(%d)\n", __status__); \ |
| 47 | goto ERRORHANDLER; \ |
| 48 | } \ |
| 49 | } while (0) |
| 50 | |
| 51 | #define WILC_ERRORREPORT(__status__, __err__) do { \ |
| 52 | PRINT_ER("PRINT_ER(%d)\n", __err__); \ |
| 53 | __status__ = __err__; \ |
| 54 | goto ERRORHANDLER; \ |
| 55 | } while (0) |
| 56 | |
| 57 | #define WILC_NULLCHECK(__status__, __ptr__) do { \ |
Greg Kroah-Hartman | b1413b6 | 2015-06-02 14:11:12 +0900 | [diff] [blame] | 58 | if (__ptr__ == NULL) { \ |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 59 | WILC_ERRORREPORT(__status__, WILC_NULL_PTR); \ |
| 60 | } \ |
| 61 | } while (0) |
| 62 | |
| 63 | #define WILC_CATCH(__status__) \ |
| 64 | ERRORHANDLER: \ |
| 65 | if (WILC_IS_ERR(__status__)) \ |
| 66 | |
Johnny Kim | c5c77ba | 2015-05-11 14:30:56 +0900 | [diff] [blame] | 67 | #endif |