Removed recursion. Also reduced few if() checks.

Cc: Hans Verkuil <hans.verk...@cisco.com>
Signed-off-by: Prashant Laddha <prlad...@cisco.com>
---
 drivers/media/platform/vivid/vivid-sin.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/media/platform/vivid/vivid-sin.c 
b/drivers/media/platform/vivid/vivid-sin.c
index 0774bdd..f2158a3 100644
--- a/drivers/media/platform/vivid/vivid-sin.c
+++ b/drivers/media/platform/vivid/vivid-sin.c
@@ -35,21 +35,19 @@ static s32 sin[65] = {
 
 static s32 get_sin_val(u32 index)
 {
-       if(index <= 64)
-               return sin[index];
-       else if (index > 64 && index <= 128) {
-               u32 tab_index = 64 - (index - 64);
-               return sin[tab_index];
-       } else if (index > 128 && index <= 192) {
-               u32 tab_index = index - 128;
-               return (-1) * sin[tab_index];
-       } else if (index > 192 && index <= 255) {
-               u32 tab_index = 64 - (index - 192);
-               return (-1) * sin[tab_index];
-       } else {
-               u32 new_index = index % 256;
-               return get_sin_val(new_index);
-       }
+       s32 sign = 1;
+       u32 tab_index;
+       u32 new_index = index & 0x7F; /* new_index = index % 128*/
+
+       if (index > 128)
+               sign = -1;
+
+       if(new_index <= 64)
+               tab_index = new_index;
+       else
+               tab_index = 64 - (new_index - 64);
+
+       return sign * sin[tab_index];
 }
 
 /*
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to