| /* |
| * Copyright 2004-2015 Freescale Semiconductor, Inc. All Rights Reserved. |
| */ |
| |
| /* |
| * The code contained herein is licensed under the GNU Lesser General |
| * Public License. You may obtain a copy of the GNU Lesser General |
| * Public License Version 2.1 or later at the following locations: |
| * |
| * http://www.opensource.org/licenses/lgpl-license.html |
| * http://www.gnu.org/copyleft/lgpl.html |
| */ |
| #ifndef __ASM_ARCH_MXC_PMIC_STATUS_H__ |
| #define __ASM_ARCH_MXC_PMIC_STATUS_H__ |
| #include <asm-generic/errno-base.h> |
| #ifdef __KERNEL__ |
| #include <asm/uaccess.h> /* copy_{from,to}_user() */ |
| #endif |
| /*! |
| * @file arch-mxc/pmic_status.h |
| * @brief PMIC APIs return code definition. |
| * |
| * @ingroup PMIC_CORE |
| */ |
| |
| /*! |
| * @enum PMIC_STATUS |
| * @brief Define return values for all PMIC APIs. |
| * |
| * These return values are used by all of the PMIC APIs. |
| * |
| * @ingroup PMIC |
| */ |
| typedef enum { |
| PMIC_SUCCESS = 0, /*!< The requested operation was successfully |
| completed. */ |
| PMIC_ERROR = -1, /*!< The requested operation could not be completed |
| due to an error. */ |
| PMIC_PARAMETER_ERROR = -2, /*!< The requested operation failed because |
| one or more of the parameters was |
| invalid. */ |
| PMIC_NOT_SUPPORTED = -3, /*!< The requested operation could not be |
| completed because the PMIC hardware |
| does not support it. */ |
| PMIC_SYSTEM_ERROR_EINTR = -EINTR, |
| |
| PMIC_MALLOC_ERROR = -5, /*!< Error in malloc function */ |
| PMIC_UNSUBSCRIBE_ERROR = -6, /*!< Error in un-subscribe event */ |
| PMIC_EVENT_NOT_SUBSCRIBED = -7, /*!< Event occur and not subscribed */ |
| PMIC_EVENT_CALL_BACK = -8, /*!< Error - bad call back */ |
| PMIC_CLIENT_NBOVERFLOW = -9, /*!< The requested operation could not be |
| completed because there are too many |
| PMIC client requests */ |
| } PMIC_STATUS; |
| |
| /* |
| * Bitfield macros that use rely on bitfield width/shift information. |
| */ |
| #define BITFMASK(field) (((1U << (field ## _WID)) - 1) << (field ## _LSH)) |
| #define BITFVAL(field, val) ((val) << (field ## _LSH)) |
| #define BITFEXT(var, bit) ((var & BITFMASK(bit)) >> (bit ## _LSH)) |
| |
| /* |
| * Macros implementing error handling |
| */ |
| #define CHECK_ERROR(a) \ |
| do { \ |
| int ret = (a); \ |
| if (ret != PMIC_SUCCESS) \ |
| return ret; \ |
| } while (0) |
| |
| #define CHECK_ERROR_KFREE(func, freeptrs) \ |
| do { \ |
| int ret = (func); \ |
| if (ret != PMIC_SUCCESS) { \ |
| freeptrs; \ |
| return ret; \ |
| } \ |
| } while (0); |
| |
| #endif /* __ASM_ARCH_MXC_PMIC_STATUS_H__ */ |