Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys use the inline bcdtobin and bintobcd directly instead th...



details:   https://anonhg.NetBSD.org/src/rev/dc6c9e624fa7
branches:  trunk
changeset: 333883:dc6c9e624fa7
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Nov 20 16:34:25 2014 +0000

description:
use the inline bcdtobin and bintobcd directly instead through a macro.

diffstat:

 sys/arch/arm/marvell/mvsocrtc.c            |  30 ++++++++--------
 sys/arch/arm/omap/omap_rtc.c               |  32 ++++++++--------
 sys/arch/arm/s3c2xx0/s3c2440_rtc.c         |  28 +++++++-------
 sys/arch/evbarm/tsarm/tsrtc.c              |   8 ++--
 sys/arch/evbppc/walnut/dev/ds1743.c        |  32 ++++++++--------
 sys/arch/luna68k/dev/timekeeper.c          |  32 ++++++++--------
 sys/arch/mipsco/obio/mkclock.c             |   8 ++--
 sys/arch/mvme68k/stand/libsa/chiptotime.c  |  24 ++++--------
 sys/arch/mvme68k/stand/libsa/clock.c       |  20 ++++------
 sys/arch/mvmeppc/isa/mkclock_isa.c         |   8 ++--
 sys/arch/mvmeppc/stand/libsa/clock.c       |  17 +++-----
 sys/arch/next68k/next68k/rtc.c             |  42 +++++++++++-----------
 sys/arch/playstation2/playstation2/clock.c |  16 ++++----
 sys/arch/sbmips/sbmips/rtc.c               |  56 +++++++++++++++---------------
 sys/arch/sgimips/dev/dpclock.c             |  32 ++++++++--------
 sys/arch/sgimips/dev/dsclock.c             |  34 +++++++++---------
 sys/arch/sgimips/mace/mcclock_mace.c       |  36 +++++++++---------
 sys/arch/sh3/dev/rtc.c                     |  12 +++---
 sys/dev/i2c/ds1307.c                       |  32 ++++++++--------
 sys/dev/i2c/m41st84.c                      |  32 ++++++++--------
 sys/dev/i2c/m41t00.c                       |  36 +++++++++---------
 sys/dev/i2c/max6900.c                      |  36 +++++++++---------
 sys/dev/i2c/pcf8563.c                      |  30 ++++++++--------
 sys/dev/i2c/pcf8583.c                      |  26 ++++++------
 sys/dev/i2c/r2025.c                        |  32 ++++++++--------
 sys/dev/i2c/rs5c372.c                      |  30 ++++++++--------
 sys/dev/i2c/s390.c                         |  30 ++++++++--------
 sys/dev/i2c/tps65950.c                     |  32 ++++++++--------
 sys/dev/i2c/x1226.c                        |  38 ++++++++++----------
 sys/dev/ic/mc146818.c                      |   8 ++--
 sys/dev/ic/mk48txx.c                       |  38 ++++++++++----------
 sys/dev/ic/mm58167.c                       |   8 ++--
 sys/dev/ic/rs5c313.c                       |   8 ++--
 33 files changed, 434 insertions(+), 449 deletions(-)

diffs (truncated from 1990 to 300 lines):

diff -r 18ff1b0040f8 -r dc6c9e624fa7 sys/arch/arm/marvell/mvsocrtc.c
--- a/sys/arch/arm/marvell/mvsocrtc.c   Thu Nov 20 16:26:34 2014 +0000
+++ b/sys/arch/arm/marvell/mvsocrtc.c   Thu Nov 20 16:34:25 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mvsocrtc.c,v 1.2 2011/07/01 20:30:21 dyoung Exp $      */
+/*     $NetBSD: mvsocrtc.c,v 1.3 2014/11/20 16:34:25 christos Exp $    */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mvsocrtc.c,v 1.2 2011/07/01 20:30:21 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mvsocrtc.c,v 1.3 2014/11/20 16:34:25 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -142,12 +142,12 @@
         * XXXX this assumption will fail in 2100, but somehow I don't think
         * I or the hardware will be functioning to see it.
         */
