Re: [PATCH 2/2] drm: zynqmp_dp: Use scope-based mutex helpers

From: Sean Anderson
Date: Thu Feb 06 2025 - 15:38:05 EST


On 2/6/25 15:31, Bart Van Assche wrote:
> On 2/6/25 11:41 AM, Sean Anderson wrote:
>> static int zynqmp_dp_enhanced_set(void *data, u64 val)
>> {
>> struct zynqmp_dp *dp = data;
>> - int ret = 0;
>> - mutex_lock(&dp->lock);
>> + guard(mutex)(&dp->lock);
>> dp->test.enhanced = val;
>> if (dp->test.active)
>> - ret = zynqmp_dp_test_setup(dp);
>> - mutex_unlock(&dp->lock);
>> + return zynqmp_dp_test_setup(dp);
>> - return ret;
>> + return 0;
>> }
>
> Has it been considered to combine the two return statements into one
> with the ternary operator (?:)?

I didn't consider it, but the line is short enough that I can add it.

>> @@ -2053,7 +2039,8 @@ static ssize_t zynqmp_dp_custom_read(struct file *file, char __user *user_buf,
>> return ret;
>> mutex_lock(&dp->lock);
>> - ret = simple_read_from_buffer(user_buf, count, ppos, &dp->test.custom,
>> + ret = simple_read_from_buffer(user_buf, count, ppos,
>> + &dp->test.custom,
>> sizeof(dp->test.custom));
>
> This change has not been mentioned in the patch description and is not
> related to the other changes in this patch?

I think I made this change while refactoring, but it turned out not to
be necessary. I will remove it for the next revision.

--Sean