mirror of
https://github.com/torvalds/linux.git
synced 2024-12-26 04:42:12 +00:00
misc: mic: fix passing the current time
I noticed that the mic driver passes a 'struct timespec64' as part of a message into an attached device, where it is used to set the current system time. This won't actually work if one of the two sides runs a 32-bit kernel and the other runs a 64-bit kernel, since the structure layout is different between the two. I found this while replacing calls to the deprecated do_settimeofday64() interface with the modern ktime_get_real_ts() variant, but it seems appropriate to address both at the same time here. To make sure we have a sane structure, let's define our own structure using the layout of the 64-bit kernel. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e890591413
commit
6051e79bbf
@ -45,7 +45,10 @@ struct cosm_msg {
|
||||
u64 id;
|
||||
union {
|
||||
u64 shutdown_status;
|
||||
struct timespec64 timespec;
|
||||
struct {
|
||||
u64 tv_sec;
|
||||
u64 tv_nsec;
|
||||
} timespec;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -179,9 +179,13 @@ static void cosm_set_crashed(struct cosm_device *cdev)
|
||||
static void cosm_send_time(struct cosm_device *cdev)
|
||||
{
|
||||
struct cosm_msg msg = { .id = COSM_MSG_SYNC_TIME };
|
||||
struct timespec64 ts;
|
||||
int rc;
|
||||
|
||||
getnstimeofday64(&msg.timespec);
|
||||
ktime_get_real_ts64(&ts);
|
||||
msg.timespec.tv_sec = ts.tv_sec;
|
||||
msg.timespec.tv_nsec = ts.tv_nsec;
|
||||
|
||||
rc = scif_send(cdev->epd, &msg, sizeof(msg), SCIF_SEND_BLOCK);
|
||||
if (rc < 0)
|
||||
dev_err(&cdev->dev, "%s %d scif_send failed rc %d\n",
|
||||
|
@ -63,7 +63,11 @@ static struct notifier_block cosm_reboot = {
|
||||
/* Set system time from timespec value received from the host */
|
||||
static void cosm_set_time(struct cosm_msg *msg)
|
||||
{
|
||||
int rc = do_settimeofday64(&msg->timespec);
|
||||
struct timespec64 ts = {
|
||||
.tv_sec = msg->timespec.tv_sec,
|
||||
.tv_nsec = msg->timespec.tv_nsec,
|
||||
};
|
||||
int rc = do_settimeofday64(&ts);
|
||||
|
||||
if (rc)
|
||||
dev_err(&client_spdev->dev, "%s: %d settimeofday rc %d\n",
|
||||
|
Loading…
Reference in New Issue
Block a user