Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Misc KNF.



details:   https://anonhg.NetBSD.org/src/rev/e2243367596e
branches:  trunk
changeset: 747047:e2243367596e
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Aug 30 02:07:05 2009 +0000

description:
Misc KNF.

diffstat:

 sys/dev/ic/hd44780_subr.c |  271 +++++++++++++++++++++++----------------------
 sys/dev/ic/hd44780reg.h   |   20 +-
 sys/dev/ic/hd44780var.h   |   57 ++++----
 3 files changed, 180 insertions(+), 168 deletions(-)

diffs (truncated from 655 to 300 lines):

diff -r 2d0b2d51aa0a -r e2243367596e sys/dev/ic/hd44780_subr.c
--- a/sys/dev/ic/hd44780_subr.c Sun Aug 30 02:03:58 2009 +0000
+++ b/sys/dev/ic/hd44780_subr.c Sun Aug 30 02:07:05 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hd44780_subr.c,v 1.19 2009/03/16 23:11:15 dsl Exp $ */
+/* $NetBSD: hd44780_subr.c,v 1.20 2009/08/30 02:07:05 tsutsui Exp $ */
 
 /*
  * Copyright (c) 2002 Dennis I. Chernoivanov
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hd44780_subr.c,v 1.19 2009/03/16 23:11:15 dsl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hd44780_subr.c,v 1.20 2009/08/30 02:07:05 tsutsui Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -118,12 +118,13 @@
 static int
 hlcd_mapchar(void *id, int uni, unsigned int *index)
 {
+
        if (uni < 256) {
                *index = uni;
-               return (5);
+               return 5;
        }
        *index = ' ';
-       return (0);
+       return 0;
 }
 
 static void
@@ -202,6 +203,7 @@
 static int
 hlcd_allocattr(void *id, int fg, int bg, int flags, long *attrp)
 {
+
         *attrp = flags;
         return 0;
 }
@@ -231,11 +233,13 @@
 static paddr_t
 hlcd_mmap(void *v, void *vs, off_t offset, int prot)
 {
+
        return -1;
 }
 
 static int
-hlcd_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep, int *curxp, int *curyp, long *defattrp)
+hlcd_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
+    int *curxp, int *curyp, long *defattrp)
 {
        struct hlcd_screen *hdscr = v, *new;
 
@@ -254,13 +258,14 @@
 }
 
 static int
-hlcd_show_screen(void *v, void *cookie, int waitok, void (*cb)(void *, int, int), void *cbarg)
+hlcd_show_screen(void *v, void *cookie, int waitok,
+    void (*cb)(void *, int, int), void *cbarg)
 {
        struct hlcd_screen *hdscr = v;
 
        hdscr->hlcd_sc->sc_curscr = cookie;
        callout_schedule(&hdscr->hlcd_sc->redraw, 1);
-       return (0);
+       return 0;
 }
 
 static void
@@ -288,7 +293,7 @@
        struct hd44780_chip *sc = arg;
        int len, crsridx, startidx, x, y;
        int old_en, new_en;
-       u_char *img, *curimg;
+       uint8_t *img, *curimg;
 
        if (sc->sc_curscr == NULL)
                return;
@@ -361,6 +366,7 @@
 hd44780_attach_subr(struct hd44780_chip *sc)
 {
        int err = 0;
+
        /* Putc/getc are supposed to be set by platform-dependent code. */
        if ((sc->sc_writereg == NULL) || (sc->sc_readreg == NULL))
                sc->sc_dev_ok = 0;
@@ -375,8 +381,8 @@
                if ((sc->sc_flags & HD_UP) == 0)
                        err = hd44780_init(sc);
                if (err != 0)
-                       aprint_error_dev(sc->sc_dev, "LCD not responding or unconnected\n");
-
+                       aprint_error_dev(sc->sc_dev,
+                           "LCD not responding or unconnected\n");
        }
 
        sc->sc_screen.hlcd_sc = sc;
@@ -389,23 +395,24 @@
        callout_setfunc(&sc->redraw, hlcd_redraw, sc);
 }
 