-       dt->dt_year = FROMBCD(rtcyear) + 2000;
-       dt->dt_mon = FROMBCD(rtcmonth);
-       dt->dt_day = FROMBCD(rtcday);
-       dt->dt_hour = FROMBCD(rtchour);
-       dt->dt_min = FROMBCD(rtcmin);
-       dt->dt_sec = FROMBCD(rtcsec);
+       dt->dt_year = bcdtobin(rtcyear) + 2000;
+       dt->dt_mon = bcdtobin(rtcmonth);
+       dt->dt_day = bcdtobin(rtcday);
+       dt->dt_hour = bcdtobin(rtchour);
+       dt->dt_min = bcdtobin(rtcmin);
+       dt->dt_sec = bcdtobin(rtcsec);
 
        return 0;
 }
@@ -159,17 +159,17 @@
        uint32_t reg;
 
        /* compose & write time register contents */
-       reg = (TOBCD(dt->dt_sec) << MVSOCRTC_SECOND_OFFSET) |
-          (TOBCD(dt->dt_min) << MVSOCRTC_MINUTE_OFFSET) |
-          (TOBCD(dt->dt_hour) << MVSOCRTC_HOUR_OFFSET) |
-          (TOBCD(dt->dt_wday) << MVSOCRTC_WDAY_OFFSET);
+       reg = (bintobcd(dt->dt_sec) << MVSOCRTC_SECOND_OFFSET) |
+          (bintobcd(dt->dt_min) << MVSOCRTC_MINUTE_OFFSET) |
+          (bintobcd(dt->dt_hour) << MVSOCRTC_HOUR_OFFSET) |
+          (bintobcd(dt->dt_wday) << MVSOCRTC_WDAY_OFFSET);
 
        bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVSOCRTC_TIME, reg);
 
        /* compose & write date register contents */
-       reg = (TOBCD(dt->dt_day) << MVSOCRTC_DAY_OFFSET) |
-          (TOBCD(dt->dt_mon) << MVSOCRTC_MONTH_OFFSET) |
-          (TOBCD(dt->dt_year % 100) << MVSOCRTC_YEAR_OFFSET);
+       reg = (bintobcd(dt->dt_day) << MVSOCRTC_DAY_OFFSET) |
+          (bintobcd(dt->dt_mon) << MVSOCRTC_MONTH_OFFSET) |
+          (bintobcd(dt->dt_year % 100) << MVSOCRTC_YEAR_OFFSET);
 
        bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVSOCRTC_DATE, reg);
 
