DriverDev-Devel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v2] staging: vt6656: Use DIV_ROUND_UP macro instead of specific code
@ 2020-03-26 17:59 Oscar Carter
  2020-03-27  8:44 ` Quentin Deslandes
  0 siblings, 1 reply; 2+ messages in thread
From: Oscar Carter @ 2020-03-26 17:59 UTC (permalink / raw)
  To: Forest Bond, Greg Kroah-Hartman
  Cc: devel, Oscar Carter, Malcolm Priestley, linux-kernel

Use DIV_ROUND_UP macro instead of specific code with the same purpose.
Also, remove the unused variables.

Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
---
Changelog v1 -> v2
- Rebase the original patch [1] against the staging-next branch of the greg's
  staging.git tree.

  [1] https://lore.kernel.org/lkml/20200322112342.9040-1-oscar.carter@gmx.com/

 drivers/staging/vt6656/baseband.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
index 0b5729abcbcd..a19a563d8bcc 100644
--- a/drivers/staging/vt6656/baseband.c
+++ b/drivers/staging/vt6656/baseband.c
@@ -23,6 +23,7 @@
  */

 #include <linux/bits.h>
+#include <linux/kernel.h>
 #include "mac.h"
 #include "baseband.h"
 #include "rf.h"
@@ -133,7 +134,6 @@ unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type,
 {
 	unsigned int frame_time;
 	unsigned int preamble;
-	unsigned int tmp;
 	unsigned int rate = 0;

 	if (tx_rate > RATE_54M)
@@ -147,20 +147,11 @@ unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type,
 		else
 			preamble = 192;

-		frame_time = (frame_length * 80) / rate;
-		tmp = (frame_time * rate) / 80;
-
-		if (frame_length != tmp)
-			frame_time++;
-
+		frame_time = DIV_ROUND_UP(frame_length * 80, rate);
 		return preamble + frame_time;
 	}
-	frame_time = (frame_length * 8 + 22) / rate;
-	tmp = ((frame_time * rate) - 22) / 8;
-
-	if (frame_length != tmp)
-		frame_time++;

+	frame_time = DIV_ROUND_UP(frame_length * 8 + 22, rate);
 	frame_time = frame_time * 4;

 	if (pkt_type != PK_TYPE_11A)
@@ -214,11 +205,7 @@ void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length,

 		break;
 	case RATE_5M:
-		count = (bit_count * 10) / 55;
-		tmp = (count * 55) / 10;
-
-		if (tmp != bit_count)
-			count++;
+		count = DIV_ROUND_UP(bit_count * 10, 55);

 		if (preamble_type == 1)
 			phy->signal = 0x0a;
--
2.20.1

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] staging: vt6656: Use DIV_ROUND_UP macro instead of specific code
  2020-03-26 17:59 [PATCH v2] staging: vt6656: Use DIV_ROUND_UP macro instead of specific code Oscar Carter
@ 2020-03-27  8:44 ` Quentin Deslandes
  0 siblings, 0 replies; 2+ messages in thread
From: Quentin Deslandes @ 2020-03-27  8:44 UTC (permalink / raw)
  To: Oscar Carter
  Cc: devel, Malcolm Priestley, Greg Kroah-Hartman, linux-kernel, Forest Bond

On 03/26/20 18:59:02, Oscar Carter wrote:
> Use DIV_ROUND_UP macro instead of specific code with the same purpose.
> Also, remove the unused variables.
> 
> Signed-off-by: Oscar Carter <oscar.carter@gmx.com>
> ---
> Changelog v1 -> v2
> - Rebase the original patch [1] against the staging-next branch of the greg's
>   staging.git tree.
> 
>   [1] https://lore.kernel.org/lkml/20200322112342.9040-1-oscar.carter@gmx.com/
> 
>  drivers/staging/vt6656/baseband.c | 21 ++++-----------------
>  1 file changed, 4 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c
> index 0b5729abcbcd..a19a563d8bcc 100644
> --- a/drivers/staging/vt6656/baseband.c
> +++ b/drivers/staging/vt6656/baseband.c
> @@ -23,6 +23,7 @@
>   */
> 
>  #include <linux/bits.h>
> +#include <linux/kernel.h>
>  #include "mac.h"
>  #include "baseband.h"
>  #include "rf.h"
> @@ -133,7 +134,6 @@ unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type,
>  {
>  	unsigned int frame_time;
>  	unsigned int preamble;
> -	unsigned int tmp;
>  	unsigned int rate = 0;
> 
>  	if (tx_rate > RATE_54M)
> @@ -147,20 +147,11 @@ unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type,
>  		else
>  			preamble = 192;
> 
> -		frame_time = (frame_length * 80) / rate;
> -		tmp = (frame_time * rate) / 80;
> -
> -		if (frame_length != tmp)
> -			frame_time++;
> -
> +		frame_time = DIV_ROUND_UP(frame_length * 80, rate);
>  		return preamble + frame_time;
>  	}
> -	frame_time = (frame_length * 8 + 22) / rate;
> -	tmp = ((frame_time * rate) - 22) / 8;
> -
> -	if (frame_length != tmp)
> -		frame_time++;
> 
> +	frame_time = DIV_ROUND_UP(frame_length * 8 + 22, rate);
>  	frame_time = frame_time * 4;
> 
>  	if (pkt_type != PK_TYPE_11A)
> @@ -214,11 +205,7 @@ void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length,
> 
>  		break;
>  	case RATE_5M:
> -		count = (bit_count * 10) / 55;
> -		tmp = (count * 55) / 10;
> -
> -		if (tmp != bit_count)
> -			count++;
> +		count = DIV_ROUND_UP(bit_count * 10, 55);
> 
>  		if (preamble_type == 1)
>  			phy->signal = 0x0a;
> --
> 2.20.1

Reviewed-by: Quentin Deslandes <quentin.deslandes@itdev.co.uk>

Thanks,
Quentin
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 17:59 [PATCH v2] staging: vt6656: Use DIV_ROUND_UP macro instead of specific code Oscar Carter
2020-03-27  8:44 ` Quentin Deslandes

DriverDev-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/driverdev-devel/0 driverdev-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 driverdev-devel driverdev-devel/ https://lore.kernel.org/driverdev-devel \
		driverdev-devel@linuxdriverproject.org devel@driverdev.osuosl.org
	public-inbox-index driverdev-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxdriverproject.driverdev-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git