[PATCH v10 3/7] qcom-tgu: Add signal priority support

Konrad Dybcio konrad.dybcio at oss.qualcomm.com
Tue Jan 27 02:30:40 PST 2026


On 1/27/26 3:23 AM, Songwei Chai wrote:
> 
> 
> On 1/13/2026 7:09 PM, Konrad Dybcio wrote:
>> On 1/9/26 3:11 AM, Songwei Chai wrote:
>>> Like circuit of a Logic analyzer, in TGU, the requirement could be
>>> configured in each step and the trigger will be created once the
>>> requirements are met. Add priority functionality here to sort the
>>> signals into different priorities. The signal which is wanted could
>>> be configured in each step's priority node, the larger number means
>>> the higher priority and the signal with higher priority will be sensed
>>> more preferentially.
>>>
>>> Signed-off-by: Songwei Chai <songwei.chai at oss.qualcomm.com>
>>> ---

[...]

>>> +    if (tgu_attr->step_index < drvdata->max_step) {
>>> +        ret = (tgu_attr->reg_num < drvdata->max_reg) ?
>>> +            attr->mode : 0;
>>> +    }
>>> +    return ret;
>>
>> This is very convoluted
>>
>> How about:
>>
>> if (tgu_attr->step_index >= drvdata->max_step)
>>     return 0;
>>
>> if (tgu_attr->reg_num >= drvdata->max_reg)
>>     return 0;
>>
>> return attr->mode;
>>
>> ?
>>
>> [...]
>>
> I agree that the expanded form is clearer step-by-step, but I intentionally kept the current version as it keeps the bounds checks localized and avoids multiple early returns in this simple case.

Multiple early returns are not an anti-pattern to avoid

Konrad



More information about the linux-arm-kernel mailing list