diff -r 18ff1b0040f8 -r dc6c9e624fa7 sys/arch/arm/omap/omap_rtc.c
--- a/sys/arch/arm/omap/omap_rtc.c      Thu Nov 20 16:26:34 2014 +0000
+++ b/sys/arch/arm/omap/omap_rtc.c      Thu Nov 20 16:34:25 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: omap_rtc.c,v 1.5 2011/07/01 20:30:21 dyoung Exp $      */
+/*     $NetBSD: omap_rtc.c,v 1.6 2014/11/20 16:34:25 christos Exp $    */
 
 /*
  * OMAP RTC driver, based on i80321_timer.c.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap_rtc.c,v 1.5 2011/07/01 20:30:21 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap_rtc.c,v 1.6 2014/11/20 16:34:25 christos Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -127,31 +127,31 @@
        }
 
        dt->dt_year =
-               FROMBCD(bus_space_read_1(sc->sc_iot,
+               bcdtobin(bus_space_read_1(sc->sc_iot,
                                         sc->sc_ioh,
                                         YEARS_REG)) + BASEYEAR;
        dt->dt_mon =
-               FROMBCD(bus_space_read_1(sc->sc_iot,
+               bcdtobin(bus_space_read_1(sc->sc_iot,
                                         sc->sc_ioh,
                                         MONTHS_REG));
        dt->dt_wday =
-               FROMBCD(bus_space_read_1(sc->sc_iot,
+               bcdtobin(bus_space_read_1(sc->sc_iot,
                                         sc->sc_ioh,
                                         WEEKS_REG) & 0x0f);
        dt->dt_day =
-               FROMBCD(bus_space_read_1(sc->sc_iot,
+               bcdtobin(bus_space_read_1(sc->sc_iot,
                                         sc->sc_ioh,
                                         DAYS_REG));
        dt->dt_sec =
-               FROMBCD(bus_space_read_1(sc->sc_iot,
+               bcdtobin(bus_space_read_1(sc->sc_iot,
                                         sc->sc_ioh,
                                         SECONDS_REG));
        dt->dt_hour =
-               FROMBCD(bus_space_read_1(sc->sc_iot,
+               bcdtobin(bus_space_read_1(sc->sc_iot,
                                         sc->sc_ioh,
                                         HOURS_REG));
        dt->dt_min =
-               FROMBCD(bus_space_read_1(sc->sc_iot,
+               bcdtobin(bus_space_read_1(sc->sc_iot,
                                         sc->sc_ioh,
                                         MINUTES_REG));
        restore_interrupts(s);
@@ -177,19 +177,19 @@
         */
 
        bus_space_write_1(sc->sc_iot, sc->sc_ioh,
-                         YEARS_REG, TOBCD(dt->dt_year - BASEYEAR));
+                         YEARS_REG, bintobcd(dt->dt_year - BASEYEAR));
        bus_space_write_1(sc->sc_iot, sc->sc_ioh,
-                         MONTHS_REG, TOBCD(dt->dt_mon));
+                         MONTHS_REG, bintobcd(dt->dt_mon));
        bus_space_write_1(sc->sc_iot, sc->sc_ioh,
-                         WEEKS_REG, TOBCD(dt->dt_wday & 0x0f));
+                         WEEKS_REG, bintobcd(dt->dt_wday & 0x0f));
        bus_space_write_1(sc->sc_iot, sc->sc_ioh,
-                         DAYS_REG, TOBCD(dt->dt_day));
+                         DAYS_REG, bintobcd(dt->dt_day));
        bus_space_write_1(sc->sc_iot, sc->sc_ioh,
-                         SECONDS_REG, TOBCD(dt->dt_sec));
+                         SECONDS_REG, bintobcd(dt->dt_sec));
        bus_space_write_1(sc->sc_iot, sc->sc_ioh,
-                         HOURS_REG, TOBCD(dt->dt_hour));
+                         HOURS_REG, bintobcd(dt->dt_hour));
        bus_space_write_1(sc->sc_iot, sc->sc_ioh,
-                         MINUTES_REG, TOBCD(dt->dt_min));
+                         MINUTES_REG, bintobcd(dt->dt_min));
        restore_interrupts(s);
         return 0;
 }
diff -r 18ff1b0040f8 -r dc6c9e624fa7 sys/arch/arm/s3c2xx0/s3c2440_rtc.c
--- a/sys/arch/arm/s3c2xx0/s3c2440_rtc.c        Thu Nov 20 16:26:34 2014 +0000
+++ b/sys/arch/arm/s3c2xx0/s3c2440_rtc.c        Thu Nov 20 16:34:25 2014 +0000
@@ -103,31 +103,31 @@
 
        reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDSEC);
        DPRINTF(("BCDSEC: %02X\n", reg));
-       dt.dt_sec = FROMBCD(reg);
+       dt.dt_sec = bcdtobin(reg);
 
        reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMIN);
        DPRINTF(("BCDMIN: %02X\n", reg));
-       dt.dt_min = FROMBCD(reg);
+       dt.dt_min = bcdtobin(reg);
 
        reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDHOUR);
        DPRINTF(("BCDHOUR: %02X\n", reg));
