[DM/MISC] Add error no for ptr
When the driver request a API gets RT_NULL which return value is ptr, they could not know why get a RT_NULL. some API return RT_NULL, is not error internal maybe, it just not supported for this platform, but the driver still could work ok, the API can return (RT_NULL + -RT_EEMPTY) to driver. on the other hand, the driver can do more behaviors by error no. When the API return the -RT_EBUSY, driver can wait for a moment and retry. When the API return the -RT_ENOSYS, driver can try the next mode or request's name. Signed-off-by: GuEe-GUI <wusongjie@rt-thread.com>
This commit is contained in:
parent
0df9a9f0cc
commit
f9b632d52d
|
@ -54,6 +54,12 @@
|
||||||
|
|
||||||
#define rt_offsetof(s, field) ((rt_size_t)&((s *)0)->field)
|
#define rt_offsetof(s, field) ((rt_size_t)&((s *)0)->field)
|
||||||
|
|
||||||
|
#define rt_err_ptr(err) ((void *)(rt_base_t)(err))
|
||||||
|
#define rt_ptr_err(ptr) ((rt_err_t)(rt_base_t)(ptr))
|
||||||
|
#define rt_is_err_value(ptr) ((rt_ubase_t)(void *)(ptr) >= (rt_ubase_t)-4095)
|
||||||
|
#define rt_is_err(ptr) rt_is_err_value(ptr)
|
||||||
|
#define rt_is_err_or_null(ptr) (!(ptr) || rt_is_err_value((rt_ubase_t)(ptr)))
|
||||||
|
|
||||||
#define rt_upper_32_bits(n) ((rt_uint32_t)(((n) >> 16) >> 16))
|
#define rt_upper_32_bits(n) ((rt_uint32_t)(((n) >> 16) >> 16))
|
||||||
#define rt_lower_32_bits(n) ((rt_uint32_t)((n) & 0xffffffff))
|
#define rt_lower_32_bits(n) ((rt_uint32_t)((n) & 0xffffffff))
|
||||||
#define rt_upper_16_bits(n) ((rt_uint16_t)((n) >> 16))
|
#define rt_upper_16_bits(n) ((rt_uint16_t)((n) >> 16))
|
||||||
|
|
Loading…
Reference in New Issue