Message ID | 1373028204-2591-1-git-send-email-colin.king@canonical.com |
---|---|
State | Accepted |
Headers | show |
On 07/05/2013 08:43 PM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > On an old 3.0 kernel we get: > > make -C /lib/modules/`uname -r`/build M=`pwd` modules > make[1]: Entering directory `/usr/src/linux-headers-3.0.0-12-generic' > CC [M] /home/king/fwts/efi_runtime/efi_runtime.o > /home/king/fwts/efi_runtime/efi_runtime.c: In function ‘efi_runtime_ioctl’: > /home/king/fwts/efi_runtime/efi_runtime.c:285:15: error: ‘struct efi’ has no member named ‘query_variable_info’ > /home/king/fwts/efi_runtime/efi_runtime.c:315:15: error: ‘struct efi’ has no member named ‘query_capsule_caps’ > /home/king/fwts/efi_runtime/efi_runtime.c:316:6: error: ‘efi_capsule_header_t’ undeclared (first use in this function) > /home/king/fwts/efi_runtime/efi_runtime.c:316:6: note: each undeclared identifier is reported only once for each function it appears in > /home/king/fwts/efi_runtime/efi_runtime.c:316:29: error: expected expression before ‘)’ token > make[2]: *** [/home/king/fwts/efi_runtime/efi_runtime.o] Error 1 > make[1]: *** [_module_/home/king/fwts/efi_runtime] Error 2 > make[1]: Leaving directory `/usr/src/linux-headers-3.0.0-12-generic' > make: *** [all] Error 2 > > ..since query_variable_info and query_capsule_caps are really supported until > 3.1 lets make these conditional on the kernel version. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > efi_runtime/efi_runtime.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c > index 73171df..b08ce0e 100644 > --- a/efi_runtime/efi_runtime.c > +++ b/efi_runtime/efi_runtime.c > @@ -18,6 +18,7 @@ > * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. > */ > > +#include <linux/version.h> > #include <linux/miscdevice.h> > #include <linux/module.h> > #include <linux/init.h> > @@ -124,11 +125,11 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, > struct efi_getnextvariablename __user *pgetnextvariablename; > unsigned long name_size; > > - struct efi_queryvariableinfo __user *pqueryvariableinfo; > - > struct efi_getnexthighmonotoniccount __user *pgetnexthighmonotoniccount; > - > +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) > + struct efi_queryvariableinfo __user *pqueryvariableinfo; > struct efi_querycapsulecapabilities __user *pquerycapsulecapabilities; > +#endif > > switch (cmd) { > case EFI_RUNTIME_GET_VARIABLE: > @@ -275,6 +276,7 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, > return -EINVAL; > return 0; > > +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) > case EFI_RUNTIME_QUERY_VARIABLEINFO: > > pqueryvariableinfo = (struct efi_queryvariableinfo __user *)arg; > @@ -292,6 +294,7 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, > return -EINVAL; > > return 0; > +#endif > > case EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT: > > @@ -307,6 +310,7 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, > > return 0; > > +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) > case EFI_RUNTIME_QUERY_CAPSULECAPABILITIES: > > pquerycapsulecapabilities = (struct > @@ -325,6 +329,7 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, > return -EINVAL; > > return 0; > +#endif > } > > return -ENOTTY; > Acked-by: Alex Hung <alex.hung@canonical.com>
On 07/05/2013 08:43 PM, Colin King wrote: > From: Colin Ian King <colin.king@canonical.com> > > On an old 3.0 kernel we get: > > make -C /lib/modules/`uname -r`/build M=`pwd` modules > make[1]: Entering directory `/usr/src/linux-headers-3.0.0-12-generic' > CC [M] /home/king/fwts/efi_runtime/efi_runtime.o > /home/king/fwts/efi_runtime/efi_runtime.c: In function ‘efi_runtime_ioctl’: > /home/king/fwts/efi_runtime/efi_runtime.c:285:15: error: ‘struct efi’ has no member named ‘query_variable_info’ > /home/king/fwts/efi_runtime/efi_runtime.c:315:15: error: ‘struct efi’ has no member named ‘query_capsule_caps’ > /home/king/fwts/efi_runtime/efi_runtime.c:316:6: error: ‘efi_capsule_header_t’ undeclared (first use in this function) > /home/king/fwts/efi_runtime/efi_runtime.c:316:6: note: each undeclared identifier is reported only once for each function it appears in > /home/king/fwts/efi_runtime/efi_runtime.c:316:29: error: expected expression before ‘)’ token > make[2]: *** [/home/king/fwts/efi_runtime/efi_runtime.o] Error 1 > make[1]: *** [_module_/home/king/fwts/efi_runtime] Error 2 > make[1]: Leaving directory `/usr/src/linux-headers-3.0.0-12-generic' > make: *** [all] Error 2 > > ..since query_variable_info and query_capsule_caps are really supported until > 3.1 lets make these conditional on the kernel version. > > Signed-off-by: Colin Ian King <colin.king@canonical.com> > --- > efi_runtime/efi_runtime.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c > index 73171df..b08ce0e 100644 > --- a/efi_runtime/efi_runtime.c > +++ b/efi_runtime/efi_runtime.c > @@ -18,6 +18,7 @@ > * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. > */ > > +#include <linux/version.h> > #include <linux/miscdevice.h> > #include <linux/module.h> > #include <linux/init.h> > @@ -124,11 +125,11 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, > struct efi_getnextvariablename __user *pgetnextvariablename; > unsigned long name_size; > > - struct efi_queryvariableinfo __user *pqueryvariableinfo; > - > struct efi_getnexthighmonotoniccount __user *pgetnexthighmonotoniccount; > - > +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) > + struct efi_queryvariableinfo __user *pqueryvariableinfo; > struct efi_querycapsulecapabilities __user *pquerycapsulecapabilities; > +#endif > > switch (cmd) { > case EFI_RUNTIME_GET_VARIABLE: > @@ -275,6 +276,7 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, > return -EINVAL; > return 0; > > +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) > case EFI_RUNTIME_QUERY_VARIABLEINFO: > > pqueryvariableinfo = (struct efi_queryvariableinfo __user *)arg; > @@ -292,6 +294,7 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, > return -EINVAL; > > return 0; > +#endif > > case EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT: > > @@ -307,6 +310,7 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, > > return 0; > > +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) > case EFI_RUNTIME_QUERY_CAPSULECAPABILITIES: > > pquerycapsulecapabilities = (struct > @@ -325,6 +329,7 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, > return -EINVAL; > > return 0; > +#endif > } > > return -ENOTTY; > Acked-by: Ivan Hu <ivan.hu@canonical.com>
diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c index 73171df..b08ce0e 100644 --- a/efi_runtime/efi_runtime.c +++ b/efi_runtime/efi_runtime.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include <linux/version.h> #include <linux/miscdevice.h> #include <linux/module.h> #include <linux/init.h> @@ -124,11 +125,11 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, struct efi_getnextvariablename __user *pgetnextvariablename; unsigned long name_size; - struct efi_queryvariableinfo __user *pqueryvariableinfo; - struct efi_getnexthighmonotoniccount __user *pgetnexthighmonotoniccount; - +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) + struct efi_queryvariableinfo __user *pqueryvariableinfo; struct efi_querycapsulecapabilities __user *pquerycapsulecapabilities; +#endif switch (cmd) { case EFI_RUNTIME_GET_VARIABLE: @@ -275,6 +276,7 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, return -EINVAL; return 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) case EFI_RUNTIME_QUERY_VARIABLEINFO: pqueryvariableinfo = (struct efi_queryvariableinfo __user *)arg; @@ -292,6 +294,7 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, return -EINVAL; return 0; +#endif case EFI_RUNTIME_GET_NEXTHIGHMONOTONICCOUNT: @@ -307,6 +310,7 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, return 0; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0) case EFI_RUNTIME_QUERY_CAPSULECAPABILITIES: pquerycapsulecapabilities = (struct @@ -325,6 +329,7 @@ static long efi_runtime_ioctl(struct file *file, unsigned int cmd, return -EINVAL; return 0; +#endif } return -ENOTTY;