* [PATCH 0/2] staging: vt6656: Refactor the vnt_vt3184_init function
@ 2020-04-11 12:51 ` Oscar Carter
0 siblings, 0 replies; 6+ messages in thread
From: Oscar Carter @ 2020-04-11 12:51 UTC (permalink / raw)
To: Forest Bond, Greg Kroah-Hartman
Cc: Oscar Carter, Malcolm Priestley, Quentin Deslandes,
Amir Mahdi Ghorbanian, devel, linux-kernel
This patch series makes a refactor of the vnt_vt3184_init function through
two patches.
The first one removes duplicate code in the if statements because
different branches are almost the same.
The second patch remove unnecessary local variable initialization.
Oscar Carter (2):
staging: vt6656: Remove duplicate code in vnt_vt3184_init function
staging: vt6656: Remove unnecessary local variable initialization
drivers/staging/vt6656/baseband.c | 54 ++++++++-----------------------
1 file changed, 13 insertions(+), 41 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 0/2] staging: vt6656: Refactor the vnt_vt3184_init function
@ 2020-04-11 12:51 ` Oscar Carter
0 siblings, 0 replies; 6+ messages in thread
From: Oscar Carter @ 2020-04-11 12:51 UTC (permalink / raw)
To: Forest Bond, Greg Kroah-Hartman
Cc: devel, Oscar Carter, Malcolm Priestley, linux-kernel
This patch series makes a refactor of the vnt_vt3184_init function through
two patches.
The first one removes duplicate code in the if statements because
different branches are almost the same.
The second patch remove unnecessary local variable initialization.
Oscar Carter (2):
staging: vt6656: Remove duplicate code in vnt_vt3184_init function
staging: vt6656: Remove unnecessary local variable initialization
drivers/staging/vt6656/baseband.c | 54 ++++++++-----------------------
1 file changed, 13 insertions(+), 41 deletions(-)
--
2.20.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] staging: vt6656: Remove duplicate code in vnt_vt3184_init function
2020-04-11 12:51 ` Oscar Carter
@ 2020-04-11 12:51 ` Oscar Carter
-1 siblings, 0 replies; 6+ messages in thread
From: Oscar Carter @ 2020-04-11 12:51 UTC (permalink / raw)
To: Forest Bond, Greg Kroah-Hartman
Cc: Oscar Carter, Malcolm Priestley, Quentin Deslandes,
Amir Mahdi Ghorbanian, devel, linux-kernel
Remove duplicate code in "if" statements because different branches are
almost the same.
Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
---
drivers/staging/vt6656/baseband.c | 52 +++++++------------------------
1 file changed, 12 insertions(+), 40 deletions(-)
diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
index a19a563d8bcc..276210a7284e 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -366,23 +366,15 @@ int vnt_vt3184_init(struct vnt_private *priv)
dev_dbg(&priv->usb->dev, "RF Type %d\n", priv->rf_type);
- if (priv->rf_type == RF_AL2230 ||
- priv->rf_type == RF_AL2230S) {
+ if ((priv->rf_type == RF_AL2230) ||
+ (priv->rf_type == RF_AL2230S) ||
+ (priv->rf_type == RF_AIROHA7230)) {
priv->bb_rx_conf = vnt_vt3184_al2230[10];
length = sizeof(vnt_vt3184_al2230);
addr = vnt_vt3184_al2230;
- priv->bb_vga[0] = 0x1C;
- priv->bb_vga[1] = 0x10;
- priv->bb_vga[2] = 0x0;
- priv->bb_vga[3] = 0x0;
-
- } else if (priv->rf_type == RF_AIROHA7230) {
- priv->bb_rx_conf = vnt_vt3184_al2230[10];
- length = sizeof(vnt_vt3184_al2230);
- addr = vnt_vt3184_al2230;
-
- addr[0xd7] = 0x06;
+ if (priv->rf_type == RF_AIROHA7230)
+ addr[0xd7] = 0x06;
priv->bb_vga[0] = 0x1c;
priv->bb_vga[1] = 0x10;
@@ -390,22 +382,8 @@ int vnt_vt3184_init(struct vnt_private *priv)
priv->bb_vga[3] = 0x0;
} else if ((priv->rf_type == RF_VT3226) ||
- (priv->rf_type == RF_VT3226D0)) {
- priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
- length = sizeof(vnt_vt3184_vt3226d0);
- addr = vnt_vt3184_vt3226d0;
-
- priv->bb_vga[0] = 0x20;
- priv->bb_vga[1] = 0x10;
- priv->bb_vga[2] = 0x0;
- priv->bb_vga[3] = 0x0;
-
- /* Fix VT3226 DFC system timing issue */
- ret = vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2,
- SOFTPWRCTL_RFLEOPT);
- if (ret)
- goto end;
- } else if (priv->rf_type == RF_VT3342A0) {
+ (priv->rf_type == RF_VT3226D0) ||
+ (priv->rf_type == RF_VT3342A0)) {
priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
length = sizeof(vnt_vt3184_vt3226d0);
addr = vnt_vt3184_vt3226d0;
@@ -435,19 +413,13 @@ int vnt_vt3184_init(struct vnt_private *priv)
if (ret)
goto end;
- if (priv->rf_type == RF_VT3226 ||
- priv->rf_type == RF_VT3342A0) {
- ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
- MAC_REG_ITRTMSET, 0x23);
- if (ret)
- goto end;
+ if ((priv->rf_type == RF_VT3226) ||
+ (priv->rf_type == RF_VT3342A0) ||
+ (priv->rf_type == RF_VT3226D0)) {
+ data = (priv->rf_type == RF_VT3226D0) ? 0x11 : 0x23;
- ret = vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, BIT(0));
- if (ret)
- goto end;
- } else if (priv->rf_type == RF_VT3226D0) {
ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
- MAC_REG_ITRTMSET, 0x11);
+ MAC_REG_ITRTMSET, data);
if (ret)
goto end;
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/2] staging: vt6656: Remove duplicate code in vnt_vt3184_init function
@ 2020-04-11 12:51 ` Oscar Carter
0 siblings, 0 replies; 6+ messages in thread
From: Oscar Carter @ 2020-04-11 12:51 UTC (permalink / raw)
To: Forest Bond, Greg Kroah-Hartman
Cc: devel, Oscar Carter, Malcolm Priestley, linux-kernel
Remove duplicate code in "if" statements because different branches are
almost the same.
Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
---
drivers/staging/vt6656/baseband.c | 52 +++++++------------------------
1 file changed, 12 insertions(+), 40 deletions(-)
diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
index a19a563d8bcc..276210a7284e 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -366,23 +366,15 @@ int vnt_vt3184_init(struct vnt_private *priv)
dev_dbg(&priv->usb->dev, "RF Type %d\n", priv->rf_type);
- if (priv->rf_type == RF_AL2230 ||
- priv->rf_type == RF_AL2230S) {
+ if ((priv->rf_type == RF_AL2230) ||
+ (priv->rf_type == RF_AL2230S) ||
+ (priv->rf_type == RF_AIROHA7230)) {
priv->bb_rx_conf = vnt_vt3184_al2230[10];
length = sizeof(vnt_vt3184_al2230);
addr = vnt_vt3184_al2230;
- priv->bb_vga[0] = 0x1C;
- priv->bb_vga[1] = 0x10;
- priv->bb_vga[2] = 0x0;
- priv->bb_vga[3] = 0x0;
-
- } else if (priv->rf_type == RF_AIROHA7230) {
- priv->bb_rx_conf = vnt_vt3184_al2230[10];
- length = sizeof(vnt_vt3184_al2230);
- addr = vnt_vt3184_al2230;
-
- addr[0xd7] = 0x06;
+ if (priv->rf_type == RF_AIROHA7230)
+ addr[0xd7] = 0x06;
priv->bb_vga[0] = 0x1c;
priv->bb_vga[1] = 0x10;
@@ -390,22 +382,8 @@ int vnt_vt3184_init(struct vnt_private *priv)
priv->bb_vga[3] = 0x0;
} else if ((priv->rf_type == RF_VT3226) ||
- (priv->rf_type == RF_VT3226D0)) {
- priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
- length = sizeof(vnt_vt3184_vt3226d0);
- addr = vnt_vt3184_vt3226d0;
-
- priv->bb_vga[0] = 0x20;
- priv->bb_vga[1] = 0x10;
- priv->bb_vga[2] = 0x0;
- priv->bb_vga[3] = 0x0;
-
- /* Fix VT3226 DFC system timing issue */
- ret = vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2,
- SOFTPWRCTL_RFLEOPT);
- if (ret)
- goto end;
- } else if (priv->rf_type == RF_VT3342A0) {
+ (priv->rf_type == RF_VT3226D0) ||
+ (priv->rf_type == RF_VT3342A0)) {
priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
length = sizeof(vnt_vt3184_vt3226d0);
addr = vnt_vt3184_vt3226d0;
@@ -435,19 +413,13 @@ int vnt_vt3184_init(struct vnt_private *priv)
if (ret)
goto end;
- if (priv->rf_type == RF_VT3226 ||
- priv->rf_type == RF_VT3342A0) {
- ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
- MAC_REG_ITRTMSET, 0x23);
- if (ret)
- goto end;
+ if ((priv->rf_type == RF_VT3226) ||
+ (priv->rf_type == RF_VT3342A0) ||
+ (priv->rf_type == RF_VT3226D0)) {
+ data = (priv->rf_type == RF_VT3226D0) ? 0x11 : 0x23;
- ret = vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, BIT(0));
- if (ret)
- goto end;
- } else if (priv->rf_type == RF_VT3226D0) {
ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
- MAC_REG_ITRTMSET, 0x11);
+ MAC_REG_ITRTMSET, data);
if (ret)
goto end;
--
2.20.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] staging: vt6656: Remove unnecessary local variable initialization
2020-04-11 12:51 ` Oscar Carter
@ 2020-04-11 12:51 ` Oscar Carter
-1 siblings, 0 replies; 6+ messages in thread
From: Oscar Carter @ 2020-04-11 12:51 UTC (permalink / raw)
To: Forest Bond, Greg Kroah-Hartman
Cc: Oscar Carter, Malcolm Priestley, Quentin Deslandes,
Amir Mahdi Ghorbanian, devel, linux-kernel
Don't initialize the ret variable as it is set a few lines later.
Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
---
drivers/staging/vt6656/baseband.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
index 276210a7284e..10d1f2cbb3d9 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -352,7 +352,7 @@ int vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode)
int vnt_vt3184_init(struct vnt_private *priv)
{
- int ret = 0;
+ int ret;
u16 length;
u8 *addr;
u8 data;
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] staging: vt6656: Remove unnecessary local variable initialization
@ 2020-04-11 12:51 ` Oscar Carter
0 siblings, 0 replies; 6+ messages in thread
From: Oscar Carter @ 2020-04-11 12:51 UTC (permalink / raw)
To: Forest Bond, Greg Kroah-Hartman
Cc: devel, Oscar Carter, Malcolm Priestley, linux-kernel
Don't initialize the ret variable as it is set a few lines later.
Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
---
drivers/staging/vt6656/baseband.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
index 276210a7284e..10d1f2cbb3d9 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -352,7 +352,7 @@ int vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode)
int vnt_vt3184_init(struct vnt_private *priv)
{
- int ret = 0;
+ int ret;
u16 length;
u8 *addr;
u8 data;
--
2.20.1
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-04-11 12:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-11 12:51 [PATCH 0/2] staging: vt6656: Refactor the vnt_vt3184_init function Oscar Carter
2020-04-11 12:51 ` Oscar Carter
2020-04-11 12:51 ` [PATCH 1/2] staging: vt6656: Remove duplicate code in " Oscar Carter
2020-04-11 12:51 ` Oscar Carter
2020-04-11 12:51 ` [PATCH 2/2] staging: vt6656: Remove unnecessary local variable initialization Oscar Carter
2020-04-11 12:51 ` Oscar Carter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.