Deleted Added
full compact
36c36
< __FBSDID("$FreeBSD: head/sys/pci/amdpm.c 158651 2006-05-16 14:37:58Z phk $");
---
> __FBSDID("$FreeBSD: head/sys/pci/amdpm.c 162234 2006-09-11 20:52:41Z jhb $");
239c239
< amdpm_callback(device_t dev, int index, caddr_t *data)
---
> amdpm_callback(device_t dev, int index, void *data)
507,508c507,508
< u_char remain, len, i;
< int error = SMB_ENOERR;
---
> u_char i;
> int error;
510a511,512
> if (count < 1 || count > 32)
> return (SMB_EINVAL);
515,519c517
< remain = count;
< while (remain) {
< len = min(remain, 32);
<
< AMDPM_SMBOUTW(sc, AMDSMB_HSTADDR, slave & ~LSB);
---
> AMDPM_SMBOUTW(sc, AMDSMB_HSTADDR, slave & ~LSB);
521,524c519,523
< /*
< * Do we have to reset the internal 32-byte buffer?
< * Can't see how to do this from the data sheet.
< */
---
> /*
> * Do we have to reset the internal 32-byte buffer?
> * Can't see how to do this from the data sheet.
> */
> AMDPM_SMBOUTW(sc, AMDSMB_HSTDATA, count);
526,540c525,528
< AMDPM_SMBOUTW(sc, AMDSMB_HSTDATA, len);
<
< /* Fill the 32-byte internal buffer */
< for (i=0; i<len; i++) {
< AMDPM_SMBOUTB(sc, AMDSMB_HSTDFIFO, buf[count-remain+i]);
< DELAY(2);
< }
< AMDPM_SMBOUTB(sc, AMDSMB_HSTCMD, cmd);
< l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE);
< AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE, (l & 0xfff8) | AMDSMB_GE_CYC_BLOCK | AMDSMB_GE_HOST_STC);
<
< if ((error = amdpm_wait(sc)) != SMB_ENOERR)
< goto error;
<
< remain -= len;
---
> /* Fill the 32-byte internal buffer */
> for (i = 0; i < count; i++) {
> AMDPM_SMBOUTB(sc, AMDSMB_HSTDFIFO, buf[i]);
> DELAY(2);
541a530,533
> AMDPM_SMBOUTB(sc, AMDSMB_HSTCMD, cmd);
> l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE);
> AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE,
> (l & 0xfff8) | AMDSMB_GE_CYC_BLOCK | AMDSMB_GE_HOST_STC);
543c535,536
< error:
---
> error = amdpm_wait(sc);
>
550c543
< amdpm_bread(device_t dev, u_char slave, char cmd, u_char count, char *buf)
---
> amdpm_bread(device_t dev, u_char slave, char cmd, u_char *count, char *buf)
553,554c546,547
< u_char remain, len, i;
< int error = SMB_ENOERR;
---
> u_char data, len, i;
> int error;
556a550,551
> if (*count < 1 || *count > 32)
> return (SMB_EINVAL);
561,563c556
< remain = count;
< while (remain) {
< AMDPM_SMBOUTW(sc, AMDSMB_HSTADDR, slave | LSB);
---
> AMDPM_SMBOUTW(sc, AMDSMB_HSTADDR, slave | LSB);
565c558
< AMDPM_SMBOUTB(sc, AMDSMB_HSTCMD, cmd);
---
> AMDPM_SMBOUTB(sc, AMDSMB_HSTCMD, cmd);
567,568c560,562
< l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE);
< AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE, (l & 0xfff8) | AMDSMB_GE_CYC_BLOCK | AMDSMB_GE_HOST_STC);
---
> l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE);
> AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE,
> (l & 0xfff8) | AMDSMB_GE_CYC_BLOCK | AMDSMB_GE_HOST_STC);
570,571c564,565
< if ((error = amdpm_wait(sc)) != SMB_ENOERR)
< goto error;
---
> if ((error = amdpm_wait(sc)) != SMB_ENOERR)
> goto error;
573c567
< len = AMDPM_SMBINW(sc, AMDSMB_HSTDATA);
---
> len = AMDPM_SMBINW(sc, AMDSMB_HSTDATA);
575,581c569,574
< /* Read the 32-byte internal buffer */
< for (i=0; i<len; i++) {
< buf[count-remain+i] = AMDPM_SMBINB(sc, AMDSMB_HSTDFIFO);
< DELAY(2);
< }
<
< remain -= len;
---
> /* Read the 32-byte internal buffer */
> for (i = 0; i < len; i++) {
> data = AMDPM_SMBINB(sc, AMDSMB_HSTDFIFO);
> if (i < *count)
> buf[i] = data;
> DELAY(2);
582a576,577
> *count = len;
>
584c579
< AMDPM_DEBUG(printf("amdpm: READBLK to 0x%x, count=0x%x, cmd=0x%x, error=0x%x", slave, count, cmd, error));
---
> AMDPM_DEBUG(printf("amdpm: READBLK to 0x%x, count=0x%x, cmd=0x%x, error=0x%x", slave, *count, cmd, error));
618a614
> DRIVER_MODULE(smbus, amdpm, smbus_driver, smbus_devclass, 0, 0);
623d618
<