Skip to content

Commit

Permalink
Staging: gasket: Use temporaries to reduce line length.
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20190910061928.GA9623@volery
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Sandro Volery authored and Greg Kroah-Hartman committed Sep 12, 2019
1 parent 129dac3 commit 3fb73ed
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions drivers/staging/gasket/apex_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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_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;
Expand Down

0 comments on commit 3fb73ed

Please sign in to comment.