Skip to content

Commit

Permalink
scsi: csiostor: Convert sysfs snprintf() to sysfs_emit()
Browse files Browse the repository at this point in the history
Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the value
to be returned to user space.

Link: https://lore.kernel.org/r/20220901015130.419307-1-zhangxuezhi3@gmail.com
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Xuezhi Zhang <zhangxuezhi1@coolpad.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
  • Loading branch information
Xuezhi Zhang authored and Martin K. Petersen committed Sep 16, 2022
1 parent 68a97fe commit 9acb9f0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/scsi/csiostor/csio_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1366,9 +1366,9 @@ csio_show_hw_state(struct device *dev,
struct csio_hw *hw = csio_lnode_to_hw(ln);

if (csio_is_hw_ready(hw))
return snprintf(buf, PAGE_SIZE, "ready\n");
else
return snprintf(buf, PAGE_SIZE, "not ready\n");
return sysfs_emit(buf, "ready\n");

return sysfs_emit(buf, "not ready\n");
}

/* Device reset */
Expand Down Expand Up @@ -1430,7 +1430,7 @@ csio_show_dbg_level(struct device *dev,
{
struct csio_lnode *ln = shost_priv(class_to_shost(dev));

return snprintf(buf, PAGE_SIZE, "%x\n", ln->params.log_level);
return sysfs_emit(buf, "%x\n", ln->params.log_level);
}

/* Store debug level */
Expand Down Expand Up @@ -1476,7 +1476,7 @@ csio_show_num_reg_rnodes(struct device *dev,
{
struct csio_lnode *ln = shost_priv(class_to_shost(dev));

return snprintf(buf, PAGE_SIZE, "%d\n", ln->num_reg_rnodes);
return sysfs_emit(buf, "%d\n", ln->num_reg_rnodes);
}

static DEVICE_ATTR(num_reg_rnodes, S_IRUGO, csio_show_num_reg_rnodes, NULL);
Expand Down

0 comments on commit 9acb9f0

Please sign in to comment.