The patch titled ktime_sub_ns: analog of ktime_add_ns has been added to the -mm tree. Its filename is ktime_sub_ns-analog-of-ktime_add_ns.patch *** Remember to use Documentation/SubmitChecklist when testing your code *** See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: ktime_sub_ns: analog of ktime_add_ns From: Stephen Hemminger <shemminger@xxxxxxxxxxxxxxxxxxxx> Add macro/function to subtract constant nanoseconds. Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- include/linux/ktime.h | 16 ++++++++++++++++ kernel/hrtimer.c | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff -puN include/linux/ktime.h~ktime_sub_ns-analog-of-ktime_add_ns include/linux/ktime.h --- a/include/linux/ktime.h~ktime_sub_ns-analog-of-ktime_add_ns +++ a/include/linux/ktime.h @@ -102,6 +102,13 @@ static inline ktime_t ktime_set(const lo #define ktime_add_ns(kt, nsval) \ ({ (ktime_t){ .tv64 = (kt).tv64 + (nsval) }; }) +/* + * Subtract a ktime_t variable and a scalar nanosecond value. + * res = kt - nsval: + */ +#define ktime_sub_ns(kt, nsval) \ + ({ (ktime_t){ .tv64 = (kt).tv64 - (nsval) }; }) + /* convert a timespec to ktime_t format: */ static inline ktime_t timespec_to_ktime(struct timespec ts) { @@ -200,6 +207,15 @@ static inline ktime_t ktime_add(const kt extern ktime_t ktime_add_ns(const ktime_t kt, u64 nsec); /** + * ktime_sub_ns - Subtract a scalar nanoseconds value to a ktime_t variable + * @kt: minuend + * @nsec: subtrahend in nanoseconds + * + * Returns the difference of @kt and @nsec in ktime_t format + */ +extern ktime_t ktime_sub_ns(const ktime_t kt, u64 nsec); + +/** * timespec_to_ktime - convert a timespec to ktime_t format * @ts: the timespec variable to convert * diff -puN kernel/hrtimer.c~ktime_sub_ns-analog-of-ktime_add_ns kernel/hrtimer.c --- a/kernel/hrtimer.c~ktime_sub_ns-analog-of-ktime_add_ns +++ a/kernel/hrtimer.c @@ -277,6 +277,30 @@ ktime_t ktime_add_ns(const ktime_t kt, u } EXPORT_SYMBOL_GPL(ktime_add_ns); + +/** + * ktime_sub_ns - Subract a scalar nanoseconds value to a ktime_t variable + * @kt: minuend + * @nsec: subtrahend in nanoseconds + * + * Returns the difference of kt and nsec in ktime_t format + */ +ktime_t ktime_sub_ns(const ktime_t kt, u64 nsec) +{ + ktime_t tmp; + + if (likely(nsec < NSEC_PER_SEC)) { + tmp.tv64 = nsec; + } else { + unsigned long rem = do_div(nsec, NSEC_PER_SEC); + + tmp = ktime_set((long)nsec, rem); + } + + return ktime_sub(kt, tmp); +} + +EXPORT_SYMBOL_GPL(ktime_add_ns); # endif /* !CONFIG_KTIME_SCALAR */ /* _ Patches currently in -mm which might be from shemminger@xxxxxxxxxxxxxxxxxxxx are origin.patch pci-x-pci-express-read-control-interfaces-mthca.patch pci-x-pci-express-read-control-interfaces-e1000.patch sky2-fe-chip-support.patch sky2-use-debugfs-rename.patch sky2-document-gphy_ctrl-bits.patch sky2-dont-restrict-config-space-access.patch sky2-advanced-error-reporting.patch sky2-use-pci_config-access-functions.patch sky2-use-net_device-internal-stats.patch ktime_sub_ns-analog-of-ktime_add_ns.patch export-reciprocal_value-for-modules.patch sky2-hardware-receive-timestamp-counter.patch sky2-avoid-divide-in-receive-path.patch sky2-118.patch git-net.patch i386-optimize-memset-of-6-and-8-bytes.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html