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

Guard notation simplifies code.

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

+16 -16
+16 -16
drivers/input/touchscreen/elo.c
··· 219 219 220 220 static int elo_command_10(struct elo *elo, unsigned char *packet) 221 221 { 222 - int rc = -1; 222 + int error; 223 223 int i; 224 224 unsigned char csum = 0xaa + ELO10_LEAD_BYTE; 225 225 226 - mutex_lock(&elo->cmd_mutex); 226 + guard(mutex)(&elo->cmd_mutex); 227 227 228 228 scoped_guard(serio_pause_rx, elo->serio) { 229 229 elo->expected_packet = toupper(packet[0]); 230 230 init_completion(&elo->cmd_done); 231 231 } 232 232 233 - if (serio_write(elo->serio, ELO10_LEAD_BYTE)) 234 - goto out; 233 + error = serio_write(elo->serio, ELO10_LEAD_BYTE); 234 + if (error) 235 + return error; 235 236 236 237 for (i = 0; i < ELO10_PACKET_LEN; i++) { 237 238 csum += packet[i]; 238 - if (serio_write(elo->serio, packet[i])) 239 - goto out; 239 + error = serio_write(elo->serio, packet[i]); 240 + if (error) 241 + return error; 240 242 } 241 243 242 - if (serio_write(elo->serio, csum)) 243 - goto out; 244 + error = serio_write(elo->serio, csum); 245 + if (error) 246 + return error; 244 247 245 248 wait_for_completion_timeout(&elo->cmd_done, HZ); 246 249 247 - if (elo->expected_packet == ELO10_TOUCH_PACKET) { 248 - /* We are back in reporting mode, the command was ACKed */ 249 - memcpy(packet, elo->response, ELO10_PACKET_LEN); 250 - rc = 0; 251 - } 250 + if (elo->expected_packet != ELO10_TOUCH_PACKET) 251 + return -EIO; 252 252 253 - out: 254 - mutex_unlock(&elo->cmd_mutex); 255 - return rc; 253 + /* We are back in reporting mode, the command was ACKed */ 254 + memcpy(packet, elo->response, ELO10_PACKET_LEN); 255 + return 0; 256 256 } 257 257 258 258 static int elo_setup_10(struct elo *elo)