[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2024120652-champion-chute-4e74@gregkh>
Date: Fri, 6 Dec 2024 13:59:38 +0100
From: Greg KH <gregkh@...uxfoundation.org>
To: Lee Jones <lee@...nel.org>
Cc: linux-kernel@...r.kernel.org, arnd@...db.de, ojeda@...nel.org,
alex.gaynor@...il.com, boqun.feng@...il.com, gary@...yguo.net,
bjorn3_gh@...tonmail.com, benno.lossin@...ton.me,
a.hindborg@...nel.org, aliceryhl@...gle.com, tmgross@...ch.edu,
rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v5 3/4] sample: rust_misc_device: Demonstrate additional
get/set value functionality
On Fri, Dec 06, 2024 at 12:42:14PM +0000, Lee Jones wrote:
> Expand the complexity of the sample driver by providing the ability to
> get and set an integer. The value is protected by a mutex.
>
> Here is a simple userspace program that fully exercises the sample
> driver's capabilities.
nit, subject line should have "samples" not "sample" :)
> + fn get_value(&self, mut writer: UserSliceWriter) -> Result<isize> {
> + let guard = self.inner.lock();
> + let value = guard.value;
> +
> + // Refrain from calling write() on a locked resource
> + drop(guard);
> +
> + pr_info!("-> Copying data to userspace (value: {})\n", &value);
> +
> + writer.write::<i32>(&value)?;
> + Ok(0)
> + }
I don't understand why you have to drop the mutex before calling
pr_info() and write (i.e. copy_to_user())? It's a mutex, not a
spinlock, so you can hold it over that potentially-sleeping call, right?
Or is there some other reason why here?
thanks,
greg k-h
Powered by blists - more mailing lists