From patchwork Wed Nov 13 00:44:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 1193913 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="zGVMSMly"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 47CQzB6X8tz9sPh for ; Wed, 13 Nov 2019 11:51:18 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 8A61EC21F1A; Wed, 13 Nov 2019 00:47:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 60FF8C21E79; Wed, 13 Nov 2019 00:45:54 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D3785C21F63; Wed, 13 Nov 2019 00:45:18 +0000 (UTC) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by lists.denx.de (Postfix) with ESMTPS id 5D5BDC21ED5 for ; Wed, 13 Nov 2019 00:45:14 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id s5so321817pfh.9 for ; Tue, 12 Nov 2019 16:45:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m3qEVMl2WFgRRGNGfoK3WeNDK0iT/nQwg0AIDdq5P/o=; b=zGVMSMlyFPi6gDOp5te9PQEqXefFwLB0TmhkaZdFiAmn6qEw5+See3ZqskfJa0W6Z6 06fL8ofod39+6vG8shm92wKPCPWJDwysakCDeQgwfFSFn1aqd+VuSYRWnyyuJ33/BhOs nI1OZdCyH6fKZ65Ok5+LOj4dlQdVIbCOg7riExKHSN4/DjrRd5Qlv3y3FChVIdHClGTg lcyyP4moxzBTU1teN3OorGizQe65XcFEkT3YF5j/LGgGoYB/6nJwlIxxwtvKgpR3zx/q sZ9x38UjkQreZYs0cTCnJtq65CkEFPUc49mWKcTGFJ9cXWhuGxUkmkHp2OH2AB4c3jRY ZyJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m3qEVMl2WFgRRGNGfoK3WeNDK0iT/nQwg0AIDdq5P/o=; b=uZke2qybTuTK1QQMAEIwz7Zqu6jXXlQxymET0WK3QWJIOJ9t2H8KjgtfOSro5thDqz qCxsBh16O4Y5ZWBDbzYKYmXtsiz4Gr6kC0xBCkdxxYKKkVFPCgDKONnoxqVbFidq0O9P Fx+nSljo70fqaM7UMHewxHOAiB2D84s99Nobr2WkqJ9SnEPy7Zdqmf/rfENhgIbtOvGs 36NGsFHCvk977YbyZegEaKF8LtcvDfJM+LIlP49VKZVte7CjIA9KuvhLEFujJ8LAojoc cLYbb4fwr013+oiq0mkbvYG3IALy8oaJPy0Qj4UwDLlvL81Mjwu6wA6NYcjE2KTl3/eR 2v1g== X-Gm-Message-State: APjAAAVEwzoNnerShutekniW9gKh2VYzrKFuPTW+3+2o9vzNTDd8T4hQ 1HtFx3d0unLFPZhpud+661Dicg== X-Google-Smtp-Source: APXvYqwgptbErMRIb7Nky+d7km9mQRQJdd8HXTkiuJ+IVOIKoaeSHnr8/Qw0Q+PzBwune1FokZag8A== X-Received: by 2002:a17:90a:1a41:: with SMTP id 1mr935052pjl.28.1573605912944; Tue, 12 Nov 2019 16:45:12 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id f33sm184596pgl.33.2019.11.12.16.45.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Nov 2019 16:45:12 -0800 (PST) From: AKASHI Takahiro To: trini@konsulko.com, xypron.glpk@gmx.de, agraf@csgraf.de Date: Wed, 13 Nov 2019 09:44:50 +0900 Message-Id: <20191113004502.29986-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191113004502.29986-1-takahiro.akashi@linaro.org> References: <20191113004502.29986-1-takahiro.akashi@linaro.org> MIME-Version: 1.0 Cc: u-boot@lists.denx.de, mail@patrick-wildt.de Subject: [U-Boot] [PATCH v3 04/16] lib: add mktime64() for linux compatibility X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This function will be used in lib/crypto/x509_cert_parser.c, which will also be imported from linux code in a later commit. Signed-off-by: AKASHI Takahiro --- include/linux/time.h | 10 ++++++++++ lib/date.c | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/linux/time.h b/include/linux/time.h index b8d298eb4d68..dc9344a6d97b 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -1,6 +1,7 @@ #ifndef _LINUX_TIME_H #define _LINUX_TIME_H +#include #include #define _DEFUN(a,b,c) a(c) @@ -150,4 +151,13 @@ _DEFUN (ctime_r, (tim_p, result), return asctime_r (localtime_r (tim_p, &tm), result); } +/* for compatibility with linux code */ +typedef __s64 time64_t; + +#ifdef CONFIG_LIB_DATE +time64_t mktime64(const unsigned int year, const unsigned int mon, + const unsigned int day, const unsigned int hour, + const unsigned int min, const unsigned int sec); +#endif + #endif diff --git a/lib/date.c b/lib/date.c index 63af4a142612..0456de78ab14 100644 --- a/lib/date.c +++ b/lib/date.c @@ -8,6 +8,7 @@ #include #include #include +#include #if defined(CONFIG_LIB_DATE) || defined(CONFIG_TIMESTAMP) @@ -97,3 +98,22 @@ unsigned long rtc_mktime(const struct rtc_time *tm) } #endif /* CONFIG_LIB_DATE || CONFIG_TIMESTAMP */ + +#ifdef CONFIG_LIB_DATE +/* for compatibility with linux code */ +time64_t mktime64(const unsigned int year, const unsigned int mon, + const unsigned int day, const unsigned int hour, + const unsigned int min, const unsigned int sec) +{ + struct rtc_time time; + + time.tm_year = year; + time.tm_mon = mon; + time.tm_mday = day; + time.tm_hour = hour; + time.tm_min = min; + time.tm_sec = sec; + + return (time64_t)rtc_mktime((const struct rtc_time *)&time); +} +#endif