From patchwork Sun Sep 10 22:23:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jasmin J." X-Patchwork-Id: 9946413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9AA45604D5 for ; Sun, 10 Sep 2017 22:23:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C4D228A6E for ; Sun, 10 Sep 2017 22:23:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70EA328A69; Sun, 10 Sep 2017 22:23:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AE5528A66 for ; Sun, 10 Sep 2017 22:23:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751888AbdIJWXS (ORCPT ); Sun, 10 Sep 2017 18:23:18 -0400 Received: from mail.anw.at ([195.234.101.228]:38598 "EHLO mail.anw.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751770AbdIJWXR (ORCPT ); Sun, 10 Sep 2017 18:23:17 -0400 Received: from hoppel.217.196.72.190 (anwhome.anw.at [195.234.103.23]) by mail.anw.at (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id v8AMNEB4003216; Mon, 11 Sep 2017 00:23:14 +0200 From: "Jasmin J." To: linux-media@vger.kernel.org Cc: hverkuil@xs4all.nl, d.scheller@gmx.net, jasmin@anw.at Subject: [PATCH] build: Added missing functions nsecs_to_jiffies(64) Date: Mon, 11 Sep 2017 00:23:17 +0200 Message-Id: <1505082197-11962-1-git-send-email-jasmin@anw.at> X-Mailer: git-send-email 2.7.4 X-Antivirus: checked in 0.023sec at mail.anw.at ([195.234.102.72]) by smf-clamd v1.2.1 - http://smfs.sf.net/ Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jasmin Jessich Several modules expect the functions nsecs_to_jiffies64 and nsecs_to_jiffies to be available when they get loaded. For Kernels prior to 3.16, this symbol is not exported in time.c . Copied the functions to compat.h, so that they get already resolved during compilation. Define also a macro with a name conversion, because the mentioned functions are defined as extern in include/linux/jiffies.h, which gives an error when the are re-defined as static. Signed-off-by: Jasmin Jessich --- v4l/compat.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/v4l/compat.h b/v4l/compat.h index 7a49551..3dedf26 100644 --- a/v4l/compat.h +++ b/v4l/compat.h @@ -2118,4 +2118,41 @@ static inline int pm_runtime_get_if_in_use(struct device *dev) .subvendor = (subvend), .subdevice = (subdev) #endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0) +/* + * copied from kernel/time/time.c + */ +static inline u64 nsecs_to_jiffies64_static(u64 n) +{ +#if (NSEC_PER_SEC % HZ) == 0 + /* Common case, HZ = 100, 128, 200, 250, 256, 500, 512, 1000 etc. */ + return div_u64(n, NSEC_PER_SEC / HZ); +#elif (HZ % 512) == 0 + /* overflow after 292 years if HZ = 1024 */ + return div_u64(n * HZ / 512, NSEC_PER_SEC / 512); +#else + /* + * Generic case - optimized for cases where HZ is a multiple of 3. + * overflow after 64.99 years, exact for HZ = 60, 72, 90, 120 etc. + */ + return div_u64(n * 9, (9ull * NSEC_PER_SEC + HZ / 2) / HZ); +#endif +} + +static inline unsigned long nsecs_to_jiffies_static(u64 n) +{ + return (unsigned long)nsecs_to_jiffies64_static(n); +} + +/* + * linux/jiffies.h defines nsecs_to_jiffies64 and nsecs_to_jiffies + * as externals. To get rid of the compiler error, we redefine the + * functions to the static variant just defined above. + */ +#define nsecs_to_jiffies64(_n) nsecs_to_jiffies64_static(_n) +#define nsecs_to_jiffies(_n) nsecs_to_jiffies_static(_n) + +#endif + #endif /* _COMPAT_H */