Re: [PATCH] workqueue: Introduce from_wq() helper for cleaner callback declarations

From: Tejun Heo
Date: Tue Feb 27 2024 - 14:01:37 EST


On Tue, Feb 27, 2024 at 06:56:28PM +0000, Allen Pais wrote:
> To streamline the transition from tasklets to worqueues, a new helper
> function, from_wq(), is introduced. This helper, inspired by existing
> from_() patterns, utilizes container_of() and eliminates the redundancy
> of declaring variable types, leading to more concise and readable code.
>
> The modified code snippet demonstrates the enhanced clarity achieved
> with from_wq():
>
> void callback(struct work_struct *w)
> {
> - struct some_data_structure *local = container_of(w,
> struct some_data_structure,
> work);
> + struct some_data_structure *local = from_wq(local, w, work);

I'm not necessarily against it but it's a bit meh in terms of how much it
saves. Also, can you please name it from_work()?

Thanks.

--
tejun