On Wed, 8 May 2019 09:25:57 -0400 Eric Farman <farman@xxxxxxxxxxxxx> wrote: > On 5/8/19 6:43 AM, Cornelia Huck wrote: > > On Fri, 3 May 2019 15:49:08 +0200 > > Eric Farman <farman@xxxxxxxxxxxxx> wrote: > >> +/* > >> + * pfn_array_pin() - Pin user pages in memory > >> + * @pa: pfn_array on which to perform the operation > >> + * @mdev: the mediated device to perform pin operations > >> + * > >> + * Returns: > >> + * Number of pages pinned on success. > >> + * If fewer pages than requested were pinned, returns -EINVAL > >> + * If no pages were pinned, returns -errno. > > > > I don't really like the 'returns -errno' :) It's actually the return > > code of vfio_pin_pages(), and that might include -EINVAL as well. > > > > So, what about mentioning in the function description that > > pfn_array_pin() only succeeds if it coult pin all pages, and simply > > stating that it returns a negative error value on failure? > > Seems reasonable to me... Something like: > > * Returns number of pages pinned upon success. > * If the pin request partially succeeds, or fails completely, > * all pages are left unpinned and a negative error value is returned. Sounds good to me!