]> git.karo-electronics.de Git - linux-beck.git/blobdiff - drivers/input/serio/hil_mlc.c
Input: HIL - various fixes for HIL drivers
[linux-beck.git] / drivers / input / serio / hil_mlc.c
index 5704204964a3545caac7c19bdc46999218ea139a..0710704d2fd30d36fdd23c4465cbb51c71f2c329 100644 (file)
@@ -59,7 +59,6 @@
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/timer.h>
-#include <linux/sched.h>
 #include <linux/list.h>
 
 MODULE_AUTHOR("Brian S. Julin <bri@calyx.com>");
@@ -162,10 +161,10 @@ static void hil_mlc_send_polls(hil_mlc *mlc) {
                if (did != (p & HIL_PKT_ADDR_MASK) >> 8) {
                        if (drv == NULL || drv->interrupt == NULL) goto skip;
 
-                       drv->interrupt(serio, 0, 0, NULL);
-                       drv->interrupt(serio, HIL_ERR_INT >> 16, 0, NULL);
-                       drv->interrupt(serio, HIL_PKT_CMD >> 8,  0, NULL);
-                       drv->interrupt(serio, HIL_CMD_POL + cnt, 0, NULL);
+                       drv->interrupt(serio, 0, 0);
+                       drv->interrupt(serio, HIL_ERR_INT >> 16, 0);
+                       drv->interrupt(serio, HIL_PKT_CMD >> 8,  0);
+                       drv->interrupt(serio, HIL_CMD_POL + cnt, 0);
                skip:
                        did = (p & HIL_PKT_ADDR_MASK) >> 8;
                        serio = did ? mlc->serio[mlc->di_map[did-1]] : NULL;
@@ -174,10 +173,10 @@ static void hil_mlc_send_polls(hil_mlc *mlc) {
                }
                cnt++; i++;
                if (drv == NULL || drv->interrupt == NULL) continue;
-               drv->interrupt(serio, (p >> 24), 0, NULL);
-               drv->interrupt(serio, (p >> 16) & 0xff, 0, NULL);
-               drv->interrupt(serio, (p >> 8) & ~HIL_PKT_ADDR_MASK, 0, NULL);
-               drv->interrupt(serio, p & 0xff, 0, NULL);
+               drv->interrupt(serio, (p >> 24), 0);
+               drv->interrupt(serio, (p >> 16) & 0xff, 0);
+               drv->interrupt(serio, (p >> 8) & ~HIL_PKT_ADDR_MASK, 0);
+               drv->interrupt(serio, p & 0xff, 0);
        }
 }
 
@@ -391,25 +390,25 @@ static int hilse_operate(hil_mlc *mlc, int repoll) {
 }
 
 #define FUNC(funct, funct_arg, zero_rc, neg_rc, pos_rc) \
-{ HILSE_FUNC,          { func: &funct }, funct_arg, zero_rc, neg_rc, pos_rc },
+{ HILSE_FUNC,          { .func = funct }, funct_arg, zero_rc, neg_rc, pos_rc },
 #define OUT(pack) \
-{ HILSE_OUT,           { packet: pack }, 0, HILSEN_NEXT, HILSEN_DOZE, 0 },
+{ HILSE_OUT,           { .packet = pack }, 0, HILSEN_NEXT, HILSEN_DOZE, 0 },
 #define CTS \
-{ HILSE_CTS,           { packet: 0    }, 0, HILSEN_NEXT | HILSEN_SCHED | HILSEN_BREAK, HILSEN_DOZE, 0 },
+{ HILSE_CTS,           { .packet = 0    }, 0, HILSEN_NEXT | HILSEN_SCHED | HILSEN_BREAK, HILSEN_DOZE, 0 },
 #define EXPECT(comp, to, got, got_wrong, timed_out) \
