Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35011881rwd; Mon, 10 Jul 2023 00:58:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlFZzrm08qtOYZjZXrkeXdE/Ay3DS3uz0+E+tCWYV/CHqNirHzkzFTUgbicDR1/ThEoP5+4S X-Received: by 2002:a05:620a:28c5:b0:75d:4101:2c9a with SMTP id l5-20020a05620a28c500b0075d41012c9amr14646702qkp.34.1688975926350; Mon, 10 Jul 2023 00:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688975926; cv=none; d=google.com; s=arc-20160816; b=b57p4aqVFxWzxb23bUiHniFyhx3cVq2sb/06/Vnc4qmyGZZP/yo+2C2ZjdxBCUwO8W 9ioEt2ZUBOnPtEMu1Z6lS5pHWaC6LqJEsrA11dC4tgjd6ylnpp8dVZKvfC5Xa+dfiZv4 8wtZECewrTXj8XVmQ0qd/tBYLZsQvrR3keD7igFgOP2/4+dQl+86rb284B7d/zN5RJXi hV+W7cfb3r004Ejbcs9dYFEv88qskuURFHJ3wUaG/vpbtGHRIQjTOs1UfO8VXUGZLoaI Jb/w2h9SoRvzfO9MTkzqyWnvLeb3BHKY+6EwLwz8jw7EnOtCIs2g+ZUSaiKllTH8EvjX /IXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=z+fVxGOLvomRxPHgL8YfDJ1nyh1KoERX/P9uIiZCMtc=; fh=pUZIbqjGywYFWHW5kugCCciHVtis1WEMvo78eidY15I=; b=Izr3VDo5MrPFD8cu16Pb3CrYriUwsTmd3tQEo4QuHr4PTScisHhbyrCMLfSZvU+HwZ WqMQFS/1/doRepfduVMSYNhsOV3rhH8Jo2KZfy6NbWphbN7ktqsemujUTKlzFmEvUq/s n4usBgC0VsSqI8YJsTDImOaA0Nb9PlI+OOAaLRWJ66IP9pA2xMi7O1VlXaj5U/tCD2fh c/n9Ax31Y57RYzA1N5v1y8l9LbEdXZdaTFSIc7manQA9IYDDm4x2efsEJq0ChaaBRutO +ZyTg4l8pXoxY2BcmPwyzTvFW+6mvxAt3u7cskoqfYIjpaBe9N7Id++Gdr8dsyVuLviF ZL7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kx0nVSR1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020a63d80d000000b0051b48085aaasi1737315pgh.858.2023.07.10.00.58.34; Mon, 10 Jul 2023 00:58:46 -0700 (PDT) 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; dkim=pass header.i=@intel.com header.s=Intel header.b=kx0nVSR1; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231443AbjGJHr3 (ORCPT + 99 others); Mon, 10 Jul 2023 03:47:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231438AbjGJHr2 (ORCPT ); Mon, 10 Jul 2023 03:47:28 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10E1B12E; Mon, 10 Jul 2023 00:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1688975243; x=1720511243; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=xPztZ+J8MBfqfmjx7KsUl5UggWWY3LTfkcDk9EsYdp4=; b=kx0nVSR10GaI3H6a2Ly69+cAI5ngdqdicRDp6tVgyc/eQ2P+aT/aEsiu d+UeVMgBFUhe6qHafqHh2VNIiheVe4656Trj0NxYU2PQ9TWtU5F51JO0O h/LLDTDKBWIAbTBGJfgYWKP1nolCIC2qBD/XfPDt3WmJnewlaFvpUkJ0A JGSomsfQftXXmKeQuvk+R3UowWNSEsNsXoN1askv5L7WenLjGFtWYX028 J+RiXidb7Dt30RNYpy/JxOjYgPKGs7Pxq7qh+DacpFa1aq5zg/UudwWl6 pwboG91IdYzIVa84zG4d0EUm6/ZQiwpTLTgmvP39luHqTC3qAesaYf/96 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10766"; a="354138667" X-IronPort-AV: E=Sophos;i="6.01,194,1684825200"; d="scan'208";a="354138667" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jul 2023 00:47:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10766"; a="1051272913" X-IronPort-AV: E=Sophos;i="6.01,194,1684825200"; d="scan'208";a="1051272913" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmsmga005.fm.intel.com with ESMTP; 10 Jul 2023 00:47:19 -0700 Date: Mon, 10 Jul 2023 15:45:52 +0800 From: Xu Yilun To: Peter Colberg Cc: Wu Hao , Tom Rix , Moritz Fischer , linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko , tianfei.zhang@intel.com, russell.h.weight@intel.com, matthew.gerlach@linux.intel.com, marpagan@redhat.com, lgoncalv@redhat.com Subject: Re: [PATCH 1/2] fpga: dfl: use sysfs_emit() to format sysfs values Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 On 2023-07-04 at 22:54:50 -0400, Peter Colberg wrote: > Use sysfs_emit() to format sysfs values, which wraps vscnprintf() for a > PAGE_SIZE buffer. Remove explicit casts in favour of using the printk() > format specifier corresponding to the type of the formatted value. > > These changes are cosmetic only; no functional changes. > > Suggested-by: Andy Shevchenko > Signed-off-by: Peter Colberg > Reviewed-by: Andy Shevchenko > --- > drivers/fpga/dfl-afu-error.c | 7 +++---- > drivers/fpga/dfl-afu-main.c | 17 ++++++++--------- > drivers/fpga/dfl-fme-error.c | 19 ++++++++----------- > drivers/fpga/dfl-fme-main.c | 26 ++++++++++---------------- > drivers/fpga/dfl-fme-perf.c | 16 +++++++--------- > drivers/fpga/dfl.c | 4 ++-- > drivers/fpga/fpga-bridge.c | 2 +- > drivers/fpga/fpga-mgr.c | 4 ++-- > drivers/fpga/fpga-region.c | 5 ++--- > 9 files changed, 43 insertions(+), 57 deletions(-) > [...] > diff --git a/drivers/fpga/dfl-fme-perf.c b/drivers/fpga/dfl-fme-perf.c > index 7422d2bc6f37..1b072416069b 100644 > --- a/drivers/fpga/dfl-fme-perf.c > +++ b/drivers/fpga/dfl-fme-perf.c > @@ -524,20 +524,18 @@ static ssize_t fme_perf_event_show(struct device *dev, > { > struct dev_ext_attribute *eattr; > unsigned long config; > - char *ptr = buf; > > eattr = container_of(attr, struct dev_ext_attribute, attr); > config = (unsigned long)eattr->var; > > - ptr += sprintf(ptr, "event=0x%02x", (unsigned int)get_event(config)); > - ptr += sprintf(ptr, ",evtype=0x%02x", (unsigned int)get_evtype(config)); > + if (!is_portid_root(get_portid(config))) > + return sysfs_emit(buf, > + "event=0x%02llx,evtype=0x%02llx,portid=?\n", ^ ^ why llx, should be lx? > + get_event(config), get_evtype(config)); > > - if (is_portid_root(get_portid(config))) > - ptr += sprintf(ptr, ",portid=0x%02x\n", FME_PORTID_ROOT); > - else > - ptr += sprintf(ptr, ",portid=?\n"); > - > - return (ssize_t)(ptr - buf); > + return sysfs_emit(buf, "event=0x%02llx,evtype=0x%02llx,portid=0x%02x\n", same > + get_event(config), get_evtype(config), > + FME_PORTID_ROOT); BTW, have you ever tested with perf tool? The perf sysfs is a little tricky to make perf work. I'm not sure everything is fine with naked eyes. Thanks, Yilun