diff mbox series

[v2,1/4] scsi: qedi: use DEVICE_ATTR_RO macro

Message ID 20210616034419.725-2-thunder.leizhen@huawei.com
State New
Headers show
Series scsi: use DEVICE_ATTR_*() macros to simplify code | expand

Commit Message

Leizhen (ThunderTown) June 16, 2021, 3:44 a.m. UTC
Use DEVICE_ATTR_RO macro helper instead of plain DEVICE_ATTR, which makes
the code a bit shorter and easier to read.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

---
 drivers/scsi/qedi/qedi_sysfs.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.26.0.106.g9fadedd

Comments

Manish Rangankar June 22, 2021, 6:40 a.m. UTC | #1
> -----Original Message-----

> From: Zhen Lei <thunder.leizhen@huawei.com>

> Sent: Wednesday, June 16, 2021 9:14 AM

> To: Nilesh Javali <njavali@marvell.com>; Manish Rangankar

> <mrangankar@marvell.com>; Saurav Kashyap <skashyap@marvell.com>; Javed

> Hasan <jhasan@marvell.com>; Kashyap Desai

> <kashyap.desai@broadcom.com>; Sumit Saxena

> <sumit.saxena@broadcom.com>; Shivasharan S

> <shivasharan.srikanteshwara@broadcom.com>; GR-QLogic-Storage-Upstream

> <GR-QLogic-Storage-Upstream@marvell.com>; megaraidlinux . pdl

> <megaraidlinux.pdl@broadcom.com>; James E . J . Bottomley

> <jejb@linux.ibm.com>; Martin K . Petersen <martin.petersen@oracle.com>;

> linux-scsi <linux-scsi@vger.kernel.org>

> Cc: Zhen Lei <thunder.leizhen@huawei.com>

> Subject: [PATCH v2 1/4] 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.

> 

> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>

> ---

>  drivers/scsi/qedi/qedi_sysfs.c | 14 +++++++-------

>  1 file changed, 7 insertions(+), 7 deletions(-)

> 

> diff --git a/drivers/scsi/qedi/qedi_sysfs.c b/drivers/scsi/qedi/qedi_sysfs.c index

> 04ee68e6499c912..be174d30eb7c275 100644

> --- a/drivers/scsi/qedi/qedi_sysfs.c

> +++ b/drivers/scsi/qedi/qedi_sysfs.c

> @@ -16,9 +16,9 @@ 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,

> -				    struct device_attribute *attr,

> -				    char *buf)

> +static ssize_t port_state_show(struct device *dev,

> +			       struct device_attribute *attr,

> +			       char *buf)

>  {

>  	struct qedi_ctx *qedi = qedi_dev_to_hba(dev);

> 

> @@ -28,8 +28,8 @@ static ssize_t qedi_show_port_state(struct device *dev,

>  		return sprintf(buf, "Linkdown\n");

>  }

> 

> -static ssize_t qedi_show_speed(struct device *dev,

> -			       struct device_attribute *attr, char *buf)

> +static ssize_t speed_show(struct device *dev,

> +			  struct device_attribute *attr, char *buf)

>  {

>  	struct qedi_ctx *qedi = qedi_dev_to_hba(dev);

>  	struct qed_link_output if_link;

> @@ -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,

> --


Thanks,
Acked-by: Manish Rangankar <mrangankar@marvell.com>
diff mbox series

Patch

diff --git a/drivers/scsi/qedi/qedi_sysfs.c b/drivers/scsi/qedi/qedi_sysfs.c
index 04ee68e6499c912..be174d30eb7c275 100644
--- a/drivers/scsi/qedi/qedi_sysfs.c
+++ b/drivers/scsi/qedi/qedi_sysfs.c
@@ -16,9 +16,9 @@  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,
-				    struct device_attribute *attr,
-				    char *buf)
+static ssize_t port_state_show(struct device *dev,
+			       struct device_attribute *attr,
+			       char *buf)
 {
 	struct qedi_ctx *qedi = qedi_dev_to_hba(dev);
 
@@ -28,8 +28,8 @@  static ssize_t qedi_show_port_state(struct device *dev,
 		return sprintf(buf, "Linkdown\n");
 }
 
-static ssize_t qedi_show_speed(struct device *dev,
-			       struct device_attribute *attr, char *buf)
+static ssize_t speed_show(struct device *dev,
+			  struct device_attribute *attr, char *buf)
 {
 	struct qedi_ctx *qedi = qedi_dev_to_hba(dev);
 	struct qed_link_output if_link;
@@ -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,