-int hd44780_init(sc)
-       struct hd44780_chip *sc;
+int hd44780_init(struct hd44780_chip *sc)
 {
        int ret;
 
        ret = hd44780_chipinit(sc, 0);
-       if (ret != 0 || !(sc->sc_flags & HD_MULTICHIP)) return ret;
-       else return hd44780_chipinit(sc, 1);
+       if (ret != 0 || !(sc->sc_flags & HD_MULTICHIP))
+               return ret;
+       else
+               return hd44780_chipinit(sc, 1);
 }
 
 /*
  * Initialize 4-bit or 8-bit connected device.
  */
 int
-hd44780_chipinit(struct hd44780_chip *sc, u_int32_t en)
+hd44780_chipinit(struct hd44780_chip *sc, uint32_t en)
 {
-       u_int8_t cmd, dat;
+       uint8_t cmd, dat;
 
        sc->sc_flags &= ~(HD_TIMEDOUT|HD_UP);
        sc->sc_dev_ok = 1;
@@ -460,131 +467,131 @@
 int
 hd44780_ioctl_subr(struct hd44780_chip *sc, u_long cmd, void *data)
 {
-       u_int8_t tmp;
+       uint8_t tmp;
        int error = 0;
-       u_int32_t en = sc->sc_curchip;
+       uint32_t en = sc->sc_curchip;
 
 #define hd44780_io()   ((struct hd44780_io *)data)
-#define hd44780_info() ((struct hd44780_info*)data)
-#define hd44780_ctrl() ((struct hd44780_dispctl*)data)
+#define hd44780_info() ((struct hd44780_info *)data)
+#define hd44780_ctrl() ((struct hd44780_dispctl *)data)
 
        switch (cmd) {
+       case HLCD_CLEAR:
                /* Clear the LCD. */
-               case HLCD_CLEAR:
-                       hd44780_ir_write(sc, en, cmd_clear());
-                       break;
-
-               /* Move the cursor one position to the left. */
-               case HLCD_CURSOR_LEFT:
-                       hd44780_ir_write(sc, en, cmd_shift(0, 0));
-                       break;
-
-               /* Move the cursor one position to the right. */
-               case HLCD_CURSOR_RIGHT:
-                       hd44780_ir_write(sc, en, cmd_shift(0, 1));
-                       break;
-
-               /* Control the LCD. */
-               case HLCD_DISPCTL:
-                       hd44780_ir_write(sc, en, cmd_dispctl(
-                                               hd44780_ctrl()->display_on,
-                                               hd44780_ctrl()->cursor_on,
-                                               hd44780_ctrl()->blink_on));
-                       break;
+               hd44780_ir_write(sc, en, cmd_clear());
+               break;
 
-               /* Get LCD configuration. */
-               case HLCD_GET_INFO:
-                       hd44780_info()->lines
-                               = (sc->sc_flags & HD_MULTILINE) ? 2 : 1;
-                       if (sc->sc_flags & HD_MULTICHIP)
-                               hd44780_info()->lines *= 2;
-                       hd44780_info()->phys_rows = sc->sc_cols;
-                       hd44780_info()->virt_rows = sc->sc_vcols;
-                       hd44780_info()->is_wide = sc->sc_flags & HD_8BIT;
-                       hd44780_info()->is_bigfont = sc->sc_flags & HD_BIGFONT;
-                       hd44780_info()->kp_present = sc->sc_flags & HD_KEYPAD;
-                       break;
-
-
-               /* Reset the LCD. */
-               case HLCD_RESET:
-                       error = hd44780_init(sc);
-                       break;
-
-               /* Get the current cursor position. */
-               case HLCD_GET_CURSOR_POS:
-                       hd44780_io()->dat = (hd44780_ir_read(sc, en) & 0x7f);
-                       break;
-
-               /* Set the cursor position. */
-               case HLCD_SET_CURSOR_POS:
-                       hd44780_ir_write(sc, en, cmd_ddramset(hd44780_io()->dat));
+       case HLCD_CURSOR_LEFT:
+               /* Move the cursor one position to the left. */
+               hd44780_ir_write(sc, en, cmd_shift(0, 0));
                        break;
 
-               /* Get the value at the current cursor position. */
-               case HLCD_GETC:
-                       tmp = (hd44780_ir_read(sc, en) & 0x7f);
-                       hd44780_ir_write(sc, en, cmd_ddramset(tmp));
-                       hd44780_io()->dat = hd44780_dr_read(sc, en);
-                       break;
+       case HLCD_CURSOR_RIGHT:
+               /* Move the cursor one position to the right. */
+               hd44780_ir_write(sc, en, cmd_shift(0, 1));
+               break;
 
-               /* Set the character at the cursor position + advance cursor. */
-               case HLCD_PUTC:
-                       hd44780_dr_write(sc, en, hd44780_io()->dat);
-                       break;
+       case HLCD_DISPCTL:
+               /* Control the LCD. */
+               hd44780_ir_write(sc, en, cmd_dispctl(
+                                       hd44780_ctrl()->display_on,
+                                       hd44780_ctrl()->cursor_on,
+                                       hd44780_ctrl()->blink_on));
+               break;
 
-               /* Shift display left. */
-               case HLCD_SHIFT_LEFT:
-                       hd44780_ir_write(sc, en, cmd_shift(1, 0));
-                       break;
+       case HLCD_GET_INFO:
+               /* Get LCD configuration. */
+               hd44780_info()->lines
+                       = (sc->sc_flags & HD_MULTILINE) ? 2 : 1;
+               if (sc->sc_flags & HD_MULTICHIP)
+                       hd44780_info()->lines *= 2;
+               hd44780_info()->phys_rows = sc->sc_cols;
+               hd44780_info()->virt_rows = sc->sc_vcols;
+               hd44780_info()->is_wide = sc->sc_flags & HD_8BIT;
+               hd44780_info()->is_bigfont = sc->sc_flags & HD_BIGFONT;
+               hd44780_info()->kp_present = sc->sc_flags & HD_KEYPAD;
+               break;
 
-               /* Shift display right. */
-               case HLCD_SHIFT_RIGHT:
-                       hd44780_ir_write(sc, en, cmd_shift(1, 1));
-                       break;
 
-               /* Return home. */
-               case HLCD_HOME:
-                       hd44780_ir_write(sc, en, cmd_rethome());
-                       break;
+       case HLCD_RESET:
+               /* Reset the LCD. */
+               error = hd44780_init(sc);
+               break;
+
+       case HLCD_GET_CURSOR_POS:
+               /* Get the current cursor position. */
+               hd44780_io()->dat = (hd44780_ir_read(sc, en) & 0x7f);
+               break;
 
-               /* Write a string to the LCD virtual area. */
-               case HLCD_WRITE:
-                       error = hd44780_ddram_io(sc, en, hd44780_io(), HD_DDRAM_WRITE);
-                       break;
+       case HLCD_SET_CURSOR_POS:
+               /* Set the cursor position. */
+               hd44780_ir_write(sc, en, cmd_ddramset(hd44780_io()->dat));
+               break;
+
+       case HLCD_GETC:
+               /* Get the value at the current cursor position. */
+               tmp = (hd44780_ir_read(sc, en) & 0x7f);
+               hd44780_ir_write(sc, en, cmd_ddramset(tmp));
+               hd44780_io()->dat = hd44780_dr_read(sc, en);
+               break;
 
+       case HLCD_PUTC:
+               /* Set the character at the cursor position + advance cursor. */
+               hd44780_dr_write(sc, en, hd44780_io()->dat);
+               break;
+
+       case HLCD_SHIFT_LEFT:
+               /* Shift display left. */
+               hd44780_ir_write(sc, en, cmd_shift(1, 0));
+               break;
+
+       case HLCD_SHIFT_RIGHT:
+               /* Shift display right. */
+               hd44780_ir_write(sc, en, cmd_shift(1, 1));
+               break;
+
+       case HLCD_HOME:
+               /* Return home. */



Home | Main Index | Thread Index | Old Index