summaryrefslogtreecommitdiff
path: root/drivers/staging/gasket
diff options
context:
space:
mode:
authorNick Ewalt <nicholasewalt@google.com>2018-10-14 21:59:24 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-10-15 16:30:37 +0200
commit4a966fa24a5a7e236db8ac1e58e04107db1c1930 (patch)
treec976683ea425706a87f0e41e74a65dc892a0e998 /drivers/staging/gasket
parentbae54fb8121da9d52cd6919758defb24639901cf (diff)
staging: gasket: page_table: simplify gasket_components_to_dev_address
Refactor gasket_components_to_dev_address to be faster and easier to understand. The old implementation was unnecessarily complex and masked the page_index for simple addresses but not extended ones. It makes the most sense for this function to perform no such masking. Signed-off-by: Nick Ewalt <nicholasewalt@google.com> Signed-off-by: Todd Poynor <toddpoynor@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/gasket')
-rw-r--r--drivers/staging/gasket/gasket_page_table.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c
index ec9359576ea7..c2fbab74194f 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -699,26 +699,9 @@ static ulong gasket_components_to_dev_address(struct gasket_page_table *pg_tbl,
int is_simple, uint page_index,
uint offset)
{
- ulong lvl0_index, lvl1_index;
+ ulong dev_addr = (page_index << GASKET_SIMPLE_PAGE_SHIFT) | offset;
- if (is_simple) {
- /* Return simple addresses directly. */
- lvl0_index = page_index & (pg_tbl->config.total_entries - 1);
- return (lvl0_index << GASKET_SIMPLE_PAGE_SHIFT) | offset;
- }
-
- /*
- * This could be compressed into fewer statements, but
- * A) the compiler should optimize it
- * B) this is not slow
- * C) this is an uncommon operation
- * D) this is actually readable this way.
- */
- lvl0_index = page_index / GASKET_PAGES_PER_SUBTABLE;
- lvl1_index = page_index & (GASKET_PAGES_PER_SUBTABLE - 1);
- return (pg_tbl)->extended_flag |
- (lvl0_index << GASKET_EXTENDED_LVL0_SHIFT) |
- (lvl1_index << GASKET_EXTENDED_LVL1_SHIFT) | offset;
+ return is_simple ? dev_addr : (pg_tbl->extended_flag | dev_addr);
}
/*