Commit Graph

30 Commits

Author SHA1 Message Date
Karel Zak 68a2ade7ed hwclock: add SPDX-License-Identifier(s)
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-11-08 11:12:13 +01:00
Carlos Santos 88bc304ba8 hwclock: use CMOS clock only if available
- Add --disable-hwclock-cmos configuration argument
- Add USE_HWCLOCK_CMOS (enabled by default for i386/x86_64)
- Add define(USE_HWCLOCK_CMOS)
- Compile hwclock-cmos.c only if USE_HWCLOCK_CMOS is true
- Remove all unnecessary #ifdefs from hwclock-cmos.c
- Add #ifdef USE_HWCLOCK_CMOS around the determine_clock_access_method()
  call in hwclock.c

Signed-off-by: Carlos Santos <unixmania@gmail.com>
2019-07-15 13:56:13 +02:00
Karel Zak 9854912fef hwclock: fix warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 12:25:38 +02:00
Karel Zak df4f1a6647 hwclock: add --delay <seconds>
* add command line option --delay <seconds>

* read RTC type from /sys/class/rtc/rtc<N>/name

* default to 0.5 (500ms) for rtc_cmos or when RTC type is impossible
  determine; otherwise delay is 0.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-18 13:59:15 +02:00
Sami Kerola 473ec35974 hwclock: remove bool type definition
Use plain int instead of type defining it to a boolean, and use numbers to
signify true or false as we do everywhere else in this source tree.  And in
hwclock-cmos.c file booleans weren't even needed, to the related code is
removed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-08-30 11:21:56 +02:00
J William Piggott b3e8105837 hwclock: remove custom errno string
Custom errno messages are unnecessary and problematic for translators.

hwclock --directisa
hwclock: iopl() port access failed: Operation not permitted
hwclock: root privileges may be required

The custom errno message is misleading. We do not know what
the system permissions are set to. The default errno string is
correct, and enough.

Patched:
hwclock --directisa
hwclock: iopl() port access failed: Operation not permitted

root@:~# hwclock --directisa -D
Using direct ISA access to the clock
2017-07-24 14:49:17.782716-0400

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-07-31 16:10:47 -04:00
J William Piggott e216a772b1 hwclock: remove dead cmos code
* hwclock-cmos.c: remove unused 'century' code.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-03-31 10:04:53 -04:00
J William Piggott 859b0b1acb hwclock: improve cmos message strings
* sys-utils/hwclock-cmos.c: improve message strings

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-03-31 10:04:53 -04:00
J William Piggott 51d94caa8d hwclock: remove unused atomic arg in cmos
* sys-utils/hwclock-cmos.c: remove unused arg for atomic()

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-03-31 10:04:53 -04:00
J William Piggott f252169c56 hwclock: remove unused cmos ctl structs
The hwclock-cmos.c ctl structs were only used for
the since removed alpha code.

* sys-utils/hwclock-cmos.c: remove unused ctl structs

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-03-31 10:04:53 -04:00
J William Piggott c47a61894b hwclock: remove alpha cmos
Remove alpha direct I/O access, use RTC instead:
http://marc.info/?l=util-linux-ng&m=141682406902804

Resolves the alpha 2020 issue for util-linux:
http://marc.info/?l=util-linux-ng&m=148387021519787

Now it is only the kernel's RTC problem.

* sys-utils/hwclock.c: remove alpha cmos
* sys-utils/hwclock-cmos.c: same
* sys-utils/hwclock.h: same
* sys-utils/hwclock.8.in: same

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-03-31 10:04:53 -04:00
Sami Kerola 2ba641e5f3 misc: add static keyword to where needed [smatch scan]
text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be
static?

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Sami Kerola c9a86ff664
hwclock: remove trailing dot from messages that include system error message
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:38 +00:00
Sami Kerola 6b06669e2a
hwclock: clarify cmos inb and outb preprocessor directives
The cmos only works when architecture is i386, x86_64, or alpha.

Reviewed-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:38 +00:00
Sami Kerola bd0786895d
hwclock: improve coding style
Make string constants to be symbolical declarations.  Use longer variable
name for rtc and cmos function pointer values.  Exclude code that is
architecture specific with preprocessor directives.  And remove message
duplication.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:38 +00:00
Sami Kerola 0f32118e70
hwclock: use symbolic magic values passed in between functions
The manipulate_clock() is seeing return value from
busywait_for_rtc_clock_tick().

