Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

soc: qcom: llcc: Use guards for mutex handling

Replacing manual lock/unlock pairs with guard() removes the need to
think about unlocking entirely and keeps the function trivially
structured.

Signed-off-by: Unnathi Chalicheemala <unnathi.chalicheemala@oss.qualcomm.com>
Signed-off-by: Francisco Munoz Ruiz <francisco.ruiz@oss.qualcomm.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Link: https://lore.kernel.org/r/20260305-external_llcc_changes1set-v1-2-6347e52e648e@oss.qualcomm.com
Signed-off-by: Bjorn Andersson <andersson@kernel.org>

authored by

Unnathi Chalicheemala and committed by
Bjorn Andersson
eda32f68 45c2a55d

+8 -20
+8 -20
drivers/soc/qcom/llcc-qcom.c
··· 4635 4635 if (IS_ERR_OR_NULL(desc)) 4636 4636 return -EINVAL; 4637 4637 4638 - mutex_lock(&drv_data->lock); 4638 + guard(mutex)(&drv_data->lock); 4639 4639 /* Already active; try to take another reference. */ 4640 - if (refcount_inc_not_zero(&desc->refcount)) { 4641 - mutex_unlock(&drv_data->lock); 4640 + if (refcount_inc_not_zero(&desc->refcount)) 4642 4641 return 0; 4643 - } 4644 4642 4645 4643 act_ctrl_val = ACT_CTRL_OPCODE_ACTIVATE << ACT_CTRL_OPCODE_SHIFT; 4646 - 4647 4644 ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val, 4648 4645 DEACTIVATE); 4649 - if (ret) { 4650 - mutex_unlock(&drv_data->lock); 4646 + if (ret) 4651 4647 return ret; 4652 - } 4653 4648 4654 4649 /* Set first reference */ 4655 4650 refcount_set(&desc->refcount, 1); 4656 - mutex_unlock(&drv_data->lock); 4657 4651 4658 - return ret; 4652 + return 0; 4659 4653 } 4660 4654 EXPORT_SYMBOL_GPL(llcc_slice_activate); 4661 4655 ··· 4671 4677 if (IS_ERR_OR_NULL(desc)) 4672 4678 return -EINVAL; 4673 4679 4674 - mutex_lock(&drv_data->lock); 4680 + guard(mutex)(&drv_data->lock); 4675 4681 /* refcount > 1, drop one ref and we’re done. */ 4676 - if (refcount_dec_not_one(&desc->refcount)) { 4677 - mutex_unlock(&drv_data->lock); 4682 + if (refcount_dec_not_one(&desc->refcount)) 4678 4683 return 0; 4679 - } 4680 4684 4681 4685 act_ctrl_val = ACT_CTRL_OPCODE_DEACTIVATE << ACT_CTRL_OPCODE_SHIFT; 4682 - 4683 4686 ret = llcc_update_act_ctrl(desc->slice_id, act_ctrl_val, 4684 4687 ACTIVATE); 4685 - if (ret) { 4686 - mutex_unlock(&drv_data->lock); 4688 + if (ret) 4687 4689 return ret; 4688 - } 4689 4690 4690 4691 /* Finalize: atomically transition 1 -> 0 */ 4691 4692 WARN_ON_ONCE(!refcount_dec_if_one(&desc->refcount)); 4692 - mutex_unlock(&drv_data->lock); 4693 4693 4694 - return ret; 4694 + return 0; 4695 4695 } 4696 4696 EXPORT_SYMBOL_GPL(llcc_slice_deactivate); 4697 4697