driverdev-devel.linuxdriverproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Code simplifications
@ 2020-07-05 14:35 Mauro Dreissig
  2020-07-05 14:35 ` [PATCH v2 1/5] staging: rtl8712: Replace constant 49152 with expression 48 * 1024 Mauro Dreissig
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Mauro Dreissig @ 2020-07-05 14:35 UTC (permalink / raw)
  To: gregkh, Larry.Finger, florian.c.schilhabel, driverdev-devel

This series applies some code enhancements to rtl8712 staging driver.

Fixed the last commit as reported by kernel test robot <lkp@intel.com>.

Mauro Dreissig (5):
  staging: rtl8712: Replace constant 49152 with expression 48 * 1024
  staging: rtl8712: Simplify expressions with boolean logic
  staging: rtl8712: Use ETH_ALEN instead of hardcoded value
  staging: rtl8712: Remove variable 'raw' from rtl871x_open_fw()
  staging: rtl8712: Use proper format in call to dev_err()

 drivers/staging/rtl8712/hal_init.c     | 18 ++++++++----------
 drivers/staging/rtl8712/osdep_intf.h   |  2 +-
 drivers/staging/rtl8712/rtl8712_recv.c |  5 ++---
 3 files changed, 11 insertions(+), 14 deletions(-)

-- 
2.25.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 v2 1/5] staging: rtl8712: Replace constant 49152 with expression 48 * 1024
  2020-07-05 14:35 [PATCH v2 0/5] Code simplifications Mauro Dreissig
@ 2020-07-05 14:35 ` Mauro Dreissig
  2020-07-05 14:35 ` [PATCH v2 2/5] staging: rtl8712: Simplify expressions with boolean logic Mauro Dreissig
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Mauro Dreissig @ 2020-07-05 14:35 UTC (permalink / raw)
  To: gregkh, Larry.Finger, florian.c.schilhabel, driverdev-devel

This way we don't need the comment stating that 49152 equals 48k.

Signed-off-by: Mauro Dreissig <mukadr@gmail.com>
---
 drivers/staging/rtl8712/hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c
index 7293cdc3a43b..1f5ba9cbe951 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -27,7 +27,7 @@
 #include "usb_osintf.h"
 
 #define FWBUFF_ALIGN_SZ 512
-#define MAX_DUMP_FWSZ	49152 /*default = 49152 (48k)*/
+#define MAX_DUMP_FWSZ (48 * 1024)
 
 static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context)
 {
-- 
2.25.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 v2 2/5] staging: rtl8712: Simplify expressions with boolean logic
  2020-07-05 14:35 [PATCH v2 0/5] Code simplifications Mauro Dreissig
  2020-07-05 14:35 ` [PATCH v2 1/5] staging: rtl8712: Replace constant 49152 with expression 48 * 1024 Mauro Dreissig
@ 2020-07-05 14:35 ` Mauro Dreissig
  2020-07-05 14:35 ` [PATCH v2 3/5] staging: rtl8712: Use ETH_ALEN instead of hardcoded value Mauro Dreissig
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Mauro Dreissig @ 2020-07-05 14:35 UTC (permalink / raw)
  To: gregkh, Larry.Finger, florian.c.schilhabel, driverdev-devel

Simplify some expressions by using boolean operations.

Signed-off-by: Mauro Dreissig <mukadr@gmail.com>
---
 drivers/staging/rtl8712/hal_init.c     | 4 ++--
 drivers/staging/rtl8712/osdep_intf.h   | 2 +-
 drivers/staging/rtl8712/rtl8712_recv.c | 5 ++---
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c
index 1f5ba9cbe951..d3fc6fa9a715 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -99,12 +99,12 @@ static void fill_fwpriv(struct _adapter *adapter, struct fw_priv *fwpriv)
 	default:
 		fwpriv->rf_config = RTL8712_RFC_1T2R;
 	}
-	fwpriv->mp_mode = (regpriv->mp_mode == 1) ? 1 : 0;
+	fwpriv->mp_mode = (regpriv->mp_mode == 1);
 	/* 0:off 1:on 2:auto */
 	fwpriv->vcs_type = regpriv->vrtl_carrier_sense;
 	fwpriv->vcs_mode = regpriv->vcs_type; /* 1:RTS/CTS 2:CTS to self */
 	/* default enable turbo_mode */
