Commit ffa63647 authored by Zhen Lei's avatar Zhen Lei Committed by Martin K. Petersen
Browse files

scsi: qedi: Use DEVICE_ATTR_RO() macro

Use DEVICE_ATTR_RO() macro helper instead of plain DEVICE_ATTR(), which
makes the code a bit shorter and easier to read.

Link: https://lore.kernel.org/r/20210616034419.725-2-thunder.leizhen@huawei.com


Acked-by: default avatarManish Rangankar <mrangankar@marvell.com>
Signed-off-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 1897c5c7
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ static inline struct qedi_ctx *qedi_dev_to_hba(struct device *dev)
	return iscsi_host_priv(shost);
}

static ssize_t qedi_show_port_state(struct device *dev,
static ssize_t port_state_show(struct device *dev,
			       struct device_attribute *attr,
			       char *buf)
{
@@ -28,7 +28,7 @@ static ssize_t qedi_show_port_state(struct device *dev,
		return sprintf(buf, "Linkdown\n");
}

static ssize_t qedi_show_speed(struct device *dev,
static ssize_t speed_show(struct device *dev,
			  struct device_attribute *attr, char *buf)
{
	struct qedi_ctx *qedi = qedi_dev_to_hba(dev);
@@ -39,8 +39,8 @@ static ssize_t qedi_show_speed(struct device *dev,
	return sprintf(buf, "%d Gbit\n", if_link.speed / 1000);
}

static DEVICE_ATTR(port_state, 0444, qedi_show_port_state, NULL);
static DEVICE_ATTR(speed, 0444, qedi_show_speed, NULL);
static DEVICE_ATTR_RO(port_state);
static DEVICE_ATTR_RO(speed);

struct device_attribute *qedi_shost_attrs[] = {
	&dev_attr_port_state,