summaryrefslogtreecommitdiff
path: root/src/libudev/libudev-device.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-03-13 18:43:00 +0100
committerTom Gundersen <teg@jklm.no>2015-03-13 18:47:07 +0100
commit1b14c3cfbe25f9bf1183bd26875f3c68847559c0 (patch)
tree205ad65aa947bd405ebd10ad815d2985df93ccec /src/libudev/libudev-device.c
parent0964dcd77213a9e229efcc2f00084e1f63fc00ca (diff)
udev: make set_usec_initialized() internal to libudev
Instead introduce ensure_usec_initialized(), which copies the timestamp if possible otherwise sets it to now(CLOCK_MONOTONIC).
Diffstat (limited to 'src/libudev/libudev-device.c')
-rw-r--r--src/libudev/libudev-device.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/libudev/libudev-device.c b/src/libudev/libudev-device.c
index c0a061af6c..b518a2f891 100644
--- a/src/libudev/libudev-device.c
+++ b/src/libudev/libudev-device.c
@@ -445,6 +445,23 @@ static int udev_device_set_syspath(struct udev_device *udev_device, const char *
return 0;
}
+static void udev_device_set_usec_initialized(struct udev_device *udev_device, usec_t usec_initialized)
+{
+ char num[DECIMAL_STR_MAX(usec_t)];
+
+ udev_device->usec_initialized = usec_initialized;
+ snprintf(num, sizeof(num), USEC_FMT, usec_initialized);
+ udev_device_add_property_internal(udev_device, "USEC_INITIALIZED", num);
+}
+
+void udev_device_ensure_usec_initialized(struct udev_device *udev_device, struct udev_device *old_device)
+{
+ if (old_device && old_device->usec_initialized != 0)
+ udev_device_set_usec_initialized(udev_device, old_device->usec_initialized);
+ else
+ udev_device_set_usec_initialized(udev_device, now(CLOCK_MONOTONIC));
+}
+
/*
* parse property string, and if needed, update internal values accordingly
*
@@ -1418,15 +1435,6 @@ usec_t udev_device_get_usec_initialized(struct udev_device *udev_device)
return udev_device->usec_initialized;
}
-void udev_device_set_usec_initialized(struct udev_device *udev_device, usec_t usec_initialized)
-{
- char num[32];
-
- udev_device->usec_initialized = usec_initialized;
- snprintf(num, sizeof(num), USEC_FMT, usec_initialized);
- udev_device_add_property_internal(udev_device, "USEC_INITIALIZED", num);
-}
-
/**
* udev_device_get_sysattr_value:
* @udev_device: udev device