staging/xgifb: Remove uneccessary/simply if in XGINew_GetXG20DRAMType
PATCH 1/5 staging/xgifb: Remove uneccessary/simply if in XGINew_GetXG20DRAMType
Instead of storing the value in a temp variable, anding it with 1 and assign data conditionally we can assign the value directly.
--- drivers/staging/xgifb/vb_init.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/staging/xgifb/vb_init.c +3 -5
@@ -54,14 +54,12 @@ XGINew_GetXG20DRAMType(struct xgi_hw_device_info *HwDeviceExtension,udelay (800 );xgifb_reg_or (pVBInfo->P3d4,0x4A ,0x80 );/* Enable GPIOH read */ /* GPIOF 0:DVI 1:DVO */ - temp =xgifb_reg_get (pVBInfo->P3d4,0x48 ); + data =xgifb_reg_get (pVBInfo->P3d4,0x48 );/* HOTPLUG_SUPPORT */ /* for current XG20 & XG21, GPIOH is floating, driver will * fix DDR temporarily */ -if (temp &0x01 )/* DVI read GPIOH */ - data =1 ;/* DDRII */ -else - data =0 ;/* DDR */ +/* DVI read GPIOH */ + data &=0x01 ;/* 1=DDRII, 0=DDR */ /* ~HOTPLUG_SUPPORT */ xgifb_reg_or (pVBInfo->P3d4,0xB4 ,0x02 );return data;
Signature · 1 line
1.8.1.5
PATCH 2/5 staging/xgifb: Remove unnecessary cases in XGINew_SenseLCD
The switch statement sets the temp value to zero for certain cases and leaves it untouched for other cases -> all these other cases can be combined in the default case.
Since an empty case containing only a break, it can be removed.
The patch also removes the if statement, as it uses the same value as the switch for comparison, and includes the code into the switch.
--- drivers/staging/xgifb/vb_init.c | 51 ++++++++++++----------------------------- 1 file changed, 15 insertions(+), 36 deletions(-)
drivers/staging/xgifb/vb_init.c +15 -36
@@ -1077,44 +1077,23 @@ static unsigned short XGINew_SenseLCD(struct xgi_hw_device_info *HwDeviceExtension, struct vb_device_info *pVBInfo) { -unsigned short temp; - -/* add lcd sense */ -if (HwDeviceExtension->ulCRT2LCDType ==LCD_UNKNOWN ) { +unsigned short temp = HwDeviceExtension->ulCRT2LCDType; + +switch (HwDeviceExtension->ulCRT2LCDType) { +case LCD_640x480: +case LCD_1024x600: +case LCD_1152x864: +case LCD_1280x960: +case LCD_1152x768: +case LCD_1920x1440: +case LCD_2048x1536: + temp =0 ;/* overwrite used ulCRT2LCDType */ +break ; +case LCD_UNKNOWN :/* unknown lcd, do nothing */ return 0 ; - }else { - temp = (unsigned short ) HwDeviceExtension->ulCRT2LCDType; -switch (HwDeviceExtension->ulCRT2LCDType) { -case LCD_INVALID : -case LCD_800x600: -case LCD_1024x768: -case LCD_1280x1024: -break ; - -case LCD_640x480: -case LCD_1024x600: -case LCD_1152x864: -case LCD_1280x960: -case LCD_1152x768: - temp =0 ; -break ; - -case LCD_1400x1050: -case LCD_1280x768: -case LCD_1600x1200: -break ; - -case LCD_1920x1440: -case LCD_2048x1536: - temp =0 ; -break ; - -default : -break ; - } -xgifb_reg_and_or (pVBInfo->P3d4,0x36 ,0xF0 , temp); -return 1 ; } +xgifb_reg_and_or (pVBInfo->P3d4,0x36 ,0xF0 , temp); +return 1 ; } static void XGINew_GetXG21Sense(struct pci_dev *pdev,
Signature · 1 line
1.8.1.5
PATCH 3/5 staging/xgifb: Consolidate function almost identical calls in XGINew_GetXG21Sense
In reply to Peter HueweInstead of calling xgifb_reg_and_or with almost identical parameters in a simple if/else scenario, we assign the changing parameter to a temp variable and call xgifb_reg_and_or only from one location.
-> Easier to read, easier to understand (especially wrt the line breaks)
(For the if condition we don't need the Temp variable, so we can use the value directly).
--- drivers/staging/xgifb/vb_init.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
drivers/staging/xgifb/vb_init.c +4 -10
@@ -1115,17 +1115,11 @@ static void XGINew_GetXG21Sense(struct pci_dev *pdev,xgifb_reg_or (pVBInfo->P3d4,0x32 , LCDSense);/* Enable read GPIOF */ xgifb_reg_and_or (pVBInfo->P3d4,0x4A , ~0x20 ,0x20 ); - Temp =xgifb_reg_get (pVBInfo->P3d4,0x48 ) &0x04 ; -if (!Temp) -xgifb_reg_and_or (pVBInfo->P3d4, -0x38 , - ~0xE0 , -0x80 );/* TMDS on chip */ +if (xgifb_reg_get (pVBInfo->P3d4,0x48 ) &0x04 ) + Temp =0xA0 ;/* Only DVO on chip */ else -xgifb_reg_and_or (pVBInfo->P3d4, -0x38 , - ~0xE0 , -0xA0 );/* Only DVO on chip */ + Temp =0x80 ;/* TMDS on chip */ +xgifb_reg_and_or (pVBInfo->P3d4,0x38 , ~0xE0 , Temp);/* Disable read GPIOF */ xgifb_reg_and (pVBInfo->P3d4,0x4A , ~0x20 ); }
Signature · 1 line
1.8.1.5
PATCH 4/5 staging/xgifb: Remove unnecessary binary calculation in GetXG27FPBits
In reply to Peter HueweIf temp <= 2 no other bits than the lowest two (0x03) can be set anyway -> this operation can be removed.
--- drivers/staging/xgifb/vb_init.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/xgifb/vb_init.c +1 -3
@@ -1177,9 +1177,7 @@ static unsigned char GetXG27FPBits(struct vb_device_info *pVBInfo)/* enable GPIOA/B/C read */ xgifb_reg_and_or (pVBInfo->P3d4,0x4A , ~0x03 ,0x03 ); temp =xgifb_reg_get (pVBInfo->P3d4,0x48 ); -if (temp <=2 ) - temp &=0x03 ; -else +if (temp >2 ) temp = ((temp &0x04 ) >>1 ) | ((~temp) &0x01 );xgifb_reg_set (pVBInfo->P3d4,0x4A ,CR4A );
Signature · 1 line
1.8.1.5
PATCH 5/5 staging/xgifb: Fix always false condition in vb_setmode.c (smatch)
In reply to Peter HueweSmatch complains:drivers/staging/xgifb/vb_setmode.c:3181 XGI_SetLockRegs() warn: bitwise AND condition is false here
Since SetNTSCTV is defined as 0 in drivers/video/sis/initdef.h this is correct.
-> Change the condition to == to fix this.
--- drivers/staging/xgifb/vb_setmode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/xgifb/vb_setmode.c +1 -1
@@ -3178,7 +3178,7 @@ static void XGI_SetLockRegs(unsigned short ModeNo, unsigned short ModeIdIndex,if (pVBInfo->VBInfo & SetCRT2ToTV) {if (pVBInfo->TVInfo & TVSimuMode) {if (ModeNo ==0x50 ) { -if (pVBInfo->TVInfo & SetNTSCTV) { +if (pVBInfo->TVInfo == SetNTSCTV) {xgifb_reg_set (pVBInfo->Part1Port,0x07 ,0x30 ); xgifb_reg_set(pVBInfo->Part1Port,
Signature · 1 line
1.8.1.5