-       dt.dt_hour = FROMBCD(reg);
+       dt.dt_hour = bcdtobin(reg);
 
        reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDATE);
        DPRINTF(("BCDDATE: %02X\n", reg));
-       dt.dt_day = FROMBCD(reg);
+       dt.dt_day = bcdtobin(reg);
 
        reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDAY);
        DPRINTF(("BCDDAY: %02X\n", reg));
-       dt.dt_wday = FROMBCD(reg);
+       dt.dt_wday = bcdtobin(reg);
 
        reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMON);
        DPRINTF(("BCDMON: %02X\n", reg));
-       dt.dt_mon = FROMBCD(reg);
+       dt.dt_mon = bcdtobin(reg);
 
        reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_BCDYEAR);
        DPRINTF(("BCDYEAR: %02X\n", reg));
-       dt.dt_year = SSRTC_YEAR_ZERO + FROMBCD(reg);
+       dt.dt_year = SSRTC_YEAR_ZERO + bcdtobin(reg);
 
        DPRINTF(("Seconds: %d\n", dt.dt_sec));
        DPRINTF(("Minutes: %d\n", dt.dt_min));
@@ -158,13 +158,13 @@
        reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_RTCCON);
        bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_RTCCON, reg | RTCCON_RTCEN);
 
-       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDSEC, TOBCD(dt.dt_sec));
-       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMIN, TOBCD(dt.dt_min));
-       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDHOUR, TOBCD(dt.dt_hour));
-       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDATE, TOBCD(dt.dt_day));
-       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDAY, TOBCD(dt.dt_wday));
-       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMON, TOBCD(dt.dt_mon));
-       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDYEAR, TOBCD(dt.dt_year-SSRTC_YEAR_ZERO));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDSEC, bintobcd(dt.dt_sec));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMIN, bintobcd(dt.dt_min));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDHOUR, bintobcd(dt.dt_hour));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDATE, bintobcd(dt.dt_day));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDDAY, bintobcd(dt.dt_wday));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDMON, bintobcd(dt.dt_mon));
+       bus_space_write_1(sc->sc_iot, sc->sc_ioh, RTC_BCDYEAR, bintobcd(dt.dt_year-SSRTC_YEAR_ZERO));
 
        /* Clear RTCEN */
        reg = bus_space_read_1(sc->sc_iot, sc->sc_ioh, RTC_RTCCON);
diff -r 18ff1b0040f8 -r dc6c9e624fa7 sys/arch/evbarm/tsarm/tsrtc.c
--- a/sys/arch/evbarm/tsarm/tsrtc.c     Thu Nov 20 16:26:34 2014 +0000
+++ b/sys/arch/evbarm/tsarm/tsrtc.c     Thu Nov 20 16:34:25 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tsrtc.c,v 1.7 2011/07/01 19:11:34 dyoung Exp $ */
+/*     $NetBSD: tsrtc.c,v 1.8 2014/11/20 16:34:25 christos Exp $       */
 
 /*
  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tsrtc.c,v 1.7 2011/07/01 19:11:34 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tsrtc.c,v 1.8 2014/11/20 16:34:25 christos Exp $");
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
@@ -86,13 +86,13 @@
                return (0);
 
        /* Read from the seconds counter. */
-       t1 = FROMBCD(tsrtc_read(sc, MC_SEC));
+       t1 = bcdtobin(tsrtc_read(sc, MC_SEC));
        if (t1 > 59)
                goto unmap;
 
        /* Wait, then look again. */
        DELAY(1100000);
-       t2 = FROMBCD(tsrtc_read(sc, MC_SEC));
+       t2 = bcdtobin(tsrtc_read(sc, MC_SEC));
        if (t2 > 59)
                goto unmap;
 
