/* read 32 bit values, not 64 bit; for memories that only support 32 bit reads; usually a single dword.  */
static int ipath_read_umem32(struct ipath_devdata *dd, void __user *uaddr, const void __iomem *caddr, size_t count)
/* read 32 bit values, not 64 bit; for memories that only support 32 bit reads; usually a single dword.  */
static int ipath_read_umem32(struct ipath_devdata *dd, void __user *uaddr, const void __iomem *caddr, size_t count)
{
	const u32 __iomem *reg_addr = caddr;
	const u32 __iomem *reg_end = reg_addr + (count / sizeof(u32));
	int ret;
	if (reg_addr < (u32 __iomem *) dd->ipath_kregbase ||
	    reg_end > (u32 __iomem *) dd->ipath_kregend) {
		ret = -EINVAL;
		goto bail;
	}
	while (reg_addr < reg_end) {
		u32 data = readl(reg_addr);
		if (copy_to_user(uaddr, &data, sizeof(data))) {
			ret = -EFAULT;
			goto bail;
		}
		reg_addr++;
		uaddr += sizeof(u32);
	}
	ret = 0;
bail:
	return ret;
}