linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 01/10] staging/xgifb: Simplify XGI_GetRatePtrCRT2
@ 2013-02-03 21:54 Peter Huewe
  2013-02-03 21:54 ` [PATCH 02/10] staging/xgifb: Remove always false comparisons Peter Huewe
                   ` (9 more replies)
  0 siblings, 10 replies; 13+ messages in thread
From: Peter Huewe @ 2013-02-03 21:54 UTC (permalink / raw)
  To: Arnaud Patard
  Cc: Greg Kroah-Hartman, Miguel Gómez, Aaro Koskinen,
	Peter Huewe, Sam Hansen, devel, linux-kernel

Since the smaller LCDRefreshIndex is contained identically in LCDARefreshIndex
we can simply use LCDARefreshIndex and skip the if/else.

Since LCDARefreshIndex is only used readonly and contains only small
unsigned values we also change its declaration to const u8.

In order to prevent an out-of-bounds access I changed the mask from 0x0F
to 0x07 and added a dummy value.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
Please apply this series after my previous one 
 [PATCH 1/6] staging/xgifb: Remove unused variables and dead assignments
 [PATCH 2/6] staging/xgifb: Remove unused variable
 [PATCH 3/6] staging/xgifb: Remove unused variable and dead assignment
 [PATCH 4/6] staging/xgifb: Remove unused variables
 [PATCH 5/6] staging/xgifb: Remove redundant if statement
 [PATCH 6/6] staging/xgifb: remove unused variables

 drivers/staging/xgifb/vb_setmode.c |   16 ++++------------
 1 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c
index 8eb23a4..02e76c5 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -5470,9 +5470,8 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
 		unsigned short ModeNo, unsigned short ModeIdIndex,
 		struct vb_device_info *pVBInfo)
 {
-	short LCDRefreshIndex[] = { 0x00, 0x00, 0x03, 0x01 },
-			LCDARefreshIndex[] = { 0x00, 0x00, 0x03, 0x01, 0x01,
-					0x01, 0x01 };
+	const u8 LCDARefreshIndex[] = {
+		0x00, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x00 };
 
 	unsigned short RefreshRateTableIndex, i, index, temp;
 
@@ -5489,15 +5488,8 @@ unsigned short XGI_GetRatePtrCRT2(struct xgi_hw_device_info *pXGIHWDE,
 	if (pVBInfo->SetFlag & ProgrammingCRT2) {
 		if (pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) {
 			if (pVBInfo->IF_DEF_LVDS == 0) {
-				if (pVBInfo->VBType & (VB_SIS301B | VB_SIS302B
-						| VB_SIS301LV | VB_SIS302LV
-						| VB_XGI301C))
-					/* 301b */
-					temp = LCDARefreshIndex[
-						pVBInfo->LCDResInfo & 0x0F];
-				else
-					temp = LCDRefreshIndex[
-						pVBInfo->LCDResInfo & 0x0F];
+				temp = LCDARefreshIndex[
+					pVBInfo->LCDResInfo & 0x07];
 
 				if (index > temp)
 					index = temp;
-- 
1.7.8.6


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

end of thread, other threads:[~2013-02-04 19:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-03 21:54 [PATCH 01/10] staging/xgifb: Simplify XGI_GetRatePtrCRT2 Peter Huewe
2013-02-03 21:54 ` [PATCH 02/10] staging/xgifb: Remove always false comparisons Peter Huewe
2013-02-03 21:54 ` [PATCH 03/10] staging/xgifb: mttr must be (signed) int Peter Huewe
2013-02-03 21:54 ` [PATCH 04/10] staging/xgifb: Fix return of uninitialized variable Peter Huewe
2013-02-03 21:54 ` [PATCH 05/10] staging/xgifb: Simplify XGI_SetSeqRegs Peter Huewe
2013-02-03 21:54 ` [PATCH 06/10] staging/xgifb: rewrite XGIfb_get_cmap_len Peter Huewe
2013-02-03 21:54 ` [PATCH 07/10] staging/xgifb: remove unnecessary temp variable in XGIfb_mode_rate_to_ddata Peter Huewe
2013-02-03 21:54 ` [PATCH 08/10] staging/xgifb: Remove unnecessary bitshifts in XGI_SetCRT1ModeRegs Peter Huewe
2013-02-04 12:59   ` Dan Carpenter
2013-02-04 18:25     ` H Hartley Sweeten
2013-02-03 21:54 ` [PATCH 09/10] staging/xgifb: Consolidate XGI_EnableChISLCD and XGI_DisableChISLCD Peter Huewe
2013-02-03 21:54 ` [PATCH 10/10] staging/xgifb: Simplify XGISetModeNew Peter Huewe
2013-02-04 19:37 ` [PATCH 01/10] staging/xgifb: Simplify XGI_GetRatePtrCRT2 Aaro Koskinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).