-	fwpriv->turbo_mode = ((regpriv->wifi_test == 1) ? 0 : 1);
+	fwpriv->turbo_mode = (regpriv->wifi_test != 1);
 	fwpriv->low_power_mode = regpriv->low_power;
 }
 
diff --git a/drivers/staging/rtl8712/osdep_intf.h b/drivers/staging/rtl8712/osdep_intf.h
index 2cc25db1a91d..9e75116c987e 100644
--- a/drivers/staging/rtl8712/osdep_intf.h
+++ b/drivers/staging/rtl8712/osdep_intf.h
@@ -17,7 +17,7 @@
 #include "osdep_service.h"
 #include "drv_types.h"
 
-#define RND4(x)	(((x >> 2) + (((x & 3) == 0) ?  0 : 1)) << 2)
+#define RND4(x)	(((x >> 2) + ((x & 3) != 0)) << 2)
 
 struct intf_priv {
 	u8 *intf_dev;
diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
index c513cda2a49e..d83f421acfc1 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -143,9 +143,8 @@ static void update_recvframe_attrib_from_recvstat(struct rx_pkt_attrib *pattrib,
 	/*TODO:
 	 * Offset 0
 	 */
-	pattrib->bdecrypted = ((le32_to_cpu(prxstat->rxdw0) & BIT(27)) >> 27)
-				 ? 0 : 1;
-	pattrib->crc_err = (le32_to_cpu(prxstat->rxdw0) & BIT(14)) >> 14;
+	pattrib->bdecrypted = (le32_to_cpu(prxstat->rxdw0) & BIT(27)) == 0;
+	pattrib->crc_err = (le32_to_cpu(prxstat->rxdw0) & BIT(14)) != 0;
 	/*Offset 4*/
 	/*Offset 8*/
 	/*Offset 12*/
-- 
2.25.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 v2 3/5] staging: rtl8712: Use ETH_ALEN instead of hardcoded value
  2020-07-05 14:35 [PATCH v2 0/5] Code simplifications Mauro Dreissig
  2020-07-05 14:35 ` [PATCH v2 1/5] staging: rtl8712: Replace constant 49152 with expression 48 * 1024 Mauro Dreissig
  2020-07-05 14:35 ` [PATCH v2 2/5] staging: rtl8712: Simplify expressions with boolean logic Mauro Dreissig
@ 2020-07-05 14:35 ` Mauro Dreissig
  2020-07-05 14:35 ` [PATCH v2 4/5] staging: rtl8712: Remove variable 'raw' from rtl871x_open_fw() Mauro Dreissig
  2020-07-05 14:35 ` [PATCH v2 5/5] staging: rtl8712: Use proper format in call to dev_err() Mauro Dreissig
  4 siblings, 0 replies; 6+ messages in thread
From: Mauro Dreissig @ 2020-07-05 14:35 UTC (permalink / raw)
  To: gregkh, Larry.Finger, florian.c.schilhabel, driverdev-devel

Use macro ETH_ALEN which defines the number of octets in
an ethernet address.

Signed-off-by: Mauro Dreissig <mukadr@gmail.com>
---
 drivers/staging/rtl8712/hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c
index d3fc6fa9a715..d53efdfc9bf0 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -343,7 +343,7 @@ uint rtl8712_hal_init(struct _adapter *padapter)
 	/* Fix the RX FIFO issue(USB error) */
 	r8712_write8(padapter, 0x1025fe5C, r8712_read8(padapter, 0x1025fe5C)
 		     | BIT(7));
-	for (i = 0; i < 6; i++)
+	for (i = 0; i < ETH_ALEN; i++)
 		padapter->eeprompriv.mac_addr[i] = r8712_read8(padapter,
 							       MACID + i);
 	return _SUCCESS;
-- 
2.25.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 v2 4/5] staging: rtl8712: Remove variable 'raw' from rtl871x_open_fw()
  2020-07-05 14:35 [PATCH v2 0/5] Code simplifications Mauro Dreissig
                   ` (2 preceding siblings ...)
  2020-07-05 14:35 ` [PATCH v2 3/5] staging: rtl8712: Use ETH_ALEN instead of hardcoded value Mauro Dreissig
@ 2020-07-05 14:35 ` Mauro Dreissig
  2020-07-05 14:35 ` [PATCH v2 5/5] staging: rtl8712: Use proper format in call to dev_err() Mauro Dreissig
  4 siblings, 0 replies; 6+ messages in thread
From: Mauro Dreissig @ 2020-07-05 14:35 UTC (permalink / raw)
  To: gregkh, Larry.Finger, florian.c.schilhabel, driverdev-devel

Remove useless variable 'raw' from function rtl871x_open_fw()
making the code a bit easier to understand.

Signed-off-by: Mauro Dreissig <mukadr@gmail.com>
---
 drivers/staging/rtl8712/hal_init.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c
index d53efdfc9bf0..d7b30152d409 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -67,15 +67,13 @@ MODULE_FIRMWARE("rtlwifi/rtl8712u.bin");
 
 static u32 rtl871x_open_fw(struct _adapter *adapter, const u8 **mappedfw)
 {
-	const struct firmware **raw = &adapter->fw;
-
 	if (adapter->fw->size > 200000) {
 		dev_err(&adapter->pnetdev->dev, "r8172u: Badfw->size of %d\n",
 			(int)adapter->fw->size);
 		return 0;
 	}
-	*mappedfw = (*raw)->data;
-	return (*raw)->size;
+	*mappedfw = adapter->fw->data;
+	return adapter->fw->size;
 }
 
 static void fill_fwpriv(struct _adapter *adapter, struct fw_priv *fwpriv)
-- 
2.25.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 v2 5/5] staging: rtl8712: Use proper format in call to dev_err()
  2020-07-05 14:35 [PATCH v2 0/5] Code simplifications Mauro Dreissig
                   ` (3 preceding siblings ...)
  2020-07-05 14:35 ` [PATCH v2 4/5] staging: rtl8712: Remove variable 'raw' from rtl871x_open_fw() Mauro Dreissig
@ 2020-07-05 14:35 ` Mauro Dreissig
  4 siblings, 0 replies; 6+ messages in thread
From: Mauro Dreissig @ 2020-07-05 14:35 UTC (permalink / raw)
  To: gregkh, Larry.Finger, florian.c.schilhabel, driverdev-devel

In the call to dev_err(), remove the cast of size_t to int
and change the format string accordingly.

As reported by the kernel test robot, the correct
format string for a size_t argument should be %zu.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Mauro Dreissig <mukadr@gmail.com>
---
 drivers/staging/rtl8712/hal_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c
index d7b30152d409..ed51023b85a0 100644
--- a/drivers/staging/rtl8712/hal_init.c
+++ b/drivers/staging/rtl8712/hal_init.c
@@ -68,8 +68,8 @@ MODULE_FIRMWARE("rtlwifi/rtl8712u.bin");
 static u32 rtl871x_open_fw(struct _adapter *adapter, const u8 **mappedfw)
 {
 	if (adapter->fw->size > 200000) {
-		dev_err(&adapter->pnetdev->dev, "r8172u: Badfw->size of %d\n",
-			(int)adapter->fw->size);
+		dev_err(&adapter->pnetdev->dev, "r8712u: Bad fw->size of %zu\n",
+			adapter->fw->size);
 		return 0;
 	}
 	*mappedfw = adapter->fw->data;
-- 
2.25.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-07-05 14:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-05 14:35 [PATCH v2 0/5] Code simplifications Mauro Dreissig
2020-07-05 14:35 ` [PATCH v2 1/5] staging: rtl8712: Replace constant 49152 with expression 48 * 1024 Mauro Dreissig
2020-07-05 14:35 ` [PATCH v2 2/5] staging: rtl8712: Simplify expressions with boolean logic Mauro Dreissig
2020-07-05 14:35 ` [PATCH v2 3/5] staging: rtl8712: Use ETH_ALEN instead of hardcoded value Mauro Dreissig
2020-07-05 14:35 ` [PATCH v2 4/5] staging: rtl8712: Remove variable 'raw' from rtl871x_open_fw() Mauro Dreissig
2020-07-05 14:35 ` [PATCH v2 5/5] staging: rtl8712: Use proper format in call to dev_err() Mauro Dreissig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).