From patchwork Thu Dec 1 02:17:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ye.xingchen@zte.com.cn X-Patchwork-Id: 28150 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp28747wrr; Wed, 30 Nov 2022 18:20:12 -0800 (PST) X-Google-Smtp-Source: AA0mqf5IfK4dvkDNg8oAwf1wfja9rkYys4qu/yYpkcgu6ag+i2XLPR3QWjzyoIbcL1yAGDw230b0 X-Received: by 2002:a17:907:2721:b0:7bd:28b5:2fb with SMTP id d1-20020a170907272100b007bd28b502fbmr23244590ejl.169.1669861212005; Wed, 30 Nov 2022 18:20:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669861212; cv=none; d=google.com; s=arc-20160816; b=JkxF/7Mq2132ptvrt5mvKcQNaFfz/YfxtQ5KVGR7N8dCDAL8cwND9PqMS7feBVsRc4 BZPWVRcZrRjDGEN7rXbIJJbbjjVUxekGiM/R3KzwgR2GXp1qgioMcsRcwfa4xiZtON+J EI/sUTnkIj5Z9lcPF9ed8eEMSDRXmvpeFALhAm+Cx4U4x2D9EZETvsh3LaDFxvlapKzp ZKWtpLtqyeUn46RawWAfQdUHc8hoDYiBhM7bsoEYIMDj+M6UxAKZdbm+vD+iZQ6YtU/s /q6u4l70q0po6USD4Mq1wg1ZUWLjaNYAw0OHujbo8K3j+zU3/MM+WMZJL2Qz45zcewnW GVPQ== 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=H7aWTDlB8uENxpg8SrehI/6ELXhha2he2CpetD3Q0os=; b=kFcIFW5rAz/IsCPAkmXvVwEIXIzfIgdJlL/0UqKXfFOdAW/jYTbcjwIkthLSATv2mL JWjX8HdV3p0dTgwSnbEFHOyZ/cjt86thal8oP67MlFaqtY87R5xH5xMjNz90JxpQjWUT XXdEfz0Ik/07rPQjlnbzkKwLrRcd9qysoICFxYT64IC5aONretyyMsBftlCJQQfLjxXb NRmaYeNPjYbvIQUaWbcrtUQLZmg6cRGydsOMxxhioDECFR4azXCYr/nETQoou4ciOSF4 Y51gVlDfeVG9lQR2sS5jfncCBLpgNXTQAISO2B9J8LeDo3oKFGlLXspHB6RVnowBgLjR h1Kg== 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 qb42-20020a1709077eaa00b007ade4c97618si3206752ejc.930.2022.11.30.18.19.48; Wed, 30 Nov 2022 18:20:11 -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 S229823AbiLACRk (ORCPT + 99 others); Wed, 30 Nov 2022 21:17:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbiLACRj (ORCPT ); Wed, 30 Nov 2022 21:17:39 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F3011170; Wed, 30 Nov 2022 18:17:38 -0800 (PST) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (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 4NN08c4THtz4xVnZ; Thu, 1 Dec 2022 10:17:36 +0800 (CST) Received: from xaxapp01.zte.com.cn ([10.88.40.50]) by mse-fl2.zte.com.cn with SMTP id 2B12HR1a083718; Thu, 1 Dec 2022 10:17:27 +0800 (+08) (envelope-from ye.xingchen@zte.com.cn) Received: from mapi (xaxapp01[null]) by mapi (Zmail) with MAPI id mid31; Thu, 1 Dec 2022 10:17:28 +0800 (CST) Date: Thu, 1 Dec 2022 10:17:28 +0800 (CST) X-Zmail-TransId: 2af963880eb865dc48e1 X-Mailer: Zmail v1.0 Message-ID: <202212011017282887800@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , Subject: =?utf-8?q?=5BPATCH=5D_fpga=3A_use_sysfs=5Femit=28=29_to_instead_of_?= =?utf-8?q?scnprintf=28=29?= X-MAIL: mse-fl2.zte.com.cn 2B12HR1a083718 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 63880EC0.003 by FangMail milter! X-FangMail-Envelope: 1669861056/4NN08c4THtz4xVnZ/63880EC0.003/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63880EC0.003/4NN08c4THtz4xVnZ 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?1750976390181890359?= X-GMAIL-MSGID: =?utf-8?q?1750976390181890359?= From: ye xingchen Replace the open-code with sysfs_emit() to simplify the code. Signed-off-by: ye xingchen --- drivers/fpga/dfl-afu-main.c | 4 ++-- drivers/fpga/dfl-fme-main.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/fpga/dfl-afu-main.c b/drivers/fpga/dfl-afu-main.c index 7f621e96d3b8..454fd4853000 100644 --- a/drivers/fpga/dfl-afu-main.c +++ b/drivers/fpga/dfl-afu-main.c @@ -155,7 +155,7 @@ id_show(struct device *dev, struct device_attribute *attr, char *buf) { int id = port_get_id(to_platform_device(dev)); - return scnprintf(buf, PAGE_SIZE, "%d\n", id); + return sysfs_emit(buf, "%d\n", id); } static DEVICE_ATTR_RO(id); @@ -472,7 +472,7 @@ afu_id_show(struct device *dev, struct device_attribute *attr, char *buf) guidh = readq(base + GUID_H); mutex_unlock(&pdata->lock); - return scnprintf(buf, PAGE_SIZE, "%016llx%016llx\n", guidh, guidl); + return sysfs_emit(buf, "%016llx%016llx\n", guidh, guidl); } static DEVICE_ATTR_RO(afu_id); diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c index 77ea04d4edbe..50e1ed69b811 100644 --- a/drivers/fpga/dfl-fme-main.c +++ b/drivers/fpga/dfl-fme-main.c @@ -34,7 +34,7 @@ static ssize_t ports_num_show(struct device *dev, v = readq(base + FME_HDR_CAP); - return scnprintf(buf, PAGE_SIZE, "%u\n", + return sysfs_emit(buf, "%u\n", (unsigned int)FIELD_GET(FME_CAP_NUM_PORTS, v)); } static DEVICE_ATTR_RO(ports_num); @@ -53,7 +53,7 @@ static ssize_t bitstream_id_show(struct device *dev, v = readq(base + FME_HDR_BITSTREAM_ID); - return scnprintf(buf, PAGE_SIZE, "0x%llx\n", (unsigned long long)v); + return sysfs_emit(buf, "0x%llx\n", (unsigned long long)v); } static DEVICE_ATTR_RO(bitstream_id); @@ -71,7 +71,7 @@ static ssize_t bitstream_metadata_show(struct device *dev, v = readq(base + FME_HDR_BITSTREAM_MD); - return scnprintf(buf, PAGE_SIZE, "0x%llx\n", (unsigned long long)v); + return sysfs_emit(buf, "0x%llx\n", (unsigned long long)v); } static DEVICE_ATTR_RO(bitstream_metadata);