Skip to contentSkip to conversation

Staging: xgifb: Use shorthand operator

PATCH In review Bhumika Goyal 3 participants 4 messages Feb 9, 2016 – Feb 12, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: xgifb: Use shorthand operator

Use shorthand operator for assignment statement to make code look cleaner. Made a coccinelle script for this and did changes.
@@
identifier data;
constant x;
@@

(
- data = data + x
+ data += x
|
- data = data - x
+ data -= x
)

---
 drivers/staging/xgifb/vb_setmode.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/xgifb/vb_setmode.c +6 -6
index de96da1..0daa661 100644
@@ -289,7 +289,7 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
 
 	if (HwDeviceExtension->jChipType >= XG20) {
 		data = xgifb_reg_get(pVBInfo->P3d4, 0x04);
-		data = data - 1;
+		data -= 1;
 		xgifb_reg_set(pVBInfo->P3d4, 0x04, data);
 		data = xgifb_reg_get(pVBInfo->P3d4, 0x05);
 		data1 = data;
@@ -302,14 +302,14 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
 			xgifb_reg_set(pVBInfo->P3c4, 0x0c, data);
 			data = pushax;
 		}
-		data = data - 1;
+		data -= 1;
 		data |= data1;
 		xgifb_reg_set(pVBInfo->P3d4, 0x05, data);
 		data = xgifb_reg_get(pVBInfo->P3c4, 0x0e);
 		data >>= 5;
-		data = data + 3;
+		data += 3;
 		if (data > 7)
-			data = data - 7;
+			data -= 7;
 		data <<= 5;
 		xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data);
 	}
@@ -3394,9 +3394,9 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
 	xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp);
 
 	tempbx = push2;
-	tempbx = tempbx + 8;
+	tempbx += 8;
 	if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
-		tempbx = tempbx - 4;
+		tempbx -= 4;
 		tempcx = tempbx;
 	}
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 5 lines · Bhumika Goyal

Use shorthand operator for assignment statement to make code look cleaner. Made a coccinelle script for this and did changes.
@@
identifier data;
constant x;

I don't think that the constant constraint is technically necessary. But perhaps it is the case in which the simplification does seem useful.

julia

Quoted 68 lines

@@

(
- data = data + x
+ data += x
|
- data = data - x
+ data -= x
)

---
 drivers/staging/xgifb/vb_setmode.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/xgifb/vb_setmode.c +6 -7
index de96da1..0daa661 100644
@@ -289,7 +289,7 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
 
 	if (HwDeviceExtension->jChipType >= XG20) {
 		data = xgifb_reg_get(pVBInfo->P3d4, 0x04);
-		data = data - 1;
+		data -= 1;
 		xgifb_reg_set(pVBInfo->P3d4, 0x04, data);
 		data = xgifb_reg_get(pVBInfo->P3d4, 0x05);
 		data1 = data;
@@ -302,14 +302,14 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
 			xgifb_reg_set(pVBInfo->P3c4, 0x0c, data);
 			data = pushax;
 		}
-		data = data - 1;
+		data -= 1;
 		data |= data1;
 		xgifb_reg_set(pVBInfo->P3d4, 0x05, data);
 		data = xgifb_reg_get(pVBInfo->P3c4, 0x0e);
 		data >>= 5;
-		data = data + 3;
+		data += 3;
 		if (data > 7)
-			data = data - 7;
+			data -= 7;
 		data <<= 5;
 		xgifb_reg_and_or(pVBInfo->P3c4, 0x0e, ~0xE0, data);
 	}
@@ -3394,9 +3394,9 @@ static void XGI_SetGroup2(unsigned short ModeNo, unsigned short ModeIdIndex,
 	xgifb_reg_and_or(pVBInfo->Part2Port, 0x25, 0x0F, temp);
 
 	tempbx = push2;
-	tempbx = tempbx + 8;
+	tempbx += 8;
 	if (pVBInfo->VBInfo & SetCRT2ToHiVision) {
-		tempbx = tempbx - 4;
+		tempbx -= 4;
 		tempcx = tempbx;
 	}
 
--

1.9.1

--
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/1455033333-31657-1-git-send-email-bhumirks%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw

Hey Julia ,
Is my approach for this script correct or it can further be simplified?

Thanks,
Bhumika

maintainer
#3 lore raw
In reply to Bhumika Goyal
Quoted 25 lines · Bhumika Goyal

Use shorthand operator for assignment statement to make code look cleaner. Made a coccinelle script for this and did changes.
@@
identifier data;
constant x;
@@

(
- data = data + x
+ data += x
|
- data = data - x
+ data -= x
)

---
 drivers/staging/xgifb/vb_setmode.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/xgifb/vb_setmode.c +0 -0
index de96da1..0daa661 100644

drivers/staging/xgifb/vb_setmode.c static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo, · line 292

Quoted 5 lines
drivers/staging/xgifb/vb_setmode.c +1 -1
@@ -289,7 +289,7 @@ static void XGI_SetCRT1Timing_H(struct vb_device_info *pVBInfo,
 
 	if (HwDeviceExtension->jChipType >= XG20) {
 		data = xgifb_reg_get(pVBInfo->P3d4, 0x04);
-		data = data - 1;
+		data -= 1;

Sorry, I'm not going to take these kinds of "cleanups" anymore, they aren't doing much...

greg k-h