Re: [PATCH 1/7] driver core: Add conditional guard support for device_lock()

From: Dave Jiang

Date: Tue Mar 10 2026 - 14:10:44 EST




On 3/10/26 11:06 AM, Danilo Krummrich wrote:
> On Tue Mar 10, 2026 at 6:45 PM CET, Dave Jiang wrote:
>> On 3/10/26 8:57 AM, Li Ming wrote:
>>> Introduce conditional guard version of device_lock() for scenarios that
>>> require conditional device lock holding.
>>>
>>> Suggested-by: Dan Williams <dan.j.williams@xxxxxxxxx>
>>> Signed-off-by: Li Ming <ming.li@xxxxxxxxxxxx>
>>> ---
>>> include/linux/device.h | 1 +
>>> 1 file changed, 1 insertion(+)
>>>
>>> diff --git a/include/linux/device.h b/include/linux/device.h
>>> index 0be95294b6e6..4fafee80524b 100644
>>> --- a/include/linux/device.h
>>> +++ b/include/linux/device.h
>>> @@ -911,6 +911,7 @@ static inline void device_unlock(struct device *dev)
>>> }
>>>
>>> DEFINE_GUARD(device, struct device *, device_lock(_T), device_unlock(_T))
>>> +DEFINE_GUARD_COND(device, _intr, device_lock_interruptible(_T), _RET == 0)
>>
>> Can you please just squash this small change to the same patch that is using it? Thanks!
>
> Why? It is a single logical change and hence should be a separate patch, no?

For some reason I missed it's in linux/device.h. So sure ok. But typically I would like to see the usage if it's in the same sub-system.

DJ

>
> We even tell contributors in the documentation [1] that adding new APIs and
> using them should be separate patches.
>
> Additionally, in this case it affects another subsystem, so it also makes sense
> in terms of making the change obvious to the maintainers of the other subsystem.
>
> [1] https://docs.kernel.org/process/submitting-patches.html#separate-your-changes