And the get_permissions_cmos() can see i386_iopl() return value.

Reviewed-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:37 +00:00
Sami Kerola c6ea9ef6cb
hwclock: remove dead code and other minor fixes
Use #ifdef rather than #if to avoid undefined preprocessor identifier
warning.

Remove dead code.  The #if 0 ensured the code has not been used for long
time, which is good because the linux/mc146818rtc.h is not been part of
user-api for long time.

Value of the adjtime_p->last_calib_time is checked if it has value of zero,
so testing none-zero bit later is necessarily true, and therefore does not
need to be checked.

And at the and remove unnecessary boolean variable.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:37 +00:00
Sami Kerola d0d3469139
hwclock: clarify set_cmos_epoch() code
Variable set_epoc is unnecessary, and removal of it makes it obvious what is
happening in this function.

Reviewed-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:37 +00:00
Sami Kerola 336f7c5f68
hwclock: move command-line options to control structure
The control structure is read-only everywhere else but in main().  Almost
all changes are about how variables are referred, with one exception.  Calls
to read_adjtime() from manipulate_clock() and compare_clock() are moved to
main().  This way it is possible to keep variable that tells if hwclock is
using UTC-0 be part of control structure.

Changes within #ifdef __alpha__ segments were tested by flipping the
preprocessor directivive otherway around and getting good compilaton all the
way to the point where linking on none-alpha system failed.

Reviewed-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-04 23:39:37 +00:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Andreas Henriksson 3baf5ac739 hwclock: fix iopl implicit declaration warning on alpha
Build warning:
sys-utils/hwclock-cmos.c: In function 'i386_iopl':
sys-utils/hwclock-cmos.c:611:9: warning: implicit declaration of function 'iopl' [-Wimplicit-function-declaration]
  return iopl(level);
         ^
sys-utils/hwclock-cmos.c:611:2: warning: nested extern declaration of 'iopl' [-Wnested-externs]
  return iopl(level);
  ^

Also:
checking sys/io.h usability... yes
checking sys/io.h presence... yes
checking for sys/io.h... yes

Full build log:
https://buildd.debian.org/status/fetch.php?pkg=util-linux&arch=alpha&ver=2.26.2-9&stamp=1440078034

Detected by/via:
https://qa.debian.org/bls/packages/u/util-linux.html

Please note that this has never been (build-)tested, but should hopefully
resolve the warning.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2015-08-24 10:55:44 +02:00
Andreas Henriksson ec3d3e67d9 hwclock: fix fgets unchecked return value warning on alpha
Build warning:
sys-utils/hwclock-cmos.c: In function 'is_in_cpuinfo':
sys-utils/hwclock-cmos.c:162:4: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result [-Wunused-result]
    fgets(field, 256, cpuinfo);

Full build log:
https://buildd.debian.org/status/fetch.php?pkg=util-linux&arch=alpha&ver=2.26.2-9&stamp=1440078034

Detected by/via:
https://qa.debian.org/bls/packages/u/util-linux.html

This change has never actually been (build-)tested on alpha, but
hopefully the change should fix the warning.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2015-08-24 10:55:41 +02:00
JWP cfb8ed1910 hwclock: enable --directisa for x86_64
Currently only x86 and Alpha can use --directisa.
This patch allows x86_64 machines to use it as well.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2015-01-09 10:44:00 +01:00
Benno Schulenberg 548696c442 textual: grammarize another error message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-10-01 09:37:09 +02:00
Benno Schulenberg b2d97db8c8 hwclock: internationalizing the message of the used interface
In addition, do it in a single sentence instead of in two fragments.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-02-10 18:41:55 +01:00
Karel Zak 41a8ff088b hwclock: use warn() to print cmos errors
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-14 23:41:32 +02:00
Karel Zak 7f89534e6e hwclock: fix compiler warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-20 19:51:38 +01:00
Karel Zak 93f90e1332 hwclock: fix compiler warning [-Wmissing-prototypes]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-16 18:43:53 +02:00
Sami Kerola 289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Karel Zak c7f753901f build-sys: move hwclock to sys-utils/
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 20:48:23 +02:00