cleanup of xgifb/vb_setmode.c
v4 cover cleanup of xgifb/vb_setmode.c
The following patchset contains patches to make the code more readable. This patchset fixes various issues that come up in the checkpatch in patch 1, 3, 4 and 5. Patches 2 and 6 are based on Julia's suggestion when a one patch was sent fixing the checkpatch issue of moving && operator to previous line.
---
Changes since v3:
fix commit messages in patches 2, 3 and 5 which exceeded 80 characters. Also, reworded patch 6 commit to explain the solution more clearly.
Changes since v2:
reword commit messages in all patches to explain the solution and using imperative form for the commit subject.
Changes since v1:
made a patchset instead of a patch to fix various readability issues in the code.
Gargi Sharma (6):
staging: xgifb: move AND operator for logical continuation
staging: xgifb: remove unnecessary parentheses
staging: xgifb: remove blank line after open brace
staging: xgifb: add spaces around |
staging: xgifb: remove blank line before closing brace
staging: xgifb: fix alignment for if arguments
drivers/staging/xgifb/vb_setmode.c | 48 ++++++++++++++------------------------ 1 file changed, 17 insertions(+), 31 deletions(-)
Signature · 1 line
2.9.2
PATCH v4 1/6 staging: xgifb: move AND operator for logical continuation
Move && up to the previous line, to fix the checkpatch issue Logical continuations should be on the previous line.
--- drivers/staging/xgifb/vb_setmode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/xgifb/vb_setmode.c +4 -4
@@ -1741,8 +1741,8 @@ static void XGI_SetCRT2ECLK(unsigned short ModeIdIndex,for (i =0 ; i <4 ; i++) {xgifb_reg_and_or (pVBInfo->P3d4,0x31 , ~0x30 , (unsigned short ) (0x10 * i)); -if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) - && (!(pVBInfo->VBInfo & SetInSlaveMode))) { +if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && + (!(pVBInfo->VBInfo & SetInSlaveMode))) {xgifb_reg_set (pVBInfo->P3c4,0x2e , di_0);xgifb_reg_set (pVBInfo->P3c4,0x2f , di_1); }else {
@@ -4141,8 +4141,8 @@ static void XGI_SetGroup4(unsigned short ModeIdIndex, | TVSetYPbPr525p | TVSetYPbPr750p | TVSetHiVision))) { temp |=0x0001 ; -if ((pVBInfo->VBInfo & SetInSlaveMode) - && (!(pVBInfo->TVInfo +if ((pVBInfo->VBInfo & SetInSlaveMode) && + (!(pVBInfo->TVInfo & TVSimuMode))) temp &= (~0x0001 ); }
Signature · 1 line
2.9.2
PATCH v4 2/6 staging: xgifb: remove unnecessary parentheses
In reply to Gargi Sharma! has higher priority than && or ||, so remove parentheses around ! expressions to make the code more readable.
--- drivers/staging/xgifb/vb_setmode.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/staging/xgifb/vb_setmode.c +16 -16
@@ -214,7 +214,7 @@ static unsigned char XGI_AjustCRT2Rate(unsigned short ModeIdIndex,if (!(pVBInfo->VBInfo & TVSetPAL) && (modeflag & NoSupportSimuTV) && (pVBInfo->VBInfo & SetInSlaveMode) && - (!(pVBInfo->VBInfo & SetNotSimuMode))) + !(pVBInfo->VBInfo & SetNotSimuMode))return 0 ; }
@@ -1655,7 +1655,7 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex, modeflag = XGI330_EModeIDTable[ModeIdIndex].Ext_ModeFlag;if ((pVBInfo->SetFlag & ProgrammingCRT2) && - (!(pVBInfo->LCDInfo & EnableScalingLCD))) {/* {LCDA/LCDB} */ + !(pVBInfo->LCDInfo & EnableScalingLCD)) {/* {LCDA/LCDB} */ index =XGI_GetLCDCapPtr (pVBInfo); tempal = pVBInfo->LCDCapList[index].LCD_VCLK;
@@ -1716,7 +1716,7 @@ static void XGI_GetVCLKLen(unsigned char tempal, unsigned char *di_0, {if (pVBInfo->VBType & (VB_SIS301 |VB_SIS301B |VB_SIS302B |VB_SIS301LV |VB_SIS302LV |VB_XGI301C )) { -if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && +if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && (pVBInfo->SetFlag & ProgrammingCRT2)) { *di_0 = XGI_VBVCLKData[tempal].Part4_A; *di_1 = XGI_VBVCLKData[tempal].Part4_B;
@@ -1741,8 +1741,8 @@ static void XGI_SetCRT2ECLK(unsigned short ModeIdIndex,for (i =0 ; i <4 ; i++) {xgifb_reg_and_or (pVBInfo->P3d4,0x31 , ~0x30 , (unsigned short ) (0x10 * i)); -if ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && - (!(pVBInfo->VBInfo & SetInSlaveMode))) { +if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && + !(pVBInfo->VBInfo & SetInSlaveMode)) {xgifb_reg_set (pVBInfo->P3c4,0x2e , di_0);xgifb_reg_set (pVBInfo->P3c4,0x2f , di_1); }else {
@@ -1986,7 +1986,7 @@ static void XGI_GetVBInfo(unsigned short ModeIdIndex, }if (!(tempbx & DisableCRT2Display)) { -if ((!(tempbx & DriverMode)) || (!(modeflag & CRT2Mode))) { +if (!(tempbx & DriverMode) || !(modeflag & CRT2Mode)) {if (!(tempbx & XGI_SetCRT2ToLCDA)) tempbx |= (SetInSlaveMode | SetSimuScanMode); }
@@ -2132,7 +2132,7 @@ static unsigned char XGI_GetLCDInfo(unsigned short ModeIdIndex,if ((pVBInfo->LCDResInfo == Panel_1400x1050) && (pVBInfo->VBInfo & SetCRT2ToLCD) && (resinfo ==9 ) && - (!(tempbx & EnableScalingLCD))) + !(tempbx & EnableScalingLCD))/* * set to center in 1280x1024 LCDB * for Panel_1400x1050
@@ -3922,7 +3922,7 @@ static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo)xgifb_reg_set (pVBInfo->Part2Port, i, Tap4TimingPtr->Reg[j]);if ((pVBInfo->VBInfo & SetCRT2ToTV) && - (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) { + !(pVBInfo->VBInfo & SetCRT2ToHiVision)) {/* Set Vertical Scaling */ Tap4TimingPtr =XGI_GetTap4Ptr (1 , pVBInfo);for (i =0xC0 , j =0 ; i <0xFF ; i++, j++)
@@ -3932,7 +3932,7 @@ static void XGI_SetTap4Regs(struct vb_device_info *pVBInfo) }if ((pVBInfo->VBInfo & SetCRT2ToTV) && - (!(pVBInfo->VBInfo & SetCRT2ToHiVision))) + !(pVBInfo->VBInfo & SetCRT2ToHiVision))/* Enable V.Scaling */ xgifb_reg_and_or (pVBInfo->Part2Port,0x4E , ~0x14 ,0x04 );else
@@ -4142,8 +4142,8 @@ static void XGI_SetGroup4(unsigned short ModeIdIndex, | TVSetHiVision))) { temp |=0x0001 ;if ((pVBInfo->VBInfo & SetInSlaveMode) && - (!(pVBInfo->TVInfo - & TVSimuMode))) + !(pVBInfo->TVInfo + & TVSimuMode)) temp &= (~0x0001 ); } }
@@ -4476,7 +4476,7 @@ static void XGI_DisableBridge(struct xgifb_video_info *xgifb_info,if ((pVBInfo->VBInfo & (DisableCRT2Display | SetSimuScanMode)) || - ((!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA)) && + (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToLCD | SetCRT2ToTV))))xgifb_reg_or (pVBInfo->Part1Port,0x00 ,0x80 );
@@ -4587,7 +4587,7 @@ static void XGI_GetTVPtrIndex2(unsigned short *tempbx, unsigned char *tempcl,if (pVBInfo->VBType & (VB_SIS301B |VB_SIS302B |VB_SIS301LV |VB_SIS302LV |VB_XGI301C )) { -if ((!(pVBInfo->VBInfo & SetInSlaveMode)) || (pVBInfo->TVInfo +if (!(pVBInfo->VBInfo & SetInSlaveMode) || (pVBInfo->TVInfo & TVSimuMode)) { *tempbx +=8 ; *tempcl +=1 ;
@@ -4988,8 +4988,8 @@ reg_and_or:if (pVBInfo->VBInfo & (SetCRT2ToRAMDAC | SetCRT2ToTV | SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) { tempah &= (~0x08 ); -if ((pVBInfo->ModeType == ModeVGA) && (!(pVBInfo->VBInfo - & SetInSlaveMode))) { +if ((pVBInfo->ModeType == ModeVGA) && !(pVBInfo->VBInfo + & SetInSlaveMode)) { tempah |=0x010 ; } tempah |=0x080 ;
@@ -5486,7 +5486,7 @@ unsigned char XGISetModeNew(struct xgifb_video_info *xgifb_info,XGI_DisableBridge (xgifb_info, HwDeviceExtension, pVBInfo);if (pVBInfo->VBInfo & (SetSimuScanMode | XGI_SetCRT2ToLCDA) || - (!(pVBInfo->VBInfo & SwitchCRT2))) { + !(pVBInfo->VBInfo & SwitchCRT2)) {XGI_SetCRT1Group (xgifb_info, HwDeviceExtension, ModeNo, ModeIdIndex, pVBInfo);
Signature · 1 line
2.9.2
PATCH v4 3/6 staging: xgifb: remove blank line after open brace
In reply to Gargi Sharmadelete a blank line after an open brace to fix the check patch issue, Blank lines aren't necessary after an open brace '{'.
--- drivers/staging/xgifb/vb_setmode.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/staging/xgifb/vb_setmode.c +0 -6
@@ -1647,7 +1647,6 @@ static void XGI_GetLCDVCLKPtr(unsigned char *di_0, unsigned char *di_1,static unsigned char XGI_GetVCLKPtr (unsigned short RefreshRateTableIndex,unsigned short ModeIdIndex,struct vb_device_info *pVBInfo) { -unsigned short index, modeflag;unsigned char tempal;
@@ -2291,7 +2290,6 @@ static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info,struct xgi_hw_device_info *pXGIHWDE, struct vb_device_info *pVBInfo) { - xgifb_reg_and_or(pVBInfo->P3c4, 0x01, 0xDF, 0x00);if (pXGIHWDE->jChipType ==XG21 ) {if (pVBInfo->IF_DEF_LVDS ==1 ) {
@@ -2338,7 +2336,6 @@ void XGI_DisplayOff(struct xgifb_video_info *xgifb_info, struct xgi_hw_device_info *pXGIHWDE, struct vb_device_info *pVBInfo) { -if (pXGIHWDE->jChipType ==XG21 ) {if (pVBInfo->IF_DEF_LVDS ==1 ) {/* LVDS backlight off */
@@ -2455,7 +2452,6 @@ exit:static unsigned char XGI_IsLCDDualLink (struct vb_device_info *pVBInfo) { -if ((pVBInfo->VBInfo & (SetCRT2ToLCD | XGI_SetCRT2ToLCDA)) && (pVBInfo->LCDInfo & SetLCDDualLink))/* shampoo0129 */ return 1 ;
@@ -4389,7 +4385,6 @@ static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info, (value << 2) & 0x7C);for (temp =0 , value =0 ; temp <3 ; temp++) { -xgifb_reg_and_or (pVBInfo->P3c4,0x31 , ~0x30 , value);xgifb_reg_set (pVBInfo->P3c4,0x2B , xgifb_info->lvds_data.VCLKData1);
@@ -5416,7 +5411,6 @@ static void XGI_SetCRT1Group(struct xgifb_video_info *xgifb_info,if (HwDeviceExtension->jChipType >=XG21 ) { temp =xgifb_reg_get (pVBInfo->P3d4,0x38 );if (temp &0xA0 ) { -if (HwDeviceExtension->jChipType ==XG27 )XGI_SetXG27CRTC (RefreshRateTableIndex, pVBInfo);else
Signature · 1 line
2.9.2
PATCH v4 4/6 staging: xgifb: add spaces around |
In reply to Gargi Sharmainsert spaces around '|' to fix the checkpatch issue spaces preferred around that '|'.
--- drivers/staging/xgifb/vb_setmode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/xgifb/vb_setmode.c +1 -1
@@ -1914,7 +1914,7 @@ static void XGI_GetVBInfo(unsigned short ModeIdIndex, } } -if (pVBInfo->VBType & (VB_SIS301LV |VB_SIS302LV |VB_XGI301C )) { +if (pVBInfo->VBType & (VB_SIS301LV |VB_SIS302LV |VB_XGI301C )) {if (temp & SetYPbPr) {/* shampoo add for new scratch */ temp =xgifb_reg_get (pVBInfo->P3d4,0x35 );
Signature · 1 line
2.9.2
PATCH v4 5/6 staging: xgifb: remove blank line before closing brace
In reply to Gargi Sharmadelete blank line before '}' to fix the checkpatch issue Blank lines aren't necessary before a closing brace '}'.
--- drivers/staging/xgifb/vb_setmode.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/staging/xgifb/vb_setmode.c +0 -7
@@ -1677,7 +1677,6 @@ static unsigned char XGI_GetVCLKPtr(unsigned short RefreshRateTableIndex,if (!(modeflag & Charx8Dot)) tempal =TVCLKBASE_315 + HiTVTextVCLK; - }return tempal; }
@@ -2244,7 +2243,6 @@ static void XGI_XG21BLSignalVDD(unsigned short tempbh, unsigned short tempbl,/* CR B4[1] */ xgifb_reg_and_or (pVBInfo->P3d4,0xB4 , ~0x02 , temp); - } temp =xgifb_reg_get (pVBInfo->P3d4,0x48 );
@@ -2273,7 +2271,6 @@ static void XGI_XG27BLSignalVDD(unsigned short tempbh, unsigned short tempbl,/* CR B4[1] */ xgifb_reg_and_or (pVBInfo->P3d4,0xB4 , ~0x02 , temp); - }xgifb_reg_and_or (pVBInfo->P3d4,0xB4 , ~tempbh0, tempbl0);
@@ -2308,7 +2305,6 @@ static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info,/* DVO/DVI signal on */ XGI_XG21BLSignalVDD (0x20 ,0x20 , pVBInfo); } - }if (pXGIHWDE->jChipType ==XG27 ) {
@@ -2328,7 +2324,6 @@ static void XGI_DisplayOn(struct xgifb_video_info *xgifb_info,/* DVO/DVI signal on */ XGI_XG27BLSignalVDD (0x20 ,0x20 , pVBInfo); } - } }
@@ -4128,7 +4123,6 @@ static void XGI_SetGroup4(unsigned short ModeIdIndex,if (pVBInfo->VBInfo & (SetCRT2ToTV | SetCRT2ToHiVision)) {if (pVBInfo->VGAHDE >800 )xgifb_reg_or (pVBInfo->Part4Port,0x1E ,0x08 ); - } temp =0x0036 ;
@@ -4404,7 +4398,6 @@ static void xgifb_set_lvds(struct xgifb_video_info *xgifb_info,inb (pVBInfo->P3da);/* reset 3da */ } - }/* --------------------------------------------------------------------- */
Signature · 1 line
2.9.2
PATCH v4 6/6 staging: xgifb: fix alignment for if arguments
In reply to Gargi SharmaReduce indentation of multi-line if-test
arguments for better readability.
--- drivers/staging/xgifb/vb_setmode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/xgifb/vb_setmode.c +2 -3
@@ -1740,7 +1740,7 @@ static void XGI_SetCRT2ECLK(unsigned short ModeIdIndex,xgifb_reg_and_or (pVBInfo->P3d4,0x31 , ~0x30 , (unsigned short ) (0x10 * i));if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && - !(pVBInfo->VBInfo & SetInSlaveMode)) { + !(pVBInfo->VBInfo & SetInSlaveMode)) {xgifb_reg_set (pVBInfo->P3c4,0x2e , di_0);xgifb_reg_set (pVBInfo->P3c4,0x2f , di_1); }else {
@@ -4132,8 +4132,7 @@ static void XGI_SetGroup4(unsigned short ModeIdIndex, | TVSetHiVision))) { temp |=0x0001 ;if ((pVBInfo->VBInfo & SetInSlaveMode) && - !(pVBInfo->TVInfo - & TVSimuMode)) + !(pVBInfo->TVInfo & TVSimuMode)) temp &= (~0x0001 ); } }
Signature · 1 line
2.9.2
Re: [Outreachy kernel] [PATCH v4 6/6] staging: xgifb: fix alignment for if arguments
Quoted 2 lines · Gargi Sharma
Reduce indentation of multi-line if-test
arguments for better readability.
You can use more horizontal space for the commit message. Just don't go over 80 characters.
Quoted 11 lines
Signed-off-by Gargi Sharma <[email protected]>--- drivers/staging/xgifb/vb_setmode.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/staging/xgifb/vb_setmode.c +0
-0
drivers/staging/xgifb/vb_setmode.c static void XGI_SetCRT2ECLK(unsigned short ModeIdIndex, · line 1743
Quoted 5 lines
drivers/staging/xgifb/vb_setmode.c +1
-1@@ -1740,7 +1740,7 @@ static void XGI_SetCRT2ECLK(unsigned short ModeIdIndex,xgifb_reg_and_or (pVBInfo->P3d4,0x31 , ~0x30 , (unsigned short ) (0x10 * i));if (!(pVBInfo->VBInfo & XGI_SetCRT2ToLCDA) && - !(pVBInfo->VBInfo & SetInSlaveMode)) { + !(pVBInfo->VBInfo & SetInSlaveMode)) {
Actually, this doesn't work out so well, because now the test is lined up with the then branch, and one may misread it. Could you pull the second part of the test back to be aligned with the first part? It's ok to use spaces rather than tabs at the end, if this is needed.
julia
Quoted 23 lines
drivers/staging/xgifb/vb_setmode.c +1
-3xgifb_reg_set (pVBInfo->P3c4,0x2e , di_0);xgifb_reg_set (pVBInfo->P3c4,0x2f , di_1); }else {@@ -4132,8 +4132,7 @@ static void XGI_SetGroup4(unsigned short ModeIdIndex, | TVSetHiVision))) { temp |=0x0001 ;if ((pVBInfo->VBInfo & SetInSlaveMode) && - !(pVBInfo->TVInfo - & TVSimuMode)) + !(pVBInfo->TVInfo & TVSimuMode)) temp &= (~0x0001 ); } } --2.9.2
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/940f51ac0ff58da6ff9a9b7b296ef8cfdda8907d.1473942527.git.gs051095%40gmail.com.
For more options, visit https://groups.google.com/d/optout.