Convert the explicit mutex_lock/mutex_unlock pair in mem_write() into
a cleanup.h guard(mutex)() scope-based lock acquisition. This removes
the remaining goto-based cleanup path and keeps the lock held until
the end of the mem_write() scope.
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: ZhaoJinming <zhaojinming@uniontech.com>
Link: https://patch.msgid.link/20260521130848.2860219-2-zhaojinming@uniontech.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
if (addr >= size)
return -EINVAL;
- mutex_lock(&tpmi_dev_lock);
+ guard(mutex)(&tpmi_dev_lock);
mem = ioremap(pfs->vsec_offset + punit * size, size);
- if (!mem) {
- ret = -ENOMEM;
- goto unlock_mem_write;
- }
+ if (!mem)
+ return -ENOMEM;
writel(value, mem + addr);
iounmap(mem);
- ret = len;
-
-unlock_mem_write:
- mutex_unlock(&tpmi_dev_lock);
-
- return ret;
+ return len;
}
static int mem_write_show(struct seq_file *s, void *unused)