* [PATCH linux next v2] scsi: ibmvfc: use sysfs_emit() to instead of scnprintf()
@ 2022-11-14 3:38 yang.yang29
2022-11-14 7:18 ` Christophe Leroy
0 siblings, 1 reply; 2+ messages in thread
From: yang.yang29 @ 2022-11-14 3:38 UTC (permalink / raw)
To: tyreld
Cc: mpe, npiggin, christophe.leroy, jejb, martin.petersen, linux-scsi,
linuxppc-dev, linux-kernel, xu.panda, yang.yang29
From: Xu Panda <xu.panda@zte.com.cn>
Replace the open-code with sysfs_emit() to simplify the code.
---
change for v2
- align code
---
Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
---
drivers/scsi/ibmvscsi/ibmvfc.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 1a0c0b7289d2..841e47c94b12 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -3411,8 +3411,7 @@ static ssize_t ibmvfc_show_host_partition_name(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvfc_host *vhost = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%s\n",
- vhost->login_buf->resp.partition_name);
+ return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.partition_name);
}
static ssize_t ibmvfc_show_host_device_name(struct device *dev,
@@ -3421,8 +3420,7 @@ static ssize_t ibmvfc_show_host_device_name(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvfc_host *vhost = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%s\n",
- vhost->login_buf->resp.device_name);
+ return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.device_name);
}
static ssize_t ibmvfc_show_host_loc_code(struct device *dev,
@@ -3431,8 +3429,7 @@ static ssize_t ibmvfc_show_host_loc_code(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvfc_host *vhost = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%s\n",
- vhost->login_buf->resp.port_loc_code);
+ return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.port_loc_code);
}
static ssize_t ibmvfc_show_host_drc_name(struct device *dev,
@@ -3441,8 +3438,7 @@ static ssize_t ibmvfc_show_host_drc_name(struct device *dev,
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvfc_host *vhost = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%s\n",
- vhost->login_buf->resp.drc_name);
+ return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.drc_name);
}
static ssize_t ibmvfc_show_host_npiv_version(struct device *dev,
@@ -3450,7 +3446,7 @@ static ssize_t ibmvfc_show_host_npiv_version(struct device *dev,
{
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvfc_host *vhost = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%d\n", be32_to_cpu(vhost->login_buf->resp.version));
+ return sysfs_emit(buf, "%d\n", be32_to_cpu(vhost->login_buf->resp.version));
}
static ssize_t ibmvfc_show_host_capabilities(struct device *dev,
@@ -3458,7 +3454,7 @@ static ssize_t ibmvfc_show_host_capabilities(struct device *dev,
{
struct Scsi_Host *shost = class_to_shost(dev);
struct ibmvfc_host *vhost = shost_priv(shost);
- return snprintf(buf, PAGE_SIZE, "%llx\n", be64_to_cpu(vhost->login_buf->resp.capabilities));
+ return sysfs_emit(buf, "%llx\n", be64_to_cpu(vhost->login_buf->resp.capabilities));
}
/**
@@ -3479,7 +3475,7 @@ static ssize_t ibmvfc_show_log_level(struct device *dev,
int len;
spin_lock_irqsave(shost->host_lock, flags);
- len = snprintf(buf, PAGE_SIZE, "%d\n", vhost->log_level);
+ len = sysfs_emit(buf, "%d\n", vhost->log_level);
spin_unlock_irqrestore(shost->host_lock, flags);
return len;
}
@@ -3517,7 +3513,7 @@ static ssize_t ibmvfc_show_scsi_channels(struct device *dev,
int len;
spin_lock_irqsave(shost->host_lock, flags);
- len = snprintf(buf, PAGE_SIZE, "%d\n", vhost->client_scsi_channels);
+ len = sysfs_emit(buf, "%d\n", vhost->client_scsi_channels);
spin_unlock_irqrestore(shost->host_lock, flags);
return len;
}
--
2.15.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH linux next v2] scsi: ibmvfc: use sysfs_emit() to instead of scnprintf()
2022-11-14 3:38 [PATCH linux next v2] scsi: ibmvfc: use sysfs_emit() to instead of scnprintf() yang.yang29
@ 2022-11-14 7:18 ` Christophe Leroy
0 siblings, 0 replies; 2+ messages in thread
From: Christophe Leroy @ 2022-11-14 7:18 UTC (permalink / raw)
To: yang.yang29@zte.com.cn, tyreld@linux.ibm.com
Cc: mpe@ellerman.id.au, npiggin@gmail.com, jejb@linux.ibm.com,
martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
xu.panda@zte.com.cn
Le 14/11/2022 à 04:38, yang.yang29@zte.com.cn a écrit :
> [Vous ne recevez pas souvent de courriers de yang.yang29@zte.com.cn. Découvrez pourquoi ceci est important à https://aka.ms/LearnAboutSenderIdentification ]
>
> From: Xu Panda <xu.panda@zte.com.cn>
>
> Replace the open-code with sysfs_emit() to simplify the code.
>
> ---
> change for v2
> - align code
> ---
> Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
> Signed-off-by: Yang Yang <yang.yang29@zte.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> drivers/scsi/ibmvscsi/ibmvfc.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
> index 1a0c0b7289d2..841e47c94b12 100644
> --- a/drivers/scsi/ibmvscsi/ibmvfc.c
> +++ b/drivers/scsi/ibmvscsi/ibmvfc.c
> @@ -3411,8 +3411,7 @@ static ssize_t ibmvfc_show_host_partition_name(struct device *dev,
> struct Scsi_Host *shost = class_to_shost(dev);
> struct ibmvfc_host *vhost = shost_priv(shost);
>
> - return snprintf(buf, PAGE_SIZE, "%s\n",
> - vhost->login_buf->resp.partition_name);
> + return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.partition_name);
> }
>
> static ssize_t ibmvfc_show_host_device_name(struct device *dev,
> @@ -3421,8 +3420,7 @@ static ssize_t ibmvfc_show_host_device_name(struct device *dev,
> struct Scsi_Host *shost = class_to_shost(dev);
> struct ibmvfc_host *vhost = shost_priv(shost);
>
> - return snprintf(buf, PAGE_SIZE, "%s\n",
> - vhost->login_buf->resp.device_name);
> + return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.device_name);
> }
>
> static ssize_t ibmvfc_show_host_loc_code(struct device *dev,
> @@ -3431,8 +3429,7 @@ static ssize_t ibmvfc_show_host_loc_code(struct device *dev,
> struct Scsi_Host *shost = class_to_shost(dev);
> struct ibmvfc_host *vhost = shost_priv(shost);
>
> - return snprintf(buf, PAGE_SIZE, "%s\n",
> - vhost->login_buf->resp.port_loc_code);
> + return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.port_loc_code);
> }
>
> static ssize_t ibmvfc_show_host_drc_name(struct device *dev,
> @@ -3441,8 +3438,7 @@ static ssize_t ibmvfc_show_host_drc_name(struct device *dev,
> struct Scsi_Host *shost = class_to_shost(dev);
> struct ibmvfc_host *vhost = shost_priv(shost);
>
> - return snprintf(buf, PAGE_SIZE, "%s\n",
> - vhost->login_buf->resp.drc_name);
> + return sysfs_emit(buf, "%s\n", vhost->login_buf->resp.drc_name);
> }
>
> static ssize_t ibmvfc_show_host_npiv_version(struct device *dev,
> @@ -3450,7 +3446,7 @@ static ssize_t ibmvfc_show_host_npiv_version(struct device *dev,
> {
> struct Scsi_Host *shost = class_to_shost(dev);
> struct ibmvfc_host *vhost = shost_priv(shost);
> - return snprintf(buf, PAGE_SIZE, "%d\n", be32_to_cpu(vhost->login_buf->resp.version));
> + return sysfs_emit(buf, "%d\n", be32_to_cpu(vhost->login_buf->resp.version));
> }
>
> static ssize_t ibmvfc_show_host_capabilities(struct device *dev,
> @@ -3458,7 +3454,7 @@ static ssize_t ibmvfc_show_host_capabilities(struct device *dev,
> {
> struct Scsi_Host *shost = class_to_shost(dev);
> struct ibmvfc_host *vhost = shost_priv(shost);
> - return snprintf(buf, PAGE_SIZE, "%llx\n", be64_to_cpu(vhost->login_buf->resp.capabilities));
> + return sysfs_emit(buf, "%llx\n", be64_to_cpu(vhost->login_buf->resp.capabilities));
> }
>
> /**
> @@ -3479,7 +3475,7 @@ static ssize_t ibmvfc_show_log_level(struct device *dev,
> int len;
>
> spin_lock_irqsave(shost->host_lock, flags);
> - len = snprintf(buf, PAGE_SIZE, "%d\n", vhost->log_level);
> + len = sysfs_emit(buf, "%d\n", vhost->log_level);
> spin_unlock_irqrestore(shost->host_lock, flags);
> return len;
> }
> @@ -3517,7 +3513,7 @@ static ssize_t ibmvfc_show_scsi_channels(struct device *dev,
> int len;
>
> spin_lock_irqsave(shost->host_lock, flags);
> - len = snprintf(buf, PAGE_SIZE, "%d\n", vhost->client_scsi_channels);
> + len = sysfs_emit(buf, "%d\n", vhost->client_scsi_channels);
> spin_unlock_irqrestore(shost->host_lock, flags);
> return len;
> }
> --
> 2.15.2
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-14 7:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-14 3:38 [PATCH linux next v2] scsi: ibmvfc: use sysfs_emit() to instead of scnprintf() yang.yang29
2022-11-14 7:18 ` Christophe Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox