RDMA/ocrdma: accept boolean value in ocrdma_dbgfs_ops_write()

Since reset is actually controlled by the boolean flag rather than
long, switch to 'kstrtobool_from_user()' and use the latter for an
overall simplification of 'ocrdma_dbgfs_ops_write()'.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Link: https://patch.msgid.link/20260723071845.568718-1-dmantipov@yandex.ru
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
Dmitry Antipov 2026-07-23 10:18:45 +03:00 committed by Leon Romanovsky
parent 7ddcd75596
commit 66fd61fe1a

View File

@ -635,39 +635,29 @@ static ssize_t ocrdma_dbgfs_ops_write(struct file *filp,
const char __user *buffer,
size_t count, loff_t *ppos)
{
char tmp_str[32];
long reset;
bool reset;
int status;
struct ocrdma_stats *pstats = filp->private_data;
struct ocrdma_dev *dev = pstats->dev;
if (*ppos != 0 || count == 0 || count > sizeof(tmp_str))
goto err;
if (copy_from_user(tmp_str, buffer, count))
goto err;
tmp_str[count-1] = '\0';
if (kstrtol(tmp_str, 10, &reset))
goto err;
status = kstrtobool_from_user(buffer, count, &reset);
if (status)
return status;
switch (pstats->type) {
case OCRDMA_RESET_STATS:
if (reset) {
status = ocrdma_mbx_rdma_stats(dev, true);
if (status) {
if (status)
pr_err("Failed to reset stats = %d\n", status);
goto err;
}
}
break;
default:
goto err;
status = -EINVAL;
break;
}
return count;
err:
return -EFAULT;
return status ? status : count;
}
void ocrdma_pma_counters(struct ocrdma_dev *dev, struct ib_mad *out_mad)