DriverDev-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] Staging: gasket: Use temporaries to reduce line length.
@ 2019-09-10  5:05 Sandro Volery
  2019-09-10  5:11 ` Sandro Volery LKML
  0 siblings, 1 reply; 3+ messages in thread
From: Sandro Volery @ 2019-09-10  5:05 UTC (permalink / raw)
  To: rspringer, toddpoynor, benchan, gregkh, devel, linux-kernel; +Cc: joe

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 <sandro@volery.com>
---
 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

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] Staging: gasket: Use temporaries to reduce line length.
  2019-09-10  5:05 [PATCH v2] Staging: gasket: Use temporaries to reduce line length Sandro Volery
@ 2019-09-10  5:11 ` Sandro Volery LKML
  2019-09-10 11:27   ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Sandro Volery LKML @ 2019-09-10  5:11 UTC (permalink / raw)
  To: Sandro Volery; +Cc: devel, gregkh, linux-kernel, rspringer, joe, toddpoynor

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 <sandro@volery.com> 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 <sandro@volery.com>
> ---
> 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
> 

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] Staging: gasket: Use temporaries to reduce line length.
  2019-09-10  5:11 ` Sandro Volery LKML
@ 2019-09-10 11:27   ` Dan Carpenter
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2019-09-10 11:27 UTC (permalink / raw)
  To: Sandro Volery LKML
  Cc: devel, gregkh, linux-kernel, Sandro Volery, rspringer, joe, toddpoynor

On Tue, Sep 10, 2019 at 07:11:26AM +0200, Sandro Volery LKML wrote:
> 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.
> 

The mistake was using gasket_page_table_num_simple_entries() instead
of gasket_page_table_num_entries()?

When I write a patch, I always queue it up and the let it sit in my
outbox overnight so I can review it again in the morning.  Otherwise my
mind is clouded with other emotions and I can't review objectively.
There is never a rush.

> Sandro V
> 
> > On 10 Sep 2019, at 07:06, Sandro Volery <sandro@volery.com> wrote:
> > 
> > Using temporaries for gasket_page_table entries to remove scnprintf()
> > statements and reduce line length, as suggested by Joe Perches. Thanks!
                                                                    ^^^^^^^

Don't put this in the commit log.  :P

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-10  5:05 [PATCH v2] Staging: gasket: Use temporaries to reduce line length Sandro Volery
2019-09-10  5:11 ` Sandro Volery LKML
2019-09-10 11:27   ` Dan Carpenter

DriverDev-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/driverdev-devel/0 driverdev-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 driverdev-devel driverdev-devel/ https://lore.kernel.org/driverdev-devel \
		driverdev-devel@linuxdriverproject.org devel@driverdev.osuosl.org driverdev-devel@archiver.kernel.org
	public-inbox-index driverdev-devel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxdriverproject.driverdev-devel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox