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.

platform/x86: barco-p50-gpio: convert to guard() notation

Using guard notation simplifies control flow and makes the code clearer.

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Link: https://patch.msgid.link/20260318-barco-p50-gpio-set-v2-2-c0a4a6416163@gmail.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Dmitry Torokhov and committed by
Ilpo Järvinen
a5877e92 1c9d30d3

+10 -16
+10 -16
drivers/platform/x86/barco-p50-gpio.c
··· 272 272 struct p50_gpio *p50 = gpiochip_get_data(gc); 273 273 int ret; 274 274 275 - mutex_lock(&p50->lock); 275 + guard(mutex)(&p50->lock); 276 276 277 277 ret = p50_send_mbox_cmd(p50, P50_MBOX_CMD_READ_GPIO, gpio_params[offset], 0); 278 - if (ret == 0) { 279 - ret = p50_read_mbox_reg(p50, P50_MBOX_REG_DATA); 280 - if (ret >= 0) 281 - ret = !!ret; 282 - } 278 + if (ret < 0) 279 + return ret; 283 280 284 - mutex_unlock(&p50->lock); 281 + ret = p50_read_mbox_reg(p50, P50_MBOX_REG_DATA); 282 + if (ret < 0) 283 + return ret; 285 284 286 - return ret; 285 + return !!ret; 287 286 } 288 287 289 288 static int p50_gpio_set(struct gpio_chip *gc, unsigned int offset, int value) 290 289 { 291 290 struct p50_gpio *p50 = gpiochip_get_data(gc); 292 - int ret; 293 291 294 - mutex_lock(&p50->lock); 292 + guard(mutex)(&p50->lock); 295 293 296 - ret = p50_send_mbox_cmd(p50, P50_MBOX_CMD_WRITE_GPIO, 297 - gpio_params[offset], value); 298 - 299 - mutex_unlock(&p50->lock); 300 - 301 - return ret; 294 + return p50_send_mbox_cmd(p50, P50_MBOX_CMD_WRITE_GPIO, 295 + gpio_params[offset], value); 302 296 } 303 297 304 298 static int p50_gpio_probe(struct platform_device *pdev)