Skip to content

Commit 228fe71

Browse files
raagjadavandy-shev
authored andcommitted
pinctrl: tangier: simplify locking using cleanup helpers
Use lock guards from cleanup.h to simplify locking. Signed-off-by: Raag Jadav <[email protected]> Acked-by: Mika Westerberg <[email protected]> Signed-off-by: Andy Shevchenko <[email protected]>
1 parent e58e519 commit 228fe71

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

drivers/pinctrl/intel/pinctrl-tangier.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*/
1010

1111
#include <linux/bits.h>
12+
#include <linux/cleanup.h>
1213
#include <linux/device.h>
1314
#include <linux/err.h>
1415
#include <linux/errno.h>
@@ -220,7 +221,6 @@ static int tng_pinmux_set_mux(struct pinctrl_dev *pctldev,
220221
const struct intel_pingroup *grp = &tp->groups[group];
221222
u32 bits = grp->mode << BUFCFG_PINMODE_SHIFT;
222223
u32 mask = BUFCFG_PINMODE_MASK;
223-
unsigned long flags;
224224
unsigned int i;
225225

226226
/*
@@ -232,11 +232,11 @@ static int tng_pinmux_set_mux(struct pinctrl_dev *pctldev,
232232
return -EBUSY;
233233
}
234234

235+
guard(raw_spinlock_irqsave)(&tp->lock);
236+
235237
/* Now enable the mux setting for each pin in the group */
236-
raw_spin_lock_irqsave(&tp->lock, flags);
237238
for (i = 0; i < grp->grp.npins; i++)
238239
tng_update_bufcfg(tp, grp->grp.pins[i], bits, mask);
239-
raw_spin_unlock_irqrestore(&tp->lock, flags);
240240

241241
return 0;
242242
}
@@ -248,14 +248,13 @@ static int tng_gpio_request_enable(struct pinctrl_dev *pctldev,
248248
struct tng_pinctrl *tp = pinctrl_dev_get_drvdata(pctldev);
249249
u32 bits = BUFCFG_PINMODE_GPIO << BUFCFG_PINMODE_SHIFT;
250250
u32 mask = BUFCFG_PINMODE_MASK;
251-
unsigned long flags;
252251

253252
if (!tng_buf_available(tp, pin))
254253
return -EBUSY;
255254

256-
raw_spin_lock_irqsave(&tp->lock, flags);
255+
guard(raw_spinlock_irqsave)(&tp->lock);
256+
257257
tng_update_bufcfg(tp, pin, bits, mask);
258-
raw_spin_unlock_irqrestore(&tp->lock, flags);
259258

260259
return 0;
261260
}
@@ -360,7 +359,6 @@ static int tng_config_set_pin(struct tng_pinctrl *tp, unsigned int pin,
360359
unsigned int param = pinconf_to_config_param(config);
361360
unsigned int arg = pinconf_to_config_argument(config);
362361
u32 mask, term, value = 0;
363-
unsigned long flags;
364362

365363
switch (param) {
366364
case PIN_CONFIG_BIAS_DISABLE:
@@ -432,9 +430,9 @@ static int tng_config_set_pin(struct tng_pinctrl *tp, unsigned int pin,
432430
return -EINVAL;
433431
}
434432

435-
raw_spin_lock_irqsave(&tp->lock, flags);
433+
guard(raw_spinlock_irqsave)(&tp->lock);
434+
436435
tng_update_bufcfg(tp, pin, value, mask);
437-
raw_spin_unlock_irqrestore(&tp->lock, flags);
438436

439437
return 0;
440438
}

0 commit comments

Comments
 (0)