/* An auxilary service that performs a read or write access  */
static ssize_t envm_read_or_write(int do_read, struct file *filp, char *buffer, size_t length, loff_t *offset)
/* An auxilary service that performs a read or write access  */
static ssize_t envm_read_or_write(int do_read, struct file *filp, char *buffer, size_t length, loff_t *offset)
{
	unsigned int size;
	unsigned int len = 0;
	unsigned int addr = 0;
	int ret = 0;
	if (! access_ok(0, buffer, length)) {
		ret = -EINVAL;
		goto Done;
	}
	addr = envm_base + *offset;
	size = mss_envm_size();
	if (addr >= size) {
		ret = 0;
		goto Done;
	}
	len = addr + length < size ? length : size - addr;
	ret = do_read ? mss_envm_read(addr, buffer, len) :
			mss_envm_write(addr, buffer, len);
	*offset += ret;
Done:
	d_printk(3, "do_r=%d,off=%x,addr=%x,len=%d,l=%d,ret=%d\n",
		 do_read, (uint) *offset, addr, length, len, ret);
	return ret;
}