From 66fd61fe1aa7177bdf9de6f27989307e6a73bfbb Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 23 Jul 2026 10:18:45 +0300 Subject: 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 Link: https://patch.msgid.link/20260723071845.568718-1-dmantipov@yandex.ru Signed-off-by: Leon Romanovsky --- drivers/infiniband/hw/ocrdma/ocrdma_stats.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c index 0834416cb3f8..8f26f62f2243 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c @@ -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) -- cgit v1.2.3