Skip to content

Commit 52d4639

Browse files
Shrikanth Hegdemaddy-kerneldev
authored andcommitted
powerpc: sysdev: use lock guard for mutex
use guard(mutex) for scope based resource management of mutex This would make the code simpler and easier to maintain. More details on lock guards can be found at https://lore.kernel.org/all/[email protected]/T/#u Reviewed-by: Srikar Dronamraju <[email protected]> Signed-off-by: Shrikanth Hegde <[email protected]> Tested-by: Venkat Rao Bagalkote <[email protected]> Signed-off-by: Madhavan Srinivasan <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 8ea7819 commit 52d4639

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,39 +75,31 @@ static ssize_t fsl_timer_wakeup_store(struct device *dev,
7575
if (kstrtoll(buf, 0, &interval))
7676
return -EINVAL;
7777

78-
mutex_lock(&sysfs_lock);
78+
guard(mutex)(&sysfs_lock);
7979

8080
if (fsl_wakeup->timer) {
8181
disable_irq_wake(fsl_wakeup->timer->irq);
8282
mpic_free_timer(fsl_wakeup->timer);
8383
fsl_wakeup->timer = NULL;
8484
}
8585

86-
if (!interval) {
87-
mutex_unlock(&sysfs_lock);
86+
if (!interval)
8887
return count;
89-
}
9088

9189
fsl_wakeup->timer = mpic_request_timer(fsl_mpic_timer_irq,
9290
fsl_wakeup, interval);
93-
if (!fsl_wakeup->timer) {
94-
mutex_unlock(&sysfs_lock);
91+
if (!fsl_wakeup->timer)
9592
return -EINVAL;
96-
}
9793

9894
ret = enable_irq_wake(fsl_wakeup->timer->irq);
9995
if (ret) {
10096
mpic_free_timer(fsl_wakeup->timer);
10197
fsl_wakeup->timer = NULL;
102-
mutex_unlock(&sysfs_lock);
103-
10498
return ret;
10599
}
106100

107101
mpic_start_timer(fsl_wakeup->timer);
108102

109-
mutex_unlock(&sysfs_lock);
110-
111103
return count;
112104
}
113105

0 commit comments

Comments
 (0)