-{ HILSE_EXPECT,                { packet: comp }, to, got, got_wrong, timed_out },
+{ HILSE_EXPECT,                { .packet = comp }, to, got, got_wrong, timed_out },
 #define EXPECT_LAST(comp, to, got, got_wrong, timed_out) \
-{ HILSE_EXPECT_LAST,   { packet: comp }, to, got, got_wrong, timed_out },
+{ HILSE_EXPECT_LAST,   { .packet = comp }, to, got, got_wrong, timed_out },
 #define EXPECT_DISC(comp, to, got, got_wrong, timed_out) \
-{ HILSE_EXPECT_DISC,   { packet: comp }, to, got, got_wrong, timed_out },
+{ HILSE_EXPECT_DISC,   { .packet = comp }, to, got, got_wrong, timed_out },
 #define IN(to, got, got_error, timed_out) \
-{ HILSE_IN,            { packet: 0    }, to, got, got_error, timed_out },
+{ HILSE_IN,            { .packet = 0    }, to, got, got_error, timed_out },
 #define OUT_DISC(pack) \
-{ HILSE_OUT_DISC,      { packet: pack }, 0, 0, 0, 0 },
+{ HILSE_OUT_DISC,      { .packet = pack }, 0, 0, 0, 0 },
 #define OUT_LAST(pack) \
-{ HILSE_OUT_LAST,      { packet: pack }, 0, 0, 0, 0 },
+{ HILSE_OUT_LAST,      { .packet = pack }, 0, 0, 0, 0 },
 
