Subject: kern/24230: The mistake of addressing
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <kiyohara@kk.iij4u.or.jp>
List: netbsd-bugs
Date: 01/25/2004 06:21:35
>Number: 24230
>Category: kern
>Synopsis: The mistake of addressing
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: kern-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sun Jan 25 06:22:01 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator: KIYOHARA Takashi
>Release: NetBSD 1.6ZG
>Organization:
>Environment:
NetBSD evbppc.fool 1.6ZG NetBSD 1.6ZG (OPENBLOCKS266) #0: Sun Dec 21 12:58:20 JST 2003 lance@evbppc.fool:/sys/arch/evbppc/compile/OPENBLOCKS266 evbppc
>Description:
Address specification of x1226 is big enddian. It checked by the datasheet. However, it is little endian now.
>How-To-Repeat:
>Fix:
Index: x1226.c
===================================================================
RCS file: /cvsroot/src/sys/dev/i2c/x1226.c,v
retrieving revision 1.1
diff -c -r1.1 x1226.c
*** x1226.c 2003/10/06 18:02:02 1.1
--- x1226.c 2004/01/15 15:21:08
***************
*** 176,183 ****
while (uio->uio_resid && uio->uio_offset < X1226_NVRAM_SIZE) {
addr = (int)uio->uio_offset + X1226_NVRAM_START;
! cmdbuf[0] = addr && 0xff;
! cmdbuf[1] = (addr >> 8) && 0xff;
if ((error = iic_exec(sc->sc_tag,
I2C_OP_READ_WITH_STOP,
sc->sc_address, cmdbuf, 2, &ch, 1, 0)) != 0) {
--- 176,183 ----
while (uio->uio_resid && uio->uio_offset < X1226_NVRAM_SIZE) {
addr = (int)uio->uio_offset + X1226_NVRAM_START;
! cmdbuf[0] = (addr >> 8) && 0xff;
! cmdbuf[1] = addr && 0xff;
if ((error = iic_exec(sc->sc_tag,
I2C_OP_READ_WITH_STOP,
sc->sc_address, cmdbuf, 2, &ch, 1, 0)) != 0) {
***************
*** 216,223 ****
while (uio->uio_resid && uio->uio_offset < X1226_NVRAM_SIZE) {
addr = (int)uio->uio_offset + X1226_NVRAM_START;
! cmdbuf[0] = addr && 0xff;
! cmdbuf[1] = (addr >> 8) && 0xff;
if ((error = uiomove(&cmdbuf[2], 1, uio)) != 0) {
break;
}
--- 216,223 ----
while (uio->uio_resid && uio->uio_offset < X1226_NVRAM_SIZE) {
addr = (int)uio->uio_offset + X1226_NVRAM_START;
! cmdbuf[0] = (addr >> 8) && 0xff;
! cmdbuf[1] = addr && 0xff;
if ((error = uiomove(&cmdbuf[2], 1, uio)) != 0) {
break;
}
***************
*** 300,307 ****
/* Read each RTC register in order */
for (i = 0 ; i < X1226_REG_RTC_SIZE ; i++) {
int addr = i + X1226_REG_RTC_BASE;
! cmdbuf[0] = addr & 0xff;
! cmdbuf[1] = (addr >> 8) & 0xff;
if (iic_exec(sc->sc_tag,
I2C_OP_READ_WITH_STOP,
--- 300,307 ----
/* Read each RTC register in order */
for (i = 0 ; i < X1226_REG_RTC_SIZE ; i++) {
int addr = i + X1226_REG_RTC_BASE;
! cmdbuf[0] = (addr >> 8) & 0xff;
! cmdbuf[1] = addr & 0xff;
if (iic_exec(sc->sc_tag,
I2C_OP_READ_WITH_STOP,
***************
*** 373,380 ****
/* Unlock register: Write Enable Latch */
addr = X1226_REG_SR;
! cmdbuf[0] = (addr & 0xff);
! cmdbuf[1] = ((addr >> 8) & 0xff);
cmdbuf[2] = X1226_FLAG_SR_WEL;
if (iic_exec(sc->sc_tag,
I2C_OP_WRITE_WITH_STOP,
--- 375,382 ----
/* Unlock register: Write Enable Latch */
addr = X1226_REG_SR;
! cmdbuf[0] = ((addr >> 8) & 0xff);
! cmdbuf[1] = (addr & 0xff);
cmdbuf[2] = X1226_FLAG_SR_WEL;
if (iic_exec(sc->sc_tag,
I2C_OP_WRITE_WITH_STOP,
***************
*** 388,395 ****
/* Unlock register: Register Write Enable Latch */
addr = X1226_REG_SR;
! cmdbuf[0] = (addr & 0xff);
! cmdbuf[1] = ((addr >> 8) & 0xff);
cmdbuf[2] = X1226_FLAG_SR_RWEL;
if (iic_exec(sc->sc_tag,
I2C_OP_WRITE_WITH_STOP,
--- 390,397 ----
/* Unlock register: Register Write Enable Latch */
addr = X1226_REG_SR;
! cmdbuf[0] = ((addr >> 8) & 0xff);
! cmdbuf[1] = (addr & 0xff);
cmdbuf[2] = X1226_FLAG_SR_RWEL;
if (iic_exec(sc->sc_tag,
I2C_OP_WRITE_WITH_STOP,
***************
*** 404,411 ****
/* Write each RTC register in reverse order */
for (i = (X1226_REG_RTC_SIZE - 1) ; i >= 0; i--) {
int addr = i + X1226_REG_RTC_BASE;
! cmdbuf[0] = (addr & 0xff);
! cmdbuf[1] = ((addr >> 8) & 0xff);
if (iic_exec(sc->sc_tag,
I2C_OP_WRITE_WITH_STOP,
sc->sc_address, cmdbuf, 2,
--- 406,413 ----
/* Write each RTC register in reverse order */
for (i = (X1226_REG_RTC_SIZE - 1) ; i >= 0; i--) {
int addr = i + X1226_REG_RTC_BASE;
! cmdbuf[0] = ((addr >> 8) & 0xff);
! cmdbuf[1] = (addr & 0xff);
if (iic_exec(sc->sc_tag,
I2C_OP_WRITE_WITH_STOP,
sc->sc_address, cmdbuf, 2,
***************
*** 413,420 ****
/* Lock register: WEL/RWEL off */
addr = X1226_REG_SR;
! cmdbuf[0] = (addr & 0xff);
! cmdbuf[1] = (addr & 0xff);
cmdbuf[2] = 0;
iic_exec(sc->sc_tag,
I2C_OP_WRITE_WITH_STOP,
***************
*** 430,437 ****
/* Lock register: WEL/RWEL off */
addr = X1226_REG_SR;
! cmdbuf[0] = (addr & 0xff);
! cmdbuf[1] = ((addr >> 8) & 0xff);
cmdbuf[2] = X1226_FLAG_SR_WEL;
if (iic_exec(sc->sc_tag,
I2C_OP_WRITE_WITH_STOP,
--- 432,439 ----
/* Lock register: WEL/RWEL off */
addr = X1226_REG_SR;
! cmdbuf[0] = ((addr >> 8) & 0xff);
! cmdbuf[1] = (addr & 0xff);
cmdbuf[2] = X1226_FLAG_SR_WEL;
if (iic_exec(sc->sc_tag,
I2C_OP_WRITE_WITH_STOP,
>Release-Note:
>Audit-Trail:
>Unformatted: