err.h 813 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef _LINUX_ERR_H
  2. #define _LINUX_ERR_H
  3. /* XXX U-BOOT XXX */
  4. #if 0
  5. #include <linux/compiler.h>
  6. #else
  7. #include <linux/mtd/compat.h>
  8. #endif
  9. #include <asm/errno.h>
  10. /*
  11. * Kernel pointers have redundant information, so we can use a
  12. * scheme where we can return either an error code or a dentry
  13. * pointer with the same return value.
  14. *
  15. * This should be a per-architecture thing, to allow different
  16. * error and pointer decisions.
  17. */
  18. #define MAX_ERRNO 4095
  19. #ifndef __ASSEMBLY__
  20. #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
  21. static inline void *ERR_PTR(long error)
  22. {
  23. return (void *) error;
  24. }
  25. static inline long PTR_ERR(const void *ptr)
  26. {
  27. return (long) ptr;
  28. }
  29. static inline long IS_ERR(const void *ptr)
  30. {
  31. return IS_ERR_VALUE((unsigned long)ptr);
  32. }
  33. #endif
  34. #endif /* _LINUX_ERR_H */