Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp7462532ybn; Mon, 30 Sep 2019 14:21:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwyjINEp9ss6vJoPcpLcAj/SNDsto2zI4ROXD3Pqv5y7CATQkWjN96Vzyc5fOx24+AzQdTn X-Received: by 2002:a05:6402:184d:: with SMTP id v13mr22550884edy.56.1569878488408; Mon, 30 Sep 2019 14:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569878488; cv=none; d=google.com; s=arc-20160816; b=mhHwa3sQho8Vh2y5ObEwBwZTbns6HI8j4+UF3IwGbqBHkEY0p0mKwdTIHULvTZoCnr BtjWHAbdW5/wjs4m4BdC6jzkuA1kCCU0xSZs5b7V/+7H253ss7AmDs9req95GB+VzsU4 IOLXRHv1Ml3cuWTxNtPi3/fIqT6ogrnaoK+b+j4EEWxNSD3rmZs6F/+S+aVD0lHMDEDH d5cHVe9W0RfrjnipldcY56U9zAC8ekSgYHf6ldW3aOGujj+mxYByuevTlC3IzOE0UMxw BwzlZlXwSz4yldMVktm7bkZBso2FJtIcI4t4zK29GqM9xyFUJp+XRDz/wRvAUH023gpp Xtmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=9HinPjMJPXdxvbi+LWBGUQkD/KBz+jv2T8NxYRRT/5Y=; b=LEv5/62/DAZ5b6IplmJCNFgzjWdhjVI7bwkI+wVzvzYCfh4WQSpLZhaC/eng8g9VUB af9I4IqRwuOtZp2olAOSZOgEbXQQdF+PiWyeTLhfN37ygVIpIUJV628tIiSfpsgjvVyd uj1SWMf3ZwdTodqXBkbt7dvgDdMBA5zklkkuqcnDQ4hJJc4uMgwEvxNLX0Y+fKLOwrzv cY0KgCbWWBrrXudGZi2nIz2IsfeEK45L8jBpu5MRgi091OK4faEfDg6oUEINjRudT0/l 9HKQB+hbupZLn9qhEiAKtC19IqbvsfilfI5ZFI9qHjAa9O0ADiZ563a86ozf+okTRP71 ogYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3si7425017edq.163.2019.09.30.14.21.03; Mon, 30 Sep 2019 14:21:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732270AbfI3VU0 (ORCPT + 99 others); Mon, 30 Sep 2019 17:20:26 -0400 Received: from mslow2.mail.gandi.net ([217.70.178.242]:47562 "EHLO mslow2.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729855AbfI3VU0 (ORCPT ); Mon, 30 Sep 2019 17:20:26 -0400 X-Greylist: delayed 2444 seconds by postgrey-1.27 at vger.kernel.org; Mon, 30 Sep 2019 17:20:25 EDT Received: from relay2-d.mail.gandi.net (unknown [217.70.183.194]) by mslow2.mail.gandi.net (Postfix) with ESMTP id D3F613A9B4F for ; Mon, 30 Sep 2019 20:08:11 +0000 (UTC) X-Originating-IP: 86.202.229.42 Received: from localhost (lfbn-lyo-1-146-42.w86-202.abo.wanadoo.fr [86.202.229.42]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 2EA4840002; Mon, 30 Sep 2019 20:08:10 +0000 (UTC) Date: Mon, 30 Sep 2019 22:08:09 +0200 From: Alexandre Belloni To: Andy Shevchenko Cc: Petr Mladek , linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Hans Verkuil , Mathias Nyman , Jonathan Corbet , Thierry Reding , Jonathan Hunter , John Stultz , Thomas Gleixner Subject: Re: [PATCH v1 1/4] lib/vsprintf: Print time64_t in human readable format Message-ID: <20190930200809.GK3913@piout.net> References: <20190104193009.30907-1-andriy.shevchenko@linux.intel.com> <20190108152528.utr3a5huran52gsf@pathway.suse.cz> <20190110215858.GG2362@piout.net> <20190726132037.GX9224@smile.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190726132037.GX9224@smile.fi.intel.com> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26/07/2019 16:20:37+0300, Andy Shevchenko wrote: > On Thu, Jan 10, 2019 at 10:58:58PM +0100, Alexandre Belloni wrote: > > On 08/01/2019 16:25:28+0100, Petr Mladek wrote: > > > On Fri 2019-01-04 21:30:06, Andy Shevchenko wrote: > > > > There are users which print time and date represented by content of > > > > time64_t type in human readable format. > > > > > > > > Instead of open coding that each time introduce %ptT[dt][r] specifier. > > > > > > > > Few test cases for %ptT specifier has been added as well. > > > > > +void time64_to_rtc_time(time64_t time, struct rtc_time *rtc_time) > > > > +{ > > > > +#ifdef CONFIG_RTC_LIB > > > > + rtc_time64_to_tm(time, rtc_time); > > > > I wonder if the conversion between struct tm and rtc_time > > > might be useful in general. > > > > > > It might make sense to de-duplicate time64_to_tm() and > > > rtc_time64_to_tm() implementations. > > > Looking at 57f1f0874f42, this seemed to be the plan at the time > > time_to_tm was introduced but this was never done. Seeing that tm and > > rtc_time are quite similar, we could probably always use time64_to_tm as > > it is more accurate than rtc_time64_to_tm as the latter assumes a > > specific year range. > > So, do I understand correctly that dropping #ifdef along with > rtc_time64_to_tm() call is sufficient for now? > I'd be fine with that. > > Maybe be rtc_str should take a struct tm instead of an rtc_time so > > time64_to_rtc_time always uses time64_to_tm. > > Because this one, while sounding plausible, maybe too invasive on current > state of affairs. > Well, if the kernel struct tm had an int tm_year instead of long tm_year, then you could simply cast a struct rtc_time to a struct tm. I'm not sure was was the rationale to have a long, especially since userspace has an int. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com