Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5988334ybe; Tue, 10 Sep 2019 11:48:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwv8BzNGmq5HnBQMR96o/Pqta0Up6iNO3Fd9dLK7/9X9GNIbE0rmL8utbfTL5Mn7Wn3Depq X-Received: by 2002:aa7:d899:: with SMTP id u25mr31197077edq.289.1568141290036; Tue, 10 Sep 2019 11:48:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568141290; cv=none; d=google.com; s=arc-20160816; b=UmUnrXqFiHmEieJmhretPRMHk9w/mwH/YX7uwcHalcmg1b1qi29OxZGbBYVKPE2nML hf+dIKyt54p564nE91uUdkR2hV68Q9RIR4PNeXyVoNy+R4ibM+MX8yuuFtdfgL7OvE67 9s/KEf8Jbgn2pEionZlflma3fADgsF2JeDGEs+jZ8/qLNOTcRi1vuGX3tvp9CWJJupDq afD/BTCqezdGX/YYzykod541gmqPMBzHMW+sB/9/x5RaEbXxYTCiBoa/Oxyww7uVfyaK PMCig12rXnw7J8WryLopqOM54l8Tr9PQ8n1/XR8HzaMLeqHMDdaqR9uoMAV3TKKnPFvv BB5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:in-reply-to:cc:references:message-id :date:subject:mime-version:from:content-transfer-encoding; bh=VtPOtvOsdC1dE3Kun1y/ZVwZBnhbsyW5303nikG8/Hc=; b=0FQGx89+zNwRyiuS4YP4WqJiGLetlWqcPJB8szYh4+1Lucf274nMx5REssi5/euc4U +5+RGsbt985j7OQiFGmA6OpguMWNfeJHPU2X6zXSLW8oAAQ06BYxZHn4Fg4F66syCrju 4udfHRthXP9qPsmJDS9UMOFb7ek7Q83IEXtm68P0w4ULKBnTO6tTHgMXN66Qy7AK+h5N ry9BSdk8H3/eZNBp2WEqaOIeVyW3p6SWqVwQiz0leLg04NjwPOuGTWy443tzGy5KXqDB ipTfNfqbiuvMET7GespbEmPdRMWfLK8NTXr1N7dnpIkFwBLNzAeOkcO5McBI+/ebIicq rWzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k23si9692648ejr.329.2019.09.10.11.47.45; Tue, 10 Sep 2019 11:48:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390638AbfIJFLb convert rfc822-to-8bit (ORCPT + 99 others); Tue, 10 Sep 2019 01:11:31 -0400 Received: from mxout013.mail.hostpoint.ch ([217.26.49.173]:10178 "EHLO mxout013.mail.hostpoint.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390362AbfIJFLb (ORCPT ); Tue, 10 Sep 2019 01:11:31 -0400 Received: from [10.0.2.45] (helo=asmtp012.mail.hostpoint.ch) by mxout013.mail.hostpoint.ch with esmtp (Exim 4.92.2 (FreeBSD)) (envelope-from ) id 1i7YR5-000LCo-Nn; Tue, 10 Sep 2019 07:11:27 +0200 Received: from [213.55.220.251] (helo=[100.66.103.90]) by asmtp012.mail.hostpoint.ch with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2 (FreeBSD)) (envelope-from ) id 1i7YR5-000H1j-FK; Tue, 10 Sep 2019 07:11:27 +0200 X-Authenticated-Sender-Id: lkml.sandro@volery.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT From: Sandro Volery LKML Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v2] Staging: gasket: Use temporaries to reduce line length. Date: Tue, 10 Sep 2019 07:11:26 +0200 Message-Id: <73C0743C-6864-4868-829B-D567F12A9463@volery.com> References: <20190910050557.GA8338@volery> Cc: rspringer@google.com, toddpoynor@google.com, benchan@chromium.org, gregkh@linuxfoundation.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, joe@perches.com In-Reply-To: <20190910050557.GA8338@volery> To: Sandro Volery X-Mailer: iPhone Mail (17A5831c) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Wow... I checked, compiled and still sent the wrong thing again. I'm gonna have to give this up soon if i can't get it right. Sandro V > On 10 Sep 2019, at 07:06, Sandro Volery wrote: > > Using temporaries for gasket_page_table entries to remove scnprintf() > statements and reduce line length, as suggested by Joe Perches. Thanks! > > Signed-off-by: Sandro Volery > --- > drivers/staging/gasket/apex_driver.c | 20 +++++++++----------- > 1 file changed, 9 insertions(+), 11 deletions(-) > > diff --git a/drivers/staging/gasket/apex_driver.c b/drivers/staging/gasket/apex_driver.c > index 2973bb920a26..16ac4329d65f 100644 > --- a/drivers/staging/gasket/apex_driver.c > +++ b/drivers/staging/gasket/apex_driver.c > @@ -509,6 +509,8 @@ static ssize_t sysfs_show(struct device *device, struct device_attribute *attr, > struct gasket_dev *gasket_dev; > struct gasket_sysfs_attribute *gasket_attr; > enum sysfs_attribute_type type; > + struct gasket_page_table *gpt; > + uint val; > > gasket_dev = gasket_sysfs_get_device_data(device); > if (!gasket_dev) { > @@ -524,29 +526,25 @@ static ssize_t sysfs_show(struct device *device, struct device_attribute *attr, > } > > type = (enum sysfs_attribute_type)gasket_attr->data.attr_type; > + gpt = gasket_dev->page_table[0]; > switch (type) { > case ATTR_KERNEL_HIB_PAGE_TABLE_SIZE: > - ret = scnprintf(buf, PAGE_SIZE, "%u\n", > - gasket_page_table_num_entries( > - gasket_dev->page_table[0])); > + val = gasket_page_table_num_simple_entries(gpt); > break; > case ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE: > - ret = scnprintf(buf, PAGE_SIZE, "%u\n", > - gasket_page_table_num_simple_entries( > - gasket_dev->page_table[0])); > + val = gasket_page_table_num_simple_entries(gpt); > break; > case ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES: > - ret = scnprintf(buf, PAGE_SIZE, "%u\n", > - gasket_page_table_num_active_pages( > - gasket_dev->page_table[0])); > + val = gasket_page_table_num_active_pages(gpt); > break; > default: > dev_dbg(gasket_dev->dev, "Unknown attribute: %s\n", > attr->attr.name); > ret = 0; > - break; > + goto exit; > } > - > + ret = scnprintf(buf, PAGE_SIZE, "%u\n", val); > +exit: > gasket_sysfs_put_attr(device, gasket_attr); > gasket_sysfs_put_device_data(device, gasket_dev); > return ret; > -- > 2.23.0 >