mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 11:21:26 -04:00
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>
This commit is contained in:
committed by
Ilpo Järvinen
parent
1c9d30d37a
commit
a5877e9213
@@ -272,33 +272,27 @@ static int p50_gpio_get(struct gpio_chip *gc, unsigned int offset)
|
||||
struct p50_gpio *p50 = gpiochip_get_data(gc);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&p50->lock);
|
||||
guard(mutex)(&p50->lock);
|
||||
|
||||
ret = p50_send_mbox_cmd(p50, P50_MBOX_CMD_READ_GPIO, gpio_params[offset], 0);
|
||||
if (ret == 0) {
|
||||
ret = p50_read_mbox_reg(p50, P50_MBOX_REG_DATA);
|
||||
if (ret >= 0)
|
||||
ret = !!ret;
|
||||
}
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
mutex_unlock(&p50->lock);
|
||||
ret = p50_read_mbox_reg(p50, P50_MBOX_REG_DATA);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return ret;
|
||||
return !!ret;
|
||||
}
|
||||
|
||||
static int p50_gpio_set(struct gpio_chip *gc, unsigned int offset, int value)
|
||||
{
|
||||
struct p50_gpio *p50 = gpiochip_get_data(gc);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&p50->lock);
|
||||
guard(mutex)(&p50->lock);
|
||||
|
||||
ret = p50_send_mbox_cmd(p50, P50_MBOX_CMD_WRITE_GPIO,
|
||||
gpio_params[offset], value);
|
||||
|
||||
mutex_unlock(&p50->lock);
|
||||
|
||||
return ret;
|
||||
return p50_send_mbox_cmd(p50, P50_MBOX_CMD_WRITE_GPIO,
|
||||
gpio_params[offset], value);
|
||||
}
|
||||
|
||||
static int p50_gpio_probe(struct platform_device *pdev)
|
||||
|
||||
Reference in New Issue
Block a user