summaryrefslogtreecommitdiffstats
path: root/commands/hwclock.c
Commit message (Collapse)AuthorAgeFilesLines
* treewide: Use pr_setenv() where appropriateSascha Hauer2022-06-211-3/+1
| | | | | | | We now have pr_setenv() which is a setenv() variant that takes a format string. Use it where appropriate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: set SPDX-License-Identifier for files without license statementAhmad Fatoum2022-01-051-0/+2
| | | | | | | | | | In absence of a dual licensing statement, this is GPL-2.0-only as the barebox project as a whole. Add a SPDX-License-Identifier to make this clear. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220103120539.1730644-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* string: implement strchrnulAhmad Fatoum2021-06-281-8/+0
| | | | | | | | | | We have at least two places opencoding strchrnul, one of them needlessly iterating twice instead of once over the string. Replace both by calling a common single pass implementation. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210628051934.9604-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands/hwclock: align -n option helpAntony Pavlov2019-05-091-1/+1
| | | | | | | | | | | | | | | | | Help string for hwclock -n option isn't aligned: barebox@barebox sandbox:/ help hwclock hwclock - query or set the hardware clock (RTC) Options: -f NAME RTC device name (default rtc0) -e VARNAME store RTC readout into variable VARNAME -n NTPSERVER set RTC from NTP server -s ccyymmddHHMM[.SS] set time Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: exit on invalid optionEnrico Jorns2016-09-161-0/+2
| | | | | | | | | | Barebox commands should not perform any action and return 0 if an invalid parameter was given. This might cause undetected unintended behvaior when calling commands with wrong options, either manually or from a script. Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands/hwclock: Check return value of rtc_read_time()Andrey Smirnov2016-01-071-2/+4
| | | | | | | | | It is possible for rtc_read_time() to fill struct rtc_time it returns with invalid values, so we have to check for its return value before using returned time. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hwclock: Allow to set hwclock from sntpSascha Hauer2016-01-071-1/+26
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hwclock command: forward return value of rtc_set_timeSascha Hauer2016-01-071-2/+1
| | | | | | rtc_set_time can fail, forward the error to the user. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* hwclock command: use format like the Linux tool doesSascha Hauer2016-01-071-3/+1
| | | | | | | | | | | | | | | Print three-letter abbreviations of the days and months. With a fixup by Andrey Smirnov: | common/date.c: Fix off-by-one error | | As per http://pubs.opengroup.org/onlinepubs/007908775/xsh/time.h.html | 'tm_wday' is zero indexed with zero representing Sunday, this is also | corroborated by the code in rtc_time_to_tm() which used 4 to represent | Thursday. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: add hwclockAntony Pavlov2014-08-021-0/+161
The hwclock command allows to query or set the hardware clock (RTC). Barebox' 'hwclock' command uses busybox' 'date' compatible time format ccyymmddHHMM[.SS]: # /bin/busybox date -s 201407292005.41 ; /bin/date Tue Jul 29 20:05:41 MSK 2014 Tue Jul 29 20:05:41 MSK 2014 Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>