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.

Input: ad714x - use guard notation when acquiring mutex

Using guard notation makes the code more compact and error handling
more robust by ensuring that mutexes are released in all code paths
when control leaves critical section.

Reviewed-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
Link: https://lore.kernel.org/r/20240904044244.1042174-2-dmitry.torokhov@gmail.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+3 -9
+3 -9
drivers/input/misc/ad714x.c
··· 941 941 struct ad714x_chip *ad714x = data; 942 942 int i; 943 943 944 - mutex_lock(&ad714x->mutex); 944 + guard(mutex)(&ad714x->mutex); 945 945 946 946 ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3); 947 947 ··· 953 953 ad714x_wheel_state_machine(ad714x, i); 954 954 for (i = 0; i < ad714x->hw->touchpad_num; i++) 955 955 ad714x_touchpad_state_machine(ad714x, i); 956 - 957 - mutex_unlock(&ad714x->mutex); 958 956 959 957 return IRQ_HANDLED; 960 958 } ··· 1167 1169 1168 1170 dev_dbg(ad714x->dev, "%s enter\n", __func__); 1169 1171 1170 - mutex_lock(&ad714x->mutex); 1172 + guard(mutex)(&ad714x->mutex); 1171 1173 1172 1174 data = ad714x->hw->sys_cfg_reg[AD714X_PWR_CTRL] | 0x3; 1173 1175 ad714x->write(ad714x, AD714X_PWR_CTRL, data); 1174 - 1175 - mutex_unlock(&ad714x->mutex); 1176 1176 1177 1177 return 0; 1178 1178 } ··· 1180 1184 struct ad714x_chip *ad714x = dev_get_drvdata(dev); 1181 1185 dev_dbg(ad714x->dev, "%s enter\n", __func__); 1182 1186 1183 - mutex_lock(&ad714x->mutex); 1187 + guard(mutex)(&ad714x->mutex); 1184 1188 1185 1189 /* resume to non-shutdown mode */ 1186 1190 ··· 1192 1196 */ 1193 1197 1194 1198 ad714x->read(ad714x, STG_LOW_INT_STA_REG, &ad714x->l_state, 3); 1195 - 1196 - mutex_unlock(&ad714x->mutex); 1197 1199 1198 1200 return 0; 1199 1201 }