From patchwork Mon Nov 14 03:38:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yang X-Patchwork-Id: 19538 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1951088wru; Sun, 13 Nov 2022 20:03:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf4rETGqE4f0jksjO5mYNJALbI53m04YUWcflIWaCOKRfZ1w+hhWGyhh679z6iB/SGc7/och X-Received: by 2002:a50:d657:0:b0:461:17e9:4ea3 with SMTP id c23-20020a50d657000000b0046117e94ea3mr9765681edj.49.1668398606960; Sun, 13 Nov 2022 20:03:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668398606; cv=none; d=google.com; s=arc-20160816; b=u74By657c7DyL7Y/7H14LBqNrBeLAHd9OEGu76GopV767EjW0+6smnL8V9OkOcRqXr 28FhHbJ6Z+RBbxJKVaEkvAylO/jm9zhKToFWGoOBQWaUF2cc6fJewxCRntZ53Eu0JC6F uzE6s6H3FGOP5cnpBMh76rD+rj+Sy1vlkTgbMG3J02WsmlNL0AraaaHcBZgtTnjIgEfw Su248WaVbu5OuGkDRzm8c3BScb3gddRgqfILfHAsA5+Tstin0vgNmvy6Go4+XOlTJTUK q8zjb/VS5K/ddTG3q2KYs8T3jFYQPd4REsM3kDh61liSDLh9x4s7DCzKIBzgPhLWxASi TWiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=mc39/RG4VNUBPYm8hAY63C1GTh8NTmfgX0p7QPm3EYg=; b=enofP63gO6GzYJv18ajQKD5BT9EylZLUnPrLmf1wneIkWxhXzOiz5jWQffXEeaJD3t Kl5vA+Z/7V62+L8roe4EbnXFojKZJpNLbdCChkHOf8BhqWLjG1puXVuDZabAina8eMUk ZlOiVxXsHZRy8TTiyis00JH+PRMn/cEjowLI5JrATRmFfuRX0W0DZKXqMPjNDppizdrD De4Qgi1WTh3tApN1mKa7eHJKgPLS1BaFfB0bvW6RC2PnD9Buj9DGCG4jgqLBKWA4ep7c FXBd+GRp6IhEn/95lpiC9KP+eMbJKQ5cUdMN5yXMuJqnVXjEPzPCSCjsJYF1YDSMWK64 WtFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds5-20020a170907724500b00770872942d8si8797211ejc.958.2022.11.13.20.03.02; Sun, 13 Nov 2022 20:03:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235719AbiKNDjA (ORCPT + 99 others); Sun, 13 Nov 2022 22:39:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235348AbiKNDi6 (ORCPT ); Sun, 13 Nov 2022 22:38:58 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [58.251.27.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF8E6559; Sun, 13 Nov 2022 19:38:55 -0800 (PST) Received: from mxde.zte.com.cn (unknown [10.35.20.121]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4N9ZmF2RPFzjn8; Mon, 14 Nov 2022 11:38:53 +0800 (CST) Received: from mxus.zte.com.cn (unknown [10.207.168.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mxde.zte.com.cn (FangMail) with ESMTPS id 4N9Zly5p4kz9vSpd; Mon, 14 Nov 2022 11:38:38 +0800 (CST) Received: from mxhk.zte.com.cn (unknown [192.168.250.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mxus.zte.com.cn (FangMail) with ESMTPS id 4N9Zlt5GxZzdmYkl; Mon, 14 Nov 2022 11:38:34 +0800 (CST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4N9Zlq52SGz8QrkZ; Mon, 14 Nov 2022 11:38:31 +0800 (CST) Received: from szxlzmapp04.zte.com.cn ([10.5.231.166]) by mse-fl1.zte.com.cn with SMTP id 2AE3cRn1020766; Mon, 14 Nov 2022 11:38:27 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp04[null]) by mapi (Zmail) with MAPI id mid14; Mon, 14 Nov 2022 11:38:28 +0800 (CST) Date: Mon, 14 Nov 2022 11:38:28 +0800 (CST) X-Zmail-TransId: 2b066371b834ffffffff9acfccbb X-Mailer: Zmail v1.0 Message-ID: <202211141138288877199@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , Subject: =?utf-8?q?=5BPATCH_linux_next_v2=5D_scsi=3A_ibmvfc=3A_use_sysfs=5Fe?= =?utf-8?q?mit=28=29_to_instead_of_scnprintf=28=29?= X-MAIL: mse-fl1.zte.com.cn 2AE3cRn1020766 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.14.novalocal with ID 6371B84C.000 by FangMail milter! X-FangMail-Envelope: 1668397133/4N9ZmF2RPFzjn8/6371B84C.000/10.35.20.121/[10.35.20.121]/mxde.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 6371B84C.000/4N9ZmF2RPFzjn8 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749442737897141948?= X-GMAIL-MSGID: =?utf-8?q?1749442737897141948?= From: Xu Panda Replace the open-code with sysfs_emit() to simplify the code. Reviewed-by: Christophe Leroy --- change for v2 - align code --- Signed-off-by: Xu Panda Signed-off-by: Yang Yang --- 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; }