diff mbox

[1/3] efi_runtime: reuse the in-kernel time structure

Message ID 1467798708-26701-1-git-send-email-ivan.hu@canonical.com
State Accepted
Headers show

Commit Message

Ivan Hu July 6, 2016, 9:51 a.m. UTC
reuse the in-kernel time structure efi_time_t instead of making our own.

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
---
 efi_runtime/efi_runtime.c | 74 ++++++++++++-----------------------------------
 efi_runtime/efi_runtime.h | 30 ++++---------------
 2 files changed, 23 insertions(+), 81 deletions(-)

Comments

Colin Ian King July 6, 2016, 9:55 a.m. UTC | #1
On 06/07/16 10:51, Ivan Hu wrote:
> reuse the in-kernel time structure efi_time_t instead of making our own.
> 
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>  efi_runtime/efi_runtime.c | 74 ++++++++++++-----------------------------------
>  efi_runtime/efi_runtime.h | 30 ++++---------------
>  2 files changed, 23 insertions(+), 81 deletions(-)
> 
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 115b1b5..4c83800 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -42,38 +42,6 @@ MODULE_LICENSE("GPL");
>  #define EFI_RUNTIME_ENABLED	efi_enabled
>  #endif
>  
> -static void convert_from_efi_time(efi_time_t *eft, EFI_TIME *time)
> -{
> -	memset(time, 0, sizeof(EFI_TIME));
> -	time->Year = eft->year;
> -	time->Month = eft->month;
> -	time->Day  = eft->day;
> -	time->Hour = eft->hour;
> -	time->Minute = eft->minute;
> -	time->Second  = eft->second;
> -	time->Pad1 = eft->pad1;
> -	time->Nanosecond = eft->nanosecond;
> -	time->TimeZone = eft->timezone;
> -	time->Daylight = eft->daylight;
> -	time->Pad2 = eft->pad2;
> -}
> -
> -static void convert_to_efi_time(efi_time_t *eft, EFI_TIME *time)
> -{
> -	memset(eft, 0, sizeof(*eft));
> -	eft->year = time->Year;
> -	eft->month = time->Month;
> -	eft->day = time->Day;
> -	eft->hour = time->Hour;
> -	eft->minute = time->Minute;
> -	eft->second = time->Second;
> -	eft->pad1 = time->Pad1;
> -	eft->nanosecond = time->Nanosecond;
> -	eft->timezone = time->TimeZone;
> -	eft->daylight = time->Daylight;
> -	eft->pad2 = time->Pad2;
> -}
> -
>  /*
>   * Count the bytes in 'str', including the terminating NULL.
>   *
> @@ -332,13 +300,13 @@ static long efi_runtime_get_time(unsigned long arg)
>  	struct efi_gettime  gettime_local;
>  	efi_status_t status;
>  	efi_time_cap_t cap;
> -	efi_time_t eft;
> +	efi_time_t efi_time;
>  
>  	gettime = (struct efi_gettime __user *)arg;
>  	if (copy_from_user(&gettime_local, gettime, sizeof(gettime_local)))
>  		return -EFAULT;
>  
> -	status = efi.get_time(gettime_local.Time ? &eft : NULL,
> +	status = efi.get_time(gettime_local.Time ? &efi_time : NULL,
>  			      gettime_local.Capabilities ? &cap : NULL);
>  
>  	if (put_user(status, gettime_local.status))
> @@ -348,18 +316,18 @@ static long efi_runtime_get_time(unsigned long arg)
>  		return -EINVAL;
>  	}
>  	if (gettime_local.Capabilities) {
> -		EFI_TIME_CAPABILITIES __user *cap_local;
> +		efi_time_cap_t __user *cap_local;
>  
> -		cap_local = (EFI_TIME_CAPABILITIES *)gettime_local.Capabilities;
> +		cap_local = (efi_time_cap_t *)gettime_local.Capabilities;
>  		if (put_user(cap.resolution,
> -				&(cap_local->Resolution)) ||
> -				put_user(cap.accuracy, &(cap_local->Accuracy)) ||
> -				put_user(cap.sets_to_zero,&(cap_local->SetsToZero)))
> +				&(cap_local->resolution)) ||
> +				put_user(cap.accuracy, &(cap_local->accuracy)) ||
> +				put_user(cap.sets_to_zero,&(cap_local->sets_to_zero)))
>  			return -EFAULT;
>  	}
>  	if (gettime_local.Time)
> -		return copy_to_user(gettime_local.Time, &eft,
> -			sizeof(EFI_TIME)) ? -EFAULT : 0;
> +		return copy_to_user(gettime_local.Time, &efi_time,
> +			sizeof(efi_time_t)) ? -EFAULT : 0;
>  	return 0;
>  }
>  
> @@ -368,17 +336,15 @@ static long efi_runtime_set_time(unsigned long arg)
>  	struct efi_settime __user *settime;
>  	struct efi_settime settime_local;
>  	efi_status_t status;
> -	EFI_TIME efi_time;
> -	efi_time_t eft;
> +	efi_time_t efi_time;
>  
>  	settime = (struct efi_settime __user *)arg;
>  	if (copy_from_user(&settime_local, settime, sizeof(settime_local)))
>  		return -EFAULT;
>  	if (copy_from_user(&efi_time, settime_local.Time,
> -					sizeof(EFI_TIME)))
> +					sizeof(efi_time_t)))
>  		return -EFAULT;
> -	convert_to_efi_time(&eft, &efi_time);
> -	status = efi.set_time(&eft);
> +	status = efi.set_time(&efi_time);
>  
>  	if (put_user(status, settime_local.status))
>  		return -EFAULT;
> @@ -392,8 +358,7 @@ static long efi_runtime_get_waketime(unsigned long arg)
>  	struct efi_getwakeuptime getwakeuptime_local;
>  	unsigned char enabled, pending;
>  	efi_status_t status;
> -	EFI_TIME efi_time;
> -	efi_time_t eft;
> +	efi_time_t efi_time;
>  
>  	getwakeuptime = (struct efi_getwakeuptime __user *)arg;
>  	if (copy_from_user(&getwakeuptime_local, getwakeuptime, sizeof(getwakeuptime_local)))
> @@ -402,7 +367,7 @@ static long efi_runtime_get_waketime(unsigned long arg)
>  	status = efi.get_wakeup_time(
>  		getwakeuptime_local.Enabled ? (efi_bool_t *)&enabled : NULL,
>  		getwakeuptime_local.Pending ? (efi_bool_t *)&pending : NULL,
> -		getwakeuptime_local.Time ? &eft : NULL);
> +		getwakeuptime_local.Time ? &efi_time : NULL);
>  
>  	if (put_user(status, getwakeuptime_local.status))
>  		return -EFAULT;
> @@ -410,11 +375,10 @@ static long efi_runtime_get_waketime(unsigned long arg)
>  		return -EINVAL;
>  	if (getwakeuptime_local.Enabled && put_user(enabled, getwakeuptime_local.Enabled))
>  		return -EFAULT;
> -	convert_from_efi_time(&eft, &efi_time);
>  
>  	if (getwakeuptime_local.Time)
>  		return copy_to_user(getwakeuptime_local.Time, &efi_time,
> -			sizeof(EFI_TIME)) ? -EFAULT : 0;
> +			sizeof(efi_time_t)) ? -EFAULT : 0;
>  	return 0;
>  }
>  
> @@ -424,8 +388,7 @@ static long efi_runtime_set_waketime(unsigned long arg)
>  	struct efi_setwakeuptime setwakeuptime_local;
>  	unsigned char enabled;
>  	efi_status_t status;
> -	EFI_TIME efi_time;
> -	efi_time_t eft;
> +	efi_time_t efi_time;
>  
>  	setwakeuptime = (struct efi_setwakeuptime __user *)arg;
>  
> @@ -434,11 +397,10 @@ static long efi_runtime_set_waketime(unsigned long arg)
>  
>  	enabled = setwakeuptime_local.Enabled;
>  	if (setwakeuptime_local.Time) {
> -		if (copy_from_user(&efi_time, setwakeuptime_local.Time, sizeof(EFI_TIME)))
> +		if (copy_from_user(&efi_time, setwakeuptime_local.Time, sizeof(efi_time_t)))
>  			return -EFAULT;
>  
> -		convert_to_efi_time(&eft, &efi_time);
> -		status = efi.set_wakeup_time(enabled, &eft);
> +		status = efi.set_wakeup_time(enabled, &efi_time);
>  	} else {
>  		status = efi.set_wakeup_time(enabled, NULL);
>  	}
> diff --git a/efi_runtime/efi_runtime.h b/efi_runtime/efi_runtime.h
> index 092e842..b9177d4 100644
> --- a/efi_runtime/efi_runtime.h
> +++ b/efi_runtime/efi_runtime.h
> @@ -30,26 +30,6 @@ typedef enum {
>  } EFI_RESET_TYPE;
>  
>  typedef struct {
> -	uint16_t	Year;		/* 1900 – 9999 */
> -	uint8_t		Month;		/* 1 – 12 */
> -	uint8_t		Day;		/* 1 – 31 */
> -	uint8_t		Hour;		/* 0 – 23 */
> -	uint8_t		Minute;		/* 0 – 59 */
> -	uint8_t		Second;		/* 0 – 59 */
> -	uint8_t		Pad1;
> -	uint32_t	Nanosecond;	/* 0 – 999,999,999 */
> -	int16_t		TimeZone;	/* -1440 to 1440 or 2047 */
> -	uint8_t		Daylight;
> -	uint8_t		Pad2;
> -} __attribute__ ((packed)) EFI_TIME;
> -
> -typedef struct {
> -	uint32_t	Resolution;
> -	uint32_t	Accuracy;
> -	uint8_t		SetsToZero;
> -} __attribute__ ((packed)) EFI_TIME_CAPABILITIES;
> -
> -typedef struct {
>  	efi_guid_t CapsuleGuid;
>  	uint32_t HeaderSize;
>  	uint32_t Flags;
> @@ -90,26 +70,26 @@ struct efi_queryvariableinfo {
>  } __attribute__ ((packed));
>  
>  struct efi_gettime {
> -	EFI_TIME		*Time;
> -	EFI_TIME_CAPABILITIES	*Capabilities;
> +	efi_time_t		*Time;
> +	efi_time_cap_t		*Capabilities;
>  	uint64_t		*status;
>  } __attribute__ ((packed));
>  
>  struct efi_settime {
> -	EFI_TIME		*Time;
> +	efi_time_t		*Time;
>  	uint64_t		*status;
>  } __attribute__ ((packed));
>  
>  struct efi_getwakeuptime {
>  	uint8_t		*Enabled;
>  	uint8_t		*Pending;
> -	EFI_TIME	*Time;
> +	efi_time_t	*Time;
>  	uint64_t	*status;
>  } __attribute__ ((packed));
>  
>  struct efi_setwakeuptime {
>  	uint8_t		Enabled;
> -	EFI_TIME	*Time;
> +	efi_time_t	*Time;
>  	uint64_t	*status;
>  } __attribute__ ((packed));
>  
> 
> 
> 
Acked-by: Colin Ian King <colin.king@canonical.com>
Alex Hung July 7, 2016, 3:15 a.m. UTC | #2
On 2016-07-06 05:51 PM, Ivan Hu wrote:
> reuse the in-kernel time structure efi_time_t instead of making our own.
>
> Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
> ---
>   efi_runtime/efi_runtime.c | 74 ++++++++++++-----------------------------------
>   efi_runtime/efi_runtime.h | 30 ++++---------------
>   2 files changed, 23 insertions(+), 81 deletions(-)
>
> diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
> index 115b1b5..4c83800 100644
> --- a/efi_runtime/efi_runtime.c
> +++ b/efi_runtime/efi_runtime.c
> @@ -42,38 +42,6 @@ MODULE_LICENSE("GPL");
>   #define EFI_RUNTIME_ENABLED	efi_enabled
>   #endif
>
> -static void convert_from_efi_time(efi_time_t *eft, EFI_TIME *time)
> -{
> -	memset(time, 0, sizeof(EFI_TIME));
> -	time->Year = eft->year;
> -	time->Month = eft->month;
> -	time->Day  = eft->day;
> -	time->Hour = eft->hour;
> -	time->Minute = eft->minute;
> -	time->Second  = eft->second;
> -	time->Pad1 = eft->pad1;
> -	time->Nanosecond = eft->nanosecond;
> -	time->TimeZone = eft->timezone;
> -	time->Daylight = eft->daylight;
> -	time->Pad2 = eft->pad2;
> -}
> -
> -static void convert_to_efi_time(efi_time_t *eft, EFI_TIME *time)
> -{
> -	memset(eft, 0, sizeof(*eft));
> -	eft->year = time->Year;
> -	eft->month = time->Month;
> -	eft->day = time->Day;
> -	eft->hour = time->Hour;
> -	eft->minute = time->Minute;
> -	eft->second = time->Second;
> -	eft->pad1 = time->Pad1;
> -	eft->nanosecond = time->Nanosecond;
> -	eft->timezone = time->TimeZone;
> -	eft->daylight = time->Daylight;
> -	eft->pad2 = time->Pad2;
> -}
> -
>   /*
>    * Count the bytes in 'str', including the terminating NULL.
>    *
> @@ -332,13 +300,13 @@ static long efi_runtime_get_time(unsigned long arg)
>   	struct efi_gettime  gettime_local;
>   	efi_status_t status;
>   	efi_time_cap_t cap;
> -	efi_time_t eft;
> +	efi_time_t efi_time;
>
>   	gettime = (struct efi_gettime __user *)arg;
>   	if (copy_from_user(&gettime_local, gettime, sizeof(gettime_local)))
>   		return -EFAULT;
>
> -	status = efi.get_time(gettime_local.Time ? &eft : NULL,
> +	status = efi.get_time(gettime_local.Time ? &efi_time : NULL,
>   			      gettime_local.Capabilities ? &cap : NULL);
>
>   	if (put_user(status, gettime_local.status))
> @@ -348,18 +316,18 @@ static long efi_runtime_get_time(unsigned long arg)
>   		return -EINVAL;
>   	}
>   	if (gettime_local.Capabilities) {
> -		EFI_TIME_CAPABILITIES __user *cap_local;
> +		efi_time_cap_t __user *cap_local;
>
> -		cap_local = (EFI_TIME_CAPABILITIES *)gettime_local.Capabilities;
> +		cap_local = (efi_time_cap_t *)gettime_local.Capabilities;
>   		if (put_user(cap.resolution,
> -				&(cap_local->Resolution)) ||
> -				put_user(cap.accuracy, &(cap_local->Accuracy)) ||
> -				put_user(cap.sets_to_zero,&(cap_local->SetsToZero)))
> +				&(cap_local->resolution)) ||
> +				put_user(cap.accuracy, &(cap_local->accuracy)) ||
> +				put_user(cap.sets_to_zero,&(cap_local->sets_to_zero)))
>   			return -EFAULT;
>   	}
>   	if (gettime_local.Time)
> -		return copy_to_user(gettime_local.Time, &eft,
> -			sizeof(EFI_TIME)) ? -EFAULT : 0;
> +		return copy_to_user(gettime_local.Time, &efi_time,
> +			sizeof(efi_time_t)) ? -EFAULT : 0;
>   	return 0;
>   }
>
> @@ -368,17 +336,15 @@ static long efi_runtime_set_time(unsigned long arg)
>   	struct efi_settime __user *settime;
>   	struct efi_settime settime_local;
>   	efi_status_t status;
> -	EFI_TIME efi_time;
> -	efi_time_t eft;
> +	efi_time_t efi_time;
>
>   	settime = (struct efi_settime __user *)arg;
>   	if (copy_from_user(&settime_local, settime, sizeof(settime_local)))
>   		return -EFAULT;
>   	if (copy_from_user(&efi_time, settime_local.Time,
> -					sizeof(EFI_TIME)))
> +					sizeof(efi_time_t)))
>   		return -EFAULT;
> -	convert_to_efi_time(&eft, &efi_time);
> -	status = efi.set_time(&eft);
> +	status = efi.set_time(&efi_time);
>
>   	if (put_user(status, settime_local.status))
>   		return -EFAULT;
> @@ -392,8 +358,7 @@ static long efi_runtime_get_waketime(unsigned long arg)
>   	struct efi_getwakeuptime getwakeuptime_local;
>   	unsigned char enabled, pending;
>   	efi_status_t status;
> -	EFI_TIME efi_time;
> -	efi_time_t eft;
> +	efi_time_t efi_time;
>
>   	getwakeuptime = (struct efi_getwakeuptime __user *)arg;
>   	if (copy_from_user(&getwakeuptime_local, getwakeuptime, sizeof(getwakeuptime_local)))
> @@ -402,7 +367,7 @@ static long efi_runtime_get_waketime(unsigned long arg)
>   	status = efi.get_wakeup_time(
>   		getwakeuptime_local.Enabled ? (efi_bool_t *)&enabled : NULL,
>   		getwakeuptime_local.Pending ? (efi_bool_t *)&pending : NULL,
> -		getwakeuptime_local.Time ? &eft : NULL);
> +		getwakeuptime_local.Time ? &efi_time : NULL);
>
>   	if (put_user(status, getwakeuptime_local.status))
>   		return -EFAULT;
> @@ -410,11 +375,10 @@ static long efi_runtime_get_waketime(unsigned long arg)
>   		return -EINVAL;
>   	if (getwakeuptime_local.Enabled && put_user(enabled, getwakeuptime_local.Enabled))
>   		return -EFAULT;
> -	convert_from_efi_time(&eft, &efi_time);
>
>   	if (getwakeuptime_local.Time)
>   		return copy_to_user(getwakeuptime_local.Time, &efi_time,
> -			sizeof(EFI_TIME)) ? -EFAULT : 0;
> +			sizeof(efi_time_t)) ? -EFAULT : 0;
>   	return 0;
>   }
>
> @@ -424,8 +388,7 @@ static long efi_runtime_set_waketime(unsigned long arg)
>   	struct efi_setwakeuptime setwakeuptime_local;
>   	unsigned char enabled;
>   	efi_status_t status;
> -	EFI_TIME efi_time;
> -	efi_time_t eft;
> +	efi_time_t efi_time;
>
>   	setwakeuptime = (struct efi_setwakeuptime __user *)arg;
>
> @@ -434,11 +397,10 @@ static long efi_runtime_set_waketime(unsigned long arg)
>
>   	enabled = setwakeuptime_local.Enabled;
>   	if (setwakeuptime_local.Time) {
> -		if (copy_from_user(&efi_time, setwakeuptime_local.Time, sizeof(EFI_TIME)))
> +		if (copy_from_user(&efi_time, setwakeuptime_local.Time, sizeof(efi_time_t)))
>   			return -EFAULT;
>
> -		convert_to_efi_time(&eft, &efi_time);
> -		status = efi.set_wakeup_time(enabled, &eft);
> +		status = efi.set_wakeup_time(enabled, &efi_time);
>   	} else {
>   		status = efi.set_wakeup_time(enabled, NULL);
>   	}
> diff --git a/efi_runtime/efi_runtime.h b/efi_runtime/efi_runtime.h
> index 092e842..b9177d4 100644
> --- a/efi_runtime/efi_runtime.h
> +++ b/efi_runtime/efi_runtime.h
> @@ -30,26 +30,6 @@ typedef enum {
>   } EFI_RESET_TYPE;
>
>   typedef struct {
> -	uint16_t	Year;		/* 1900 – 9999 */
> -	uint8_t		Month;		/* 1 – 12 */
> -	uint8_t		Day;		/* 1 – 31 */
> -	uint8_t		Hour;		/* 0 – 23 */
> -	uint8_t		Minute;		/* 0 – 59 */
> -	uint8_t		Second;		/* 0 – 59 */
> -	uint8_t		Pad1;
> -	uint32_t	Nanosecond;	/* 0 – 999,999,999 */
> -	int16_t		TimeZone;	/* -1440 to 1440 or 2047 */
> -	uint8_t		Daylight;
> -	uint8_t		Pad2;
> -} __attribute__ ((packed)) EFI_TIME;
> -
> -typedef struct {
> -	uint32_t	Resolution;
> -	uint32_t	Accuracy;
> -	uint8_t		SetsToZero;
> -} __attribute__ ((packed)) EFI_TIME_CAPABILITIES;
> -
> -typedef struct {
>   	efi_guid_t CapsuleGuid;
>   	uint32_t HeaderSize;
>   	uint32_t Flags;
> @@ -90,26 +70,26 @@ struct efi_queryvariableinfo {
>   } __attribute__ ((packed));
>
>   struct efi_gettime {
> -	EFI_TIME		*Time;
> -	EFI_TIME_CAPABILITIES	*Capabilities;
> +	efi_time_t		*Time;
> +	efi_time_cap_t		*Capabilities;
>   	uint64_t		*status;
>   } __attribute__ ((packed));
>
>   struct efi_settime {
> -	EFI_TIME		*Time;
> +	efi_time_t		*Time;
>   	uint64_t		*status;
>   } __attribute__ ((packed));
>
>   struct efi_getwakeuptime {
>   	uint8_t		*Enabled;
>   	uint8_t		*Pending;
> -	EFI_TIME	*Time;
> +	efi_time_t	*Time;
>   	uint64_t	*status;
>   } __attribute__ ((packed));
>
>   struct efi_setwakeuptime {
>   	uint8_t		Enabled;
> -	EFI_TIME	*Time;
> +	efi_time_t	*Time;
>   	uint64_t	*status;
>   } __attribute__ ((packed));
>
>
>
>


Acked-by: Alex Hung <alex.hung@canonical.com>
diff mbox

Patch

diff --git a/efi_runtime/efi_runtime.c b/efi_runtime/efi_runtime.c
index 115b1b5..4c83800 100644
--- a/efi_runtime/efi_runtime.c
+++ b/efi_runtime/efi_runtime.c
@@ -42,38 +42,6 @@  MODULE_LICENSE("GPL");
 #define EFI_RUNTIME_ENABLED	efi_enabled
 #endif
 
-static void convert_from_efi_time(efi_time_t *eft, EFI_TIME *time)
-{
-	memset(time, 0, sizeof(EFI_TIME));
-	time->Year = eft->year;
-	time->Month = eft->month;
-	time->Day  = eft->day;
-	time->Hour = eft->hour;
-	time->Minute = eft->minute;
-	time->Second  = eft->second;
-	time->Pad1 = eft->pad1;
-	time->Nanosecond = eft->nanosecond;
-	time->TimeZone = eft->timezone;
-	time->Daylight = eft->daylight;
-	time->Pad2 = eft->pad2;
-}
-
-static void convert_to_efi_time(efi_time_t *eft, EFI_TIME *time)
-{
-	memset(eft, 0, sizeof(*eft));
-	eft->year = time->Year;
-	eft->month = time->Month;
-	eft->day = time->Day;
-	eft->hour = time->Hour;
-	eft->minute = time->Minute;
-	eft->second = time->Second;
-	eft->pad1 = time->Pad1;
-	eft->nanosecond = time->Nanosecond;
-	eft->timezone = time->TimeZone;
-	eft->daylight = time->Daylight;
-	eft->pad2 = time->Pad2;
-}
-
 /*
  * Count the bytes in 'str', including the terminating NULL.
  *
@@ -332,13 +300,13 @@  static long efi_runtime_get_time(unsigned long arg)
 	struct efi_gettime  gettime_local;
 	efi_status_t status;
 	efi_time_cap_t cap;
-	efi_time_t eft;
+	efi_time_t efi_time;
 
 	gettime = (struct efi_gettime __user *)arg;
 	if (copy_from_user(&gettime_local, gettime, sizeof(gettime_local)))
 		return -EFAULT;
 
-	status = efi.get_time(gettime_local.Time ? &eft : NULL,
+	status = efi.get_time(gettime_local.Time ? &efi_time : NULL,
 			      gettime_local.Capabilities ? &cap : NULL);
 
 	if (put_user(status, gettime_local.status))
@@ -348,18 +316,18 @@  static long efi_runtime_get_time(unsigned long arg)
 		return -EINVAL;
 	}
 	if (gettime_local.Capabilities) {
-		EFI_TIME_CAPABILITIES __user *cap_local;
+		efi_time_cap_t __user *cap_local;
 
-		cap_local = (EFI_TIME_CAPABILITIES *)gettime_local.Capabilities;
+		cap_local = (efi_time_cap_t *)gettime_local.Capabilities;
 		if (put_user(cap.resolution,
-				&(cap_local->Resolution)) ||
-				put_user(cap.accuracy, &(cap_local->Accuracy)) ||
-				put_user(cap.sets_to_zero,&(cap_local->SetsToZero)))
+				&(cap_local->resolution)) ||
+				put_user(cap.accuracy, &(cap_local->accuracy)) ||
+				put_user(cap.sets_to_zero,&(cap_local->sets_to_zero)))
 			return -EFAULT;
 	}
 	if (gettime_local.Time)
-		return copy_to_user(gettime_local.Time, &eft,
-			sizeof(EFI_TIME)) ? -EFAULT : 0;
+		return copy_to_user(gettime_local.Time, &efi_time,
+			sizeof(efi_time_t)) ? -EFAULT : 0;
 	return 0;
 }
 
@@ -368,17 +336,15 @@  static long efi_runtime_set_time(unsigned long arg)
 	struct efi_settime __user *settime;
 	struct efi_settime settime_local;
 	efi_status_t status;
-	EFI_TIME efi_time;
-	efi_time_t eft;
+	efi_time_t efi_time;
 
 	settime = (struct efi_settime __user *)arg;
 	if (copy_from_user(&settime_local, settime, sizeof(settime_local)))
 		return -EFAULT;
 	if (copy_from_user(&efi_time, settime_local.Time,
-					sizeof(EFI_TIME)))
+					sizeof(efi_time_t)))
 		return -EFAULT;
-	convert_to_efi_time(&eft, &efi_time);
-	status = efi.set_time(&eft);
+	status = efi.set_time(&efi_time);
 
 	if (put_user(status, settime_local.status))
 		return -EFAULT;
@@ -392,8 +358,7 @@  static long efi_runtime_get_waketime(unsigned long arg)
 	struct efi_getwakeuptime getwakeuptime_local;
 	unsigned char enabled, pending;
 	efi_status_t status;
-	EFI_TIME efi_time;
-	efi_time_t eft;
+	efi_time_t efi_time;
 
 	getwakeuptime = (struct efi_getwakeuptime __user *)arg;
 	if (copy_from_user(&getwakeuptime_local, getwakeuptime, sizeof(getwakeuptime_local)))
@@ -402,7 +367,7 @@  static long efi_runtime_get_waketime(unsigned long arg)
 	status = efi.get_wakeup_time(
 		getwakeuptime_local.Enabled ? (efi_bool_t *)&enabled : NULL,
 		getwakeuptime_local.Pending ? (efi_bool_t *)&pending : NULL,
-		getwakeuptime_local.Time ? &eft : NULL);
+		getwakeuptime_local.Time ? &efi_time : NULL);
 
 	if (put_user(status, getwakeuptime_local.status))
 		return -EFAULT;
@@ -410,11 +375,10 @@  static long efi_runtime_get_waketime(unsigned long arg)
 		return -EINVAL;
 	if (getwakeuptime_local.Enabled && put_user(enabled, getwakeuptime_local.Enabled))
 		return -EFAULT;
-	convert_from_efi_time(&eft, &efi_time);
 
 	if (getwakeuptime_local.Time)
 		return copy_to_user(getwakeuptime_local.Time, &efi_time,
-			sizeof(EFI_TIME)) ? -EFAULT : 0;
+			sizeof(efi_time_t)) ? -EFAULT : 0;
 	return 0;
 }
 
@@ -424,8 +388,7 @@  static long efi_runtime_set_waketime(unsigned long arg)
 	struct efi_setwakeuptime setwakeuptime_local;
 	unsigned char enabled;
 	efi_status_t status;
-	EFI_TIME efi_time;
-	efi_time_t eft;
+	efi_time_t efi_time;
 
 	setwakeuptime = (struct efi_setwakeuptime __user *)arg;
 
@@ -434,11 +397,10 @@  static long efi_runtime_set_waketime(unsigned long arg)
 
 	enabled = setwakeuptime_local.Enabled;
 	if (setwakeuptime_local.Time) {
-		if (copy_from_user(&efi_time, setwakeuptime_local.Time, sizeof(EFI_TIME)))
+		if (copy_from_user(&efi_time, setwakeuptime_local.Time, sizeof(efi_time_t)))
 			return -EFAULT;
 
-		convert_to_efi_time(&eft, &efi_time);
-		status = efi.set_wakeup_time(enabled, &eft);
+		status = efi.set_wakeup_time(enabled, &efi_time);
 	} else {
 		status = efi.set_wakeup_time(enabled, NULL);
 	}
diff --git a/efi_runtime/efi_runtime.h b/efi_runtime/efi_runtime.h
index 092e842..b9177d4 100644
--- a/efi_runtime/efi_runtime.h
+++ b/efi_runtime/efi_runtime.h
@@ -30,26 +30,6 @@  typedef enum {
 } EFI_RESET_TYPE;
 
 typedef struct {
-	uint16_t	Year;		/* 1900 – 9999 */
-	uint8_t		Month;		/* 1 – 12 */
-	uint8_t		Day;		/* 1 – 31 */
-	uint8_t		Hour;		/* 0 – 23 */
-	uint8_t		Minute;		/* 0 – 59 */
-	uint8_t		Second;		/* 0 – 59 */
-	uint8_t		Pad1;
-	uint32_t	Nanosecond;	/* 0 – 999,999,999 */
-	int16_t		TimeZone;	/* -1440 to 1440 or 2047 */
-	uint8_t		Daylight;
-	uint8_t		Pad2;
-} __attribute__ ((packed)) EFI_TIME;
-
-typedef struct {
-	uint32_t	Resolution;
-	uint32_t	Accuracy;
-	uint8_t		SetsToZero;
-} __attribute__ ((packed)) EFI_TIME_CAPABILITIES;
-
-typedef struct {
 	efi_guid_t CapsuleGuid;
 	uint32_t HeaderSize;
 	uint32_t Flags;
@@ -90,26 +70,26 @@  struct efi_queryvariableinfo {
 } __attribute__ ((packed));
 
 struct efi_gettime {
-	EFI_TIME		*Time;
-	EFI_TIME_CAPABILITIES	*Capabilities;
+	efi_time_t		*Time;
+	efi_time_cap_t		*Capabilities;
 	uint64_t		*status;
 } __attribute__ ((packed));
 
 struct efi_settime {
-	EFI_TIME		*Time;
+	efi_time_t		*Time;
 	uint64_t		*status;
 } __attribute__ ((packed));
 
 struct efi_getwakeuptime {
 	uint8_t		*Enabled;
 	uint8_t		*Pending;
-	EFI_TIME	*Time;
+	efi_time_t	*Time;
 	uint64_t	*status;
 } __attribute__ ((packed));
 
 struct efi_setwakeuptime {
 	uint8_t		Enabled;
-	EFI_TIME	*Time;
+	efi_time_t	*Time;
 	uint64_t	*status;
 } __attribute__ ((packed));