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: eeti_ts - use guard notation when acquiring mutexes

This makes the code more compact and error handling more robust.

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

+10 -17
+10 -17
drivers/input/touchscreen/eeti_ts.c
··· 89 89 struct eeti_ts *eeti = dev_id; 90 90 int error; 91 91 92 - mutex_lock(&eeti->mutex); 92 + guard(mutex)(&eeti->mutex); 93 93 94 94 do { 95 95 /* ··· 109 109 110 110 } while (eeti->running && eeti->attn_gpio); 111 111 112 - mutex_unlock(&eeti->mutex); 113 112 return IRQ_HANDLED; 114 113 } 115 114 116 115 static void eeti_ts_start(struct eeti_ts *eeti) 117 116 { 118 - mutex_lock(&eeti->mutex); 117 + guard(mutex)(&eeti->mutex); 119 118 120 119 eeti->running = true; 121 120 enable_irq(eeti->client->irq); ··· 126 127 */ 127 128 if (eeti->attn_gpio && gpiod_get_value_cansleep(eeti->attn_gpio)) 128 129 eeti_ts_read(eeti); 129 - 130 - mutex_unlock(&eeti->mutex); 131 130 } 132 131 133 132 static void eeti_ts_stop(struct eeti_ts *eeti) ··· 235 238 struct eeti_ts *eeti = i2c_get_clientdata(client); 236 239 struct input_dev *input_dev = eeti->input; 237 240 238 - mutex_lock(&input_dev->mutex); 239 - 240 - if (input_device_enabled(input_dev)) 241 - eeti_ts_stop(eeti); 242 - 243 - mutex_unlock(&input_dev->mutex); 241 + scoped_guard(mutex, &input_dev->mutex) { 242 + if (input_device_enabled(input_dev)) 243 + eeti_ts_stop(eeti); 244 + } 244 245 245 246 if (device_may_wakeup(&client->dev)) 246 247 enable_irq_wake(client->irq); ··· 255 260 if (device_may_wakeup(&client->dev)) 256 261 disable_irq_wake(client->irq); 257 262 258 - mutex_lock(&input_dev->mutex); 259 - 260 - if (input_device_enabled(input_dev)) 261 - eeti_ts_start(eeti); 262 - 263 - mutex_unlock(&input_dev->mutex); 263 + scoped_guard(mutex, &input_dev->mutex) { 264 + if (input_device_enabled(input_dev)) 265 + eeti_ts_start(eeti); 266 + } 264 267 265 268 return 0; 266 269 }