Files

38 lines
686 B
C
Raw Permalink Normal View History

2018-10-09 17:50:12 -07:00
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
#ifndef __LINUX_ERR_H
#define __LINUX_ERR_H
2018-10-09 21:45:49 -07:00
#include <linux/types.h>
2019-01-16 17:16:50 -08:00
#include <asm/errno.h>
2018-10-09 21:45:49 -07:00
#define MAX_ERRNO 4095
#define IS_ERR_VALUE(x) ((x) >= (unsigned long)-MAX_ERRNO)
2018-10-09 17:50:12 -07:00
static inline void * ERR_PTR(long error_)
{
2018-10-09 21:45:49 -07:00
return (void *) error_;
}
static inline long PTR_ERR(const void *ptr)
{
return (long) ptr;
}
static inline bool IS_ERR(const void *ptr)
{
return IS_ERR_VALUE((unsigned long)ptr);
}
static inline bool IS_ERR_OR_NULL(const void *ptr)
{
return (!ptr) || IS_ERR_VALUE((unsigned long)ptr);
2018-10-09 17:50:12 -07:00
}
2019-05-29 10:05:50 -07:00
static inline long PTR_ERR_OR_ZERO(const void *ptr)
{
return IS_ERR(ptr) ? PTR_ERR(ptr) : 0;
}
2018-10-09 17:50:12 -07:00
#endif