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: exc3000 - use guard notation when acquiring mutex

Guard notation simplifies code.

Note that callers of exc3000_vendor_data_request() always expect
response, so it was adjusted to always wait for it.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

+10 -21
+10 -21
drivers/input/touchscreen/exc3000.c
··· 234 234 int ret; 235 235 unsigned long time_left; 236 236 237 - mutex_lock(&data->query_lock); 237 + guard(mutex)(&data->query_lock); 238 238 239 239 reinit_completion(&data->wait_event); 240 240 ··· 243 243 244 244 ret = i2c_master_send(data->client, buf, EXC3000_LEN_VENDOR_REQUEST); 245 245 if (ret < 0) 246 - goto out_unlock; 246 + return ret; 247 247 248 - if (response) { 249 - time_left = wait_for_completion_timeout(&data->wait_event, 250 - timeout * HZ); 251 - if (time_left == 0) { 252 - ret = -ETIMEDOUT; 253 - goto out_unlock; 254 - } 248 + time_left = wait_for_completion_timeout(&data->wait_event, 249 + timeout * HZ); 250 + if (time_left == 0) 251 + return -ETIMEDOUT; 255 252 256 - if (data->buf[3] >= EXC3000_LEN_FRAME) { 257 - ret = -ENOSPC; 258 - goto out_unlock; 259 - } 253 + if (data->buf[3] >= EXC3000_LEN_FRAME) 254 + return -ENOSPC; 260 255 261 - memcpy(response, &data->buf[4], data->buf[3]); 262 - ret = data->buf[3]; 263 - } 264 - 265 - out_unlock: 266 - mutex_unlock(&data->query_lock); 267 - 268 - return ret; 256 + memcpy(response, &data->buf[4], data->buf[3]); 257 + return data->buf[3]; 269 258 } 270 259 271 260 static ssize_t fw_version_show(struct device *dev,