summaryrefslogtreecommitdiffstats
path: root/sys-utils/hwclock-rtc.c
diff options
context:
space:
mode:
authorSami Kerola2016-07-24 23:33:01 +0200
committerSami Kerola2017-02-05 00:39:38 +0100
commitbd0786895d584644b47ef7e7ea923cda29e73fa6 (patch)
treecd07cca3ee59c6430bb93a1cf91bd8bc9063c422 /sys-utils/hwclock-rtc.c
parenthwclock: remove division by zero [asan] (diff)
downloadkernel-qcow2-util-linux-bd0786895d584644b47ef7e7ea923cda29e73fa6.tar.gz
kernel-qcow2-util-linux-bd0786895d584644b47ef7e7ea923cda29e73fa6.tar.xz
kernel-qcow2-util-linux-bd0786895d584644b47ef7e7ea923cda29e73fa6.zip
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>
Diffstat (limited to 'sys-utils/hwclock-rtc.c')
-rw-r--r--sys-utils/hwclock-rtc.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/sys-utils/hwclock-rtc.c b/sys-utils/hwclock-rtc.c
index 5e11aeebd..f54e2633c 100644
--- a/sys-utils/hwclock-rtc.c
+++ b/sys-utils/hwclock-rtc.c
@@ -38,6 +38,7 @@
# include <asm/rtc.h>
#endif
*/
+#ifdef __sparc__
/* The following is roughly equivalent */
struct sparc_rtc_time
{
@@ -49,9 +50,9 @@ struct sparc_rtc_time
int month; /* Month of year 1-12 */
int year; /* Year 0-99 */
};
-
#define RTCGET _IOR('p', 20, struct sparc_rtc_time)
#define RTCSET _IOW('p', 21, struct sparc_rtc_time)
+#endif
/*
* struct rtc_time is present since 1.3.99.
@@ -374,7 +375,7 @@ static int get_permissions_rtc(void)
return 0;
}
-static struct clock_ops rtc = {
+static struct clock_ops rtc_interface = {
N_("Using the rtc interface to the clock."),
get_permissions_rtc,
read_hardware_clock_rtc,
@@ -385,14 +386,14 @@ static struct clock_ops rtc = {
/* return &rtc if /dev/rtc can be opened, NULL otherwise */
struct clock_ops *probe_for_rtc_clock(const struct hwclock_control *ctl)
{
- int rtc_fd = open_rtc(ctl);
- if (rtc_fd >= 0)
- return &rtc;
- if (ctl->debug)
- warn(_("cannot open rtc device"));
- return NULL;
+ const int rtc_fd = open_rtc(ctl);
+
+ if (rtc_fd < 0)
+ return NULL;
+ return &rtc_interface;
}
+#ifdef __alpha__
/*
* Get the Hardware Clock epoch setting from the kernel.
*/
@@ -478,3 +479,4 @@ int set_epoch_rtc(const struct hwclock_control *ctl)
return 0;
}
+#endif /* __alpha__ */