-struct hilse_node hil_mlc_se[HILSEN_END] = {
+const struct hilse_node hil_mlc_se[HILSEN_END] = {
 
        /* 0  HILSEN_START */
        FUNC(hilse_init_lcv, 0, HILSEN_NEXT,    HILSEN_SLEEP,   0)
@@ -531,7 +530,7 @@ struct hilse_node hil_mlc_se[HILSEN_END] = {
        /* 60 HILSEN_END */
 };
 
-static inline void hilse_setup_input(hil_mlc *mlc, struct hilse_node *node) {
+static inline void hilse_setup_input(hil_mlc *mlc, const struct hilse_node *node) {
 
        switch (node->act) {
        case HILSE_EXPECT_DISC:
@@ -556,7 +555,7 @@ static inline void hilse_setup_input(hil_mlc *mlc, struct hilse_node *node) {
        do_gettimeofday(&(mlc->instart));
        mlc->icount = 15;
        memset(mlc->ipacket, 0, 16 * sizeof(hil_packet));
-       if (down_trylock(&(mlc->isem))) BUG();
+       BUG_ON(down_trylock(&(mlc->isem)));
 
        return;
 }
@@ -564,21 +563,19 @@ static inline void hilse_setup_input(hil_mlc *mlc, struct hilse_node *node) {
 #ifdef HIL_MLC_DEBUG
 static int doze = 0;
 static int seidx; /* For debug */
-static int kick = 1;
 #endif
 
 static int hilse_donode (hil_mlc *mlc) {
-       struct hilse_node *node;
+       const struct hilse_node *node;
        int nextidx = 0;
        int sched_long = 0;
        unsigned long flags;
 
 #ifdef HIL_MLC_DEBUG
        if (mlc->seidx && (mlc->seidx != seidx)  && mlc->seidx != 41 && mlc->seidx != 42 && mlc->seidx != 43) {
-         printk(KERN_DEBUG PREFIX "z%i \n%s {%i}", doze, kick ? "K" : "", mlc->seidx);
+         printk(KERN_DEBUG PREFIX "z%i \n {%i}", doze, mlc->seidx);
                doze = 0;
        }
-       kick = 0;
 
        seidx = mlc->seidx;
 #endif
@@ -589,7 +586,7 @@ static int hilse_donode (hil_mlc *mlc) {
                hil_packet pack;
 
        case HILSE_FUNC:
-               if (node->object.func == NULL) break;
+               BUG_ON(node->object.func == NULL);
                rc = node->object.func(mlc, node->arg);
                nextidx = (rc > 0) ? node->ugly : 
                        ((rc < 0) ? node->bad : node->good);
@@ -675,10 +672,10 @@ static int hilse_donode (hil_mlc *mlc) {
                if (!sched_long) goto sched;
 
                do_gettimeofday(&tv);
-               tv.tv_usec += 1000000 * (tv.tv_sec - mlc->instart.tv_sec);
+               tv.tv_usec += USEC_PER_SEC * (tv.tv_sec - mlc->instart.tv_sec);
                tv.tv_usec -= mlc->instart.tv_usec;
                if (tv.tv_usec >= mlc->intimeout) goto sched;
-               tv.tv_usec = (mlc->intimeout - tv.tv_usec) * HZ / 1000000;
+               tv.tv_usec = (mlc->intimeout - tv.tv_usec) * HZ / USEC_PER_SEC;
                if (!tv.tv_usec) goto sched;
                mod_timer(&hil_mlcs_kicker, jiffies + tv.tv_usec);
                break;
@@ -780,16 +777,16 @@ static int hil_mlc_serio_write(struct serio *serio, unsigned char c) {
        while ((last != idx) && (*last == 0)) last--;
 
        while (idx != last) {
-               drv->interrupt(serio, 0, 0, NULL);
-               drv->interrupt(serio, HIL_ERR_INT >> 16, 0, NULL);
-               drv->interrupt(serio, 0, 0, NULL);
-               drv->interrupt(serio, *idx, 0, NULL);
+               drv->interrupt(serio, 0, 0);
+               drv->interrupt(serio, HIL_ERR_INT >> 16, 0);
+               drv->interrupt(serio, 0, 0);
+               drv->interrupt(serio, *idx, 0);
                idx++;
        }
-       drv->interrupt(serio, 0, 0, NULL);
-       drv->interrupt(serio, HIL_ERR_INT >> 16, 0, NULL);
-       drv->interrupt(serio, HIL_PKT_CMD >> 8, 0, NULL);
-       drv->interrupt(serio, *idx, 0, NULL);
+       drv->interrupt(serio, 0, 0);
+       drv->interrupt(serio, HIL_ERR_INT >> 16, 0);
+       drv->interrupt(serio, HIL_PKT_CMD >> 8, 0);
+       drv->interrupt(serio, *idx, 0);
        
        mlc->serio_oidx[map->didx] = 0;
        mlc->serio_opacket[map->didx] = 0;
@@ -838,7 +835,7 @@ static void hil_mlc_serio_close(struct serio *serio) {
        /* TODO wake up interruptable */
 }
 
-static struct serio_device_id hil_mlc_serio_id = {
+static const struct serio_device_id hil_mlc_serio_id = {
        .type = SERIO_HIL_MLC,
        .proto = SERIO_HIL,
        .extra = SERIO_ANY,
@@ -872,9 +869,10 @@ int hil_mlc_register(hil_mlc *mlc) {
        for (i = 0; i < HIL_MLC_DEVMEM; i++) {
                struct serio *mlc_serio;
                hil_mlc_copy_di_scratch(mlc, i);
-               mlc_serio = kmalloc(sizeof(*mlc_serio), GFP_KERNEL);
+               mlc_serio = kzalloc(sizeof(*mlc_serio), GFP_KERNEL);
                mlc->serio[i] = mlc_serio;
-               memset(mlc_serio, 0, sizeof(*mlc_serio));
+               snprintf(mlc_serio->name, sizeof(mlc_serio->name)-1, "HIL_SERIO%d", i);
+               snprintf(mlc_serio->phys, sizeof(mlc_serio->phys)-1, "HIL%d", i);
                mlc_serio->id                   = hil_mlc_serio_id;
                mlc_serio->write                = hil_mlc_serio_write;
                mlc_serio->open                 = hil_mlc_serio_open;