diff options
author | np <np@FreeBSD.org> | 2011-04-07 07:10:42 +0000 |
---|---|---|
committer | np <np@FreeBSD.org> | 2011-04-07 07:10:42 +0000 |
commit | d75443ce48c023f5f7cfe7a041b1a232d0a5b7d7 (patch) | |
tree | 6c79e9758c7b5a407b3ce36d37787b429f5366d7 /sys/dev/cxgbe/t4_main.c | |
parent | 86570b7a275827958aba5c40a70c7f5fcb697393 (diff) | |
download | FreeBSD-src-d75443ce48c023f5f7cfe7a041b1a232d0a5b7d7.zip FreeBSD-src-d75443ce48c023f5f7cfe7a041b1a232d0a5b7d7.tar.gz |
Modify read/write ioctls to work with 64 bit registers too.
MFC after: 3 days
Diffstat (limited to 'sys/dev/cxgbe/t4_main.c')
-rw-r--r-- | sys/dev/cxgbe/t4_main.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c index 3baaf0c..43bf779 100644 --- a/sys/dev/cxgbe/t4_main.c +++ b/sys/dev/cxgbe/t4_main.c @@ -2803,18 +2803,35 @@ t4_ioctl(struct cdev *dev, unsigned long cmd, caddr_t data, int fflag, return (rc); switch (cmd) { - case CHELSIO_T4_GETREG32: { - struct t4_reg32 *edata = (struct t4_reg32 *)data; + case CHELSIO_T4_GETREG: { + struct t4_reg *edata = (struct t4_reg *)data; + if ((edata->addr & 0x3) != 0 || edata->addr >= sc->mmio_len) return (EFAULT); - edata->val = t4_read_reg(sc, edata->addr); + + if (edata->size == 4) + edata->val = t4_read_reg(sc, edata->addr); + else if (edata->size == 8) + edata->val = t4_read_reg64(sc, edata->addr); + else + return (EINVAL); + break; } - case CHELSIO_T4_SETREG32: { - struct t4_reg32 *edata = (struct t4_reg32 *)data; + case CHELSIO_T4_SETREG: { + struct t4_reg *edata = (struct t4_reg *)data; + if ((edata->addr & 0x3) != 0 || edata->addr >= sc->mmio_len) return (EFAULT); - t4_write_reg(sc, edata->addr, edata->val); + + if (edata->size == 4) { + if (edata->val & 0xffffffff00000000) + return (EINVAL); + t4_write_reg(sc, edata->addr, (uint32_t) edata->val); + } else if (edata->size == 8) + t4_write_reg64(sc, edata->addr, edata->val); + else + return (EINVAL); break; } case CHELSIO_T4_REGDUMP: { |