From: Hauke Mehrtens Date: Sun, 3 Feb 2013 13:01:39 +0000 (+0100) Subject: compat: add efi_enabled() X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=3e1afb65a6fa6d964c1bbc9b2f4fc89c31d42d1a;p=openwrt%2Fstaging%2Fblogic.git compat: add efi_enabled() Signed-off-by: Hauke Mehrtens --- diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index 942b4cbd3190..3af253b9a868 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -7,6 +7,7 @@ #include #include +#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,5)) extern void netdev_set_default_ethtool_ops(struct net_device *dev, @@ -49,6 +50,60 @@ static inline int __must_check kref_get_unless_zero(struct kref *kref) { return atomic_add_unless(&kref->refcount, 1, 0); } + +/* This backports: + * + * commit 83e68189745ad931c2afd45d8ee3303929233e7f + * Author: Matt Fleming + * Date: Wed Nov 14 09:42:35 2012 +0000 + * + * efi: Make 'efi_enabled' a function to query EFI facilities + * + */ +/* + * We play games with efi_enabled so that the compiler will, if + * possible, remove EFI-related code altogether. + */ +#define EFI_BOOT 0 /* Were we booted from EFI? */ +#define EFI_SYSTEM_TABLES 1 /* Can we use EFI system tables? */ +#define EFI_CONFIG_TABLES 2 /* Can we use EFI config tables? */ +#define EFI_RUNTIME_SERVICES 3 /* Can we use runtime services? */ +#define EFI_MEMMAP 4 /* Can we use EFI memory map? */ +#define EFI_64BIT 5 /* Is the firmware 64-bit? */ + +#ifdef CONFIG_EFI +# ifdef CONFIG_X86 +static inline int compat_efi_enabled(int facility) +{ + switch (facility) { + case EFI_BOOT: + return efi_enabled; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) + case EFI_64BIT: + return efi_64bit; +#endif + default: + printk(KERN_ERR "can not translate efi_enabled() to old values completly\n"); + return efi_enabled; + } +} +# else +static inline int compat_efi_enabled(int facility) +{ + return 1; +} +# endif +#else +static inline int compat_efi_enabled(int facility) +{ + return 0; +} +#endif +#ifdef efi_enabled +#undef efi_enabled +#endif +#define efi_enabled(facility) compat_efi_enabled(facility) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) */ #endif /* LINUX_3_8_COMPAT_H */