diff -r 18ff1b0040f8 -r dc6c9e624fa7 sys/arch/evbppc/walnut/dev/ds1743.c
--- a/sys/arch/evbppc/walnut/dev/ds1743.c       Thu Nov 20 16:26:34 2014 +0000
+++ b/sys/arch/evbppc/walnut/dev/ds1743.c       Thu Nov 20 16:34:25 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ds1743.c,v 1.9 2011/07/01 19:03:50 dyoung Exp $        */
+/*     $NetBSD: ds1743.c,v 1.10 2014/11/20 16:34:25 christos Exp $     */
 
 /*
  * Copyright (c) 2001-2002 Wasabi Sysetms, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ds1743.c,v 1.9 2011/07/01 19:03:50 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ds1743.c,v 1.10 2014/11/20 16:34:25 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -234,14 +234,14 @@
 
        key = ds1743_lock(sc, DS_CTL_W);
        
-       ds1743_write(sc, DS_SECONDS, TOBCD(dt->dt_sec) & 0x7f);
-       ds1743_write(sc, DS_MINUTES, TOBCD(dt->dt_min) & 0x7f);
-       ds1743_write(sc, DS_HOURS, TOBCD(dt->dt_hour)  & 0x3f);
-       ds1743_write(sc, DS_DATE, TOBCD(dt->dt_day)    & 0x3f);
-       ds1743_write(sc, DS_MONTH, TOBCD(dt->dt_mon)   & 0x1f);
-       ds1743_write(sc, DS_YEAR, TOBCD(dt->dt_year % 100));
+       ds1743_write(sc, DS_SECONDS, bintobcd(dt->dt_sec) & 0x7f);
+       ds1743_write(sc, DS_MINUTES, bintobcd(dt->dt_min) & 0x7f);
+       ds1743_write(sc, DS_HOURS, bintobcd(dt->dt_hour)  & 0x3f);
+       ds1743_write(sc, DS_DATE, bintobcd(dt->dt_day)    & 0x3f);
+       ds1743_write(sc, DS_MONTH, bintobcd(dt->dt_mon)   & 0x1f);
+       ds1743_write(sc, DS_YEAR, bintobcd(dt->dt_year % 100));
        ds1743_write(sc, DS_CENTURY, ((ds1743_read(sc, DS_CENTURY) & DS_CTL_RW)
-                                     | TOBCD(dt->dt_year / 100)));
+                                     | bintobcd(dt->dt_year / 100)));
 
        ds1743_unlock(sc, key);
        return(0);
@@ -254,14 +254,14 @@
        u_char key;
        
        key = ds1743_lock(sc, DS_CTL_R);
-       dt->dt_sec = FROMBCD(ds1743_read(sc, DS_SECONDS) & 0x7f);
-       dt->dt_min = FROMBCD(ds1743_read(sc, DS_MINUTES) & 0x7f);
-       dt->dt_hour = FROMBCD(ds1743_read(sc, DS_HOURS) & 0x3f);
-       dt->dt_day = FROMBCD(ds1743_read(sc, DS_DATE)   & 0x3f);
-       dt->dt_mon = FROMBCD(ds1743_read(sc, DS_MONTH)   & 0x1f);
+       dt->dt_sec = bcdtobin(ds1743_read(sc, DS_SECONDS) & 0x7f);
+       dt->dt_min = bcdtobin(ds1743_read(sc, DS_MINUTES) & 0x7f);
+       dt->dt_hour = bcdtobin(ds1743_read(sc, DS_HOURS) & 0x3f);
+       dt->dt_day = bcdtobin(ds1743_read(sc, DS_DATE)   & 0x3f);
+       dt->dt_mon = bcdtobin(ds1743_read(sc, DS_MONTH)   & 0x1f);
        dt->dt_year =
-           FROMBCD(ds1743_read(sc, DS_YEAR)) +
-           FROMBCD(ds1743_read(sc, DS_CENTURY) & ~DS_CTL_RW) * 100; 



Home | Main Index | Thread Index | Old Index