From: Guenter Roeck Date: Fri, 10 Jan 2014 00:12:52 +0000 (-0800) Subject: Add declaration of PTR_ERR_OR_ZERO for kernels prior to 3.12 X-Git-Url: https://git.sur5r.net/?p=groeck-nct6775;a=commitdiff_plain;h=e7641b37f042e8476d1825a0043cc4dd9d665712 Add declaration of PTR_ERR_OR_ZERO for kernels prior to 3.12 Signed-off-by: Guenter Roeck --- diff --git a/compat.h b/compat.h index de13589..0a46c0d 100644 --- a/compat.h +++ b/compat.h @@ -39,6 +39,14 @@ static void sysfs_remove_groups(struct kobject *kobj, sysfs_remove_group(kobj, groups[i]); } +static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr) +{ + if (IS_ERR(ptr)) + return PTR_ERR(ptr); + else + return 0; +} + #endif #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 21)