Module Name: src Committed By: jakllsch Date: Fri Aug 5 20:51:10 UTC 2011
Modified Files: src/sys/dev/i2c: mt2131.c Log Message: Various cleanup, mostly reducing debugging spew. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/i2c/mt2131.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/i2c/mt2131.c diff -u src/sys/dev/i2c/mt2131.c:1.2 src/sys/dev/i2c/mt2131.c:1.3 --- src/sys/dev/i2c/mt2131.c:1.2 Thu Aug 4 22:24:29 2011 +++ src/sys/dev/i2c/mt2131.c Fri Aug 5 20:51:09 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: mt2131.c,v 1.2 2011/08/04 22:24:29 jmcneill Exp $ */ +/* $NetBSD: mt2131.c,v 1.3 2011/08/05 20:51:09 jakllsch Exp $ */ /* * Copyright (c) 2008, 2011 Jonathan A. Kollasch @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mt2131.c,v 1.2 2011/08/04 22:24:29 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mt2131.c,v 1.3 2011/08/05 20:51:09 jakllsch Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -80,12 +80,9 @@ { struct mt2131_softc *sc; int ret; - uint8_t cmd, reg; - - cmd = reg = 0; - printf("%s\n", __func__); + cmd = reg = 0; /* get id reg */ iic_acquire_bus(t, I2C_F_POLL); @@ -93,14 +90,15 @@ iic_release_bus(t, I2C_F_POLL); if (ret) { - printf("%s read fail\n", __func__); + device_printf(parent, "%s(): read fail\n", __func__); return NULL; } - printf("%s %02x\n", __func__, reg); - - if ((reg & 0xfe) != 0x3e) + if ((reg & 0xfe) != 0x3e) { + device_printf(parent, "%s(): chip id %02x unknown\n", + __func__, reg); return NULL; + } sc = kmem_alloc(sizeof(*sc), KM_SLEEP); if (sc == NULL) @@ -124,7 +122,7 @@ int mt2131_tune_dtv(struct mt2131_softc *sc, const struct dvb_frontend_parameters *p) { - int rv; + int rv, i; uint64_t o1, o2; uint64_t d1, d2; uint32_t r1, r2; @@ -151,9 +149,6 @@ r1 = d1/8192; r2 = d2/8192; - printf("mt2131 %lu %lu %lu %u\n", o1, d1, d1&0x1fff, r1); - printf("mt2131 %lu %lu %lu %u\n", o2, d2, d2&0x1fff, r2); - b[1] = (d1 & 0x1fe0) >> 5; b[2] = (d1 & 0x001f); b[3] = r1; @@ -170,31 +165,27 @@ if(regval > 0x13) regval = 0x13; - printf("mt2131 %u\n", regval); - rv = mt2131_write(sc, UPC_1, regval); if (rv != 0) - printf("%s\n", __func__); + device_printf(sc->parent, "%s write failed\n", __func__); sc->frequency = (o1 - o2 - IF2) * 1000; - printf("%s freq %d\n", __func__, sc->frequency); - int i; - b[0] = 0x08; + for (i = 0; i < 100; i++) { + kpause("mt2131", true, 1, NULL); - for ( i = 0; i < 100; i++) { rv = mt2131_read(sc, 0x08, ®val); + if (rv != 0) + device_printf(sc->parent, "%s read failed\n", __func__); if (( regval & 0x88 ) == 0x88 ) { - printf("mt2131 - locked\n"); - break; - } else { - printf("mt2131 - not locked - %02x\n", b[1]); + return 0; } - kpause("mt2131", true, 1, NULL); } + device_printf(sc->parent, "mt2131 not locked, %02x\n", b[1]); + return rv; } @@ -203,8 +194,6 @@ { int ret; - printf("%s\n", __func__); - ret = iic_acquire_bus(sc->tag, I2C_F_POLL); if (ret) return -1;