iommu/vt-d: Use kstrtoint_from_user() in dmar_perf_latency_write()

Simplify 'dmar_perf_latency_write()' by using the convenient
'kstrtoint_from_user()'.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
This commit is contained in:
Dmitry Antipov 2026-08-05 07:42:58 +08:00 committed by Joerg Roedel
parent 3846e469c1
commit 1251ade0e3

View File

@ -690,19 +690,11 @@ static ssize_t dmar_perf_latency_write(struct file *filp,
{
struct dmar_drhd_unit *drhd;
struct intel_iommu *iommu;
int counting;
char buf[64];
int ret, counting;
if (cnt > 63)
cnt = 63;
if (copy_from_user(&buf, ubuf, cnt))
return -EFAULT;
buf[cnt] = 0;
if (kstrtoint(buf, 0, &counting))
return -EINVAL;
ret = kstrtoint_from_user(ubuf, cnt, 0, &counting);
if (ret)
return ret;
switch (counting) {
case 0: