Skip to contentSkip to conversation

Staging: sm750fb: Remove an unnecessary local variable in a function

PATCH In review Madhumitha Prabakaran 2 participants 4 messages Mar 13, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: sm750fb: Remove an unnecessary local variable in a function

Remove an unnecessary local variable in sm750_format_pll_reg function and replace its initialization directly in return type. Issue suggested by Coccinelle using ret.cocci.

---
 drivers/staging/sm750fb/ddk750_chip.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/sm750fb/ddk750_chip.c +1 -4
index 90f5480304f4..93abfa8b0090 100644
@@ -391,7 +391,6 @@ unsigned int sm750_format_pll_reg(struct pll_value *pPLL)
 	unsigned int OD = pPLL->OD;
 	unsigned int M = pPLL->M;
 	unsigned int N = pPLL->N;
-	unsigned int reg = 0;
 
 	/*
 	 * Note that all PLL's have the same format. Here, we just use
@@ -399,13 +398,11 @@ unsigned int sm750_format_pll_reg(struct pll_value *pPLL)
 	 * register. On returning a 32 bit number, the value can be
 	 * applied to any PLL in the calling function.
 	 */
-	reg = PLL_CTRL_POWER |
+	return PLL_CTRL_POWER |
 #ifndef VALIDATION_CHIP
 		((POD << PLL_CTRL_POD_SHIFT) & PLL_CTRL_POD_MASK) |
 #endif
 		((OD << PLL_CTRL_OD_SHIFT) & PLL_CTRL_OD_MASK) |
 		((N << PLL_CTRL_N_SHIFT) & PLL_CTRL_N_MASK) |
 		((M << PLL_CTRL_M_SHIFT) & PLL_CTRL_M_MASK);
-
-	return reg;
 }
Signature · 1 line
2.17.1
#1 lore raw
Quoted 25 lines · Madhumitha Prabakaran

Remove an unnecessary local variable in sm750_format_pll_reg function and replace its initialization directly in return type. Issue suggested by Coccinelle using ret.cocci.

---
 drivers/staging/sm750fb/ddk750_chip.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/sm750fb/ddk750_chip.c +0 -1
index 90f5480304f4..93abfa8b0090 100644
@@ -391,7 +391,6 @@ unsigned int sm750_format_pll_reg(struct pll_value *pPLL)
 	unsigned int OD = pPLL->OD;
 	unsigned int M = pPLL->M;
 	unsigned int N = pPLL->N;
-	unsigned int reg = 0;
 
 	/*
 	 * Note that all PLL's have the same format. Here, we just use
@@ -399,13 +398,11 @@ unsigned int sm750_format_pll_reg(struct pll_value *pPLL)
 	 * register. On returning a 32 bit number, the value can be
 	 * applied to any PLL in the calling function.
 	 */

drivers/staging/sm750fb/ddk750_chip.c unsigned int sm750_format_pll_reg(struct pll_value *pPLL) · line 410

Quoted 10 lines
drivers/staging/sm750fb/ddk750_chip.c +1 -3
-	reg = PLL_CTRL_POWER |
+	return PLL_CTRL_POWER |
 #ifndef VALIDATION_CHIP
 		((POD << PLL_CTRL_POD_SHIFT) & PLL_CTRL_POD_MASK) |
 #endif
 		((OD << PLL_CTRL_OD_SHIFT) & PLL_CTRL_OD_MASK) |
 		((N << PLL_CTRL_N_SHIFT) & PLL_CTRL_N_MASK) |
 		((M << PLL_CTRL_M_SHIFT) & PLL_CTRL_M_MASK);
-
-	return reg;

This is going better in the right direction. But maybe it is less readable than before, with that very large expression and the ifndef...

julia

Quoted 11 lines
drivers/staging/sm750fb/ddk750_chip.c +0 -1
 }
--

2.17.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/20190313153205.4974-1-madhumithabiw%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 49 lines · Julia Lawall
Quoted 25 lines · Madhumitha Prabakaran

Remove an unnecessary local variable in sm750_format_pll_reg function and replace its initialization directly in return type. Issue suggested by Coccinelle using ret.cocci.

---
 drivers/staging/sm750fb/ddk750_chip.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/sm750fb/ddk750_chip.c +0 -1
index 90f5480304f4..93abfa8b0090 100644
@@ -391,7 +391,6 @@ unsigned int sm750_format_pll_reg(struct pll_value *pPLL)
 	unsigned int OD = pPLL->OD;
 	unsigned int M = pPLL->M;
 	unsigned int N = pPLL->N;
-	unsigned int reg = 0;
 
 	/*
 	 * Note that all PLL's have the same format. Here, we just use
@@ -399,13 +398,11 @@ unsigned int sm750_format_pll_reg(struct pll_value *pPLL)
 	 * register. On returning a 32 bit number, the value can be
 	 * applied to any PLL in the calling function.
 	 */

drivers/staging/sm750fb/ddk750_chip.c unsigned int sm750_format_pll_reg(struct pll_value *pPLL) · line 410

Quoted 10 lines
drivers/staging/sm750fb/ddk750_chip.c +1 -3
-	reg = PLL_CTRL_POWER |
+	return PLL_CTRL_POWER |
 #ifndef VALIDATION_CHIP
 		((POD << PLL_CTRL_POD_SHIFT) & PLL_CTRL_POD_MASK) |
 #endif
 		((OD << PLL_CTRL_OD_SHIFT) & PLL_CTRL_OD_MASK) |
 		((N << PLL_CTRL_N_SHIFT) & PLL_CTRL_N_MASK) |
 		((M << PLL_CTRL_M_SHIFT) & PLL_CTRL_M_MASK);
-
-	return reg;

This is going better in the right direction. But maybe it is less readable than before, with that very large expression and the ifndef...

julia

Quoted 4 lines
drivers/staging/sm750fb/ddk750_chip.c +0 -1
 }
--

2.17.1

Quoted 14 lines
Quoted 7 lines

--
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/20190313153205.4974-1-madhumithabiw%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Signature · 5 lines
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/alpine.DEB.2.20.1903131634500.27312%40hadrien.
For more options, visit https://groups.google.com/d/optout.

Do you want me to drop this? As the previous code is more readable than this one.

thanks,
Madhumitha

#3 lore raw
Quoted 58 lines · Madhumthia Prabakaran
Quoted 57 lines · Julia Lawall
Quoted 25 lines · Madhumitha Prabakaran

Remove an unnecessary local variable in sm750_format_pll_reg function and replace its initialization directly in return type. Issue suggested by Coccinelle using ret.cocci.

---
 drivers/staging/sm750fb/ddk750_chip.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/staging/sm750fb/ddk750_chip.c +0 -1
index 90f5480304f4..93abfa8b0090 100644
@@ -391,7 +391,6 @@ unsigned int sm750_format_pll_reg(struct pll_value *pPLL)
 	unsigned int OD = pPLL->OD;
 	unsigned int M = pPLL->M;
 	unsigned int N = pPLL->N;
-	unsigned int reg = 0;
 
 	/*
 	 * Note that all PLL's have the same format. Here, we just use
@@ -399,13 +398,11 @@ unsigned int sm750_format_pll_reg(struct pll_value *pPLL)
 	 * register. On returning a 32 bit number, the value can be
 	 * applied to any PLL in the calling function.
 	 */

drivers/staging/sm750fb/ddk750_chip.c unsigned int sm750_format_pll_reg(struct pll_value *pPLL) · line 410

Quoted 10 lines
drivers/staging/sm750fb/ddk750_chip.c +1 -3
-	reg = PLL_CTRL_POWER |
+	return PLL_CTRL_POWER |
 #ifndef VALIDATION_CHIP
 		((POD << PLL_CTRL_POD_SHIFT) & PLL_CTRL_POD_MASK) |
 #endif
 		((OD << PLL_CTRL_OD_SHIFT) & PLL_CTRL_OD_MASK) |
 		((N << PLL_CTRL_N_SHIFT) & PLL_CTRL_N_MASK) |
 		((M << PLL_CTRL_M_SHIFT) & PLL_CTRL_M_MASK);
-
-	return reg;

This is going better in the right direction. But maybe it is less readable than before, with that very large expression and the ifndef...

julia

Quoted 11 lines
drivers/staging/sm750fb/ddk750_chip.c +0 -1
 }
--

2.17.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/20190313153205.4974-1-madhumithabiw%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Quoted 8 lines
Quoted 6 lines

--
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/alpine.DEB.2.20.1903131634500.27312%40hadrien.
For more options, visit https://groups.google.com/d/optout.

Do you want me to drop this? As the previous code is more readable than this one.

I don't know. Greg decides...

julia