From owner-freebsd-drivers@freebsd.org Mon May 8 20:37:22 2017 Return-Path: Delivered-To: freebsd-drivers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 06198D6312C for ; Mon, 8 May 2017 20:37:22 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CF63118AA for ; Mon, 8 May 2017 20:37:21 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id E5A9E10A7DB; Mon, 8 May 2017 16:37:20 -0400 (EDT) From: John Baldwin To: freebsd-drivers@freebsd.org Subject: Re: uiomove question Date: Mon, 08 May 2017 13:35:42 -0700 Message-ID: <1616964.AnLvBdJceo@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-STABLE; KDE/4.14.10; amd64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Mon, 08 May 2017 16:37:21 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 May 2017 20:37:22 -0000 On Saturday, March 11, 2017 02:03:06 PM Anindya Mukherjee wrote: > An example of the usage I am talking about: > > xxx_write(...) > { > ... > amount = MIN(uio->uio_resid, // 0. This is the no of bytes in the uio left to write > (BUFFER_SIZE - 1 - uio->uio_offset > 0) ? > BUFFER_SIZE - 1 - uio->uio_offset : 0); // 1. amount to write is computed > //assuming write will happen at uio_offset in sc_buffer > if (amount == 0) > return (error); > error = uiomove(sc->sc_buffer, amount, uio); // 2. sc_buffer is not offset > ... > } > > xxx_read(...) > { > ... > amount = MIN(uio->uio_resid, > (sc->sc_length - uio->uio_offset > 0) ? > sc->sc_length - uio->uio_offset : 0); // 3. Same as comment 1 above > error = uiomove(sc->sc_buffer + uio->uio_offset, amount, uio); // 4. Here buffer is offset > ... > } > > Anindya Yes, I think your point is correct. -- John Baldwin