2022-06-12 10:40:02

by Nam Cao

[permalink] [raw]
Subject: [PATCH v2 1/2] staging: r8188eu: replace LE_BITS_TO_1BYTE with clearer codes

The statement LE_BITS_TO_1BYTE(__paddr + n, 0, 8) is not obvious on
what it is doing, while in truth it is simply reading one byte.
Replace these with clearer codes.

Signed-off-by: Nam Cao <[email protected]>
---
drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h
index 20d73ca781e8..79e4210c6b65 100644
--- a/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h
+++ b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h
@@ -26,15 +26,15 @@
#define GET_TX_REPORT_TYPE1_RERTY_0(__paddr) \
le16_get_bits(*(__le16 *)__paddr, GENMASK(15, 0))
#define GET_TX_REPORT_TYPE1_RERTY_1(__paddr) \
- LE_BITS_TO_1BYTE(__paddr + 2, 0, 8)
+ ((u8 *)__paddr)[2]
#define GET_TX_REPORT_TYPE1_RERTY_2(__paddr) \
- LE_BITS_TO_1BYTE(__paddr + 3, 0, 8)
+ ((u8 *)__paddr)[3]
#define GET_TX_REPORT_TYPE1_RERTY_3(__paddr) \
- LE_BITS_TO_1BYTE(__paddr + 4, 0, 8)
+ ((u8 *)__paddr)[4]
#define GET_TX_REPORT_TYPE1_RERTY_4(__paddr) \
- LE_BITS_TO_1BYTE(__paddr + 5, 0, 8)
+ ((u8 *)__paddr)[5]
#define GET_TX_REPORT_TYPE1_DROP_0(__paddr) \
- LE_BITS_TO_1BYTE(__paddr + 6, 0, 8)
+ ((u8 *)__paddr)[6]
/* End rate adaptive define */

int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm);
--
2.25.1


2022-06-13 18:39:14

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] staging: r8188eu: replace LE_BITS_TO_1BYTE with clearer codes

On Sun, Jun 12, 2022 at 10:11:43AM +0200, Nam Cao wrote:
> The statement LE_BITS_TO_1BYTE(__paddr + n, 0, 8) is not obvious on
> what it is doing, while in truth it is simply reading one byte.
> Replace these with clearer codes.
>
> Signed-off-by: Nam Cao <[email protected]>
> ---
> drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h
> index 20d73ca781e8..79e4210c6b65 100644
> --- a/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h
> +++ b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h
> @@ -26,15 +26,15 @@
> #define GET_TX_REPORT_TYPE1_RERTY_0(__paddr) \
> le16_get_bits(*(__le16 *)__paddr, GENMASK(15, 0))
> #define GET_TX_REPORT_TYPE1_RERTY_1(__paddr) \
> - LE_BITS_TO_1BYTE(__paddr + 2, 0, 8)
> + ((u8 *)__paddr)[2]

Instead of doing this, I would prefer to just get rid of
GET_TX_REPORT_TYPE1_RERTY_[1234].

regards,
dan carpenter

2022-06-14 09:59:21

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] staging: r8188eu: replace LE_BITS_TO_1BYTE with clearer codes

On Mon, Jun 13, 2022 at 05:30:24PM +0300, Dan Carpenter wrote:
> On Sun, Jun 12, 2022 at 10:11:43AM +0200, Nam Cao wrote:
> > The statement LE_BITS_TO_1BYTE(__paddr + n, 0, 8) is not obvious on
> > what it is doing, while in truth it is simply reading one byte.
> > Replace these with clearer codes.
> >
> > Signed-off-by: Nam Cao <[email protected]>
> > ---
> > drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h
> > index 20d73ca781e8..79e4210c6b65 100644
> > --- a/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h
> > +++ b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h
> > @@ -26,15 +26,15 @@
> > #define GET_TX_REPORT_TYPE1_RERTY_0(__paddr) \
> > le16_get_bits(*(__le16 *)__paddr, GENMASK(15, 0))
> > #define GET_TX_REPORT_TYPE1_RERTY_1(__paddr) \
> > - LE_BITS_TO_1BYTE(__paddr + 2, 0, 8)
> > + ((u8 *)__paddr)[2]
>
> Instead of doing this, I would prefer to just get rid of
> GET_TX_REPORT_TYPE1_RERTY_[1234].

Yes, I agree, that's a mess and almost impossible to understand...

thanks,

greg k-h

2022-06-14 16:30:10

by Nam Cao

[permalink] [raw]
Subject: [PATCH v3 0/2] get rid of confusing macros

Replace some confusing macros with more explicit codes.

V3:
- Get rid of GET_TX_REPORT_TYPE1_RERTY_0 and similar
V2:
- Split into smaller commits so that it's easier to review

Nam Cao (2):
staging: r8188eu: replace confusing macros
staging: r8188eu: remove unused macros

.../r8188eu/hal/Hal8188ERateAdaptive.c | 12 +++----
.../r8188eu/include/Hal8188ERateAdaptive.h | 13 --------
drivers/staging/r8188eu/include/basic_types.h | 31 -------------------
3 files changed, 6 insertions(+), 50 deletions(-)

--
2.25.1

2022-06-15 08:38:01

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH v3 0/2] get rid of confusing macros

On Tue, Jun 14, 2022 at 05:58:43PM +0200, Nam Cao wrote:
> Replace some confusing macros with more explicit codes.
>
> V3:
> - Get rid of GET_TX_REPORT_TYPE1_RERTY_0 and similar
> V2:
> - Split into smaller commits so that it's easier to review
>
> Nam Cao (2):
> staging: r8188eu: replace confusing macros
> staging: r8188eu: remove unused macros

So much better! Thanks!

Reviewed-by: Dan Carpenter <[email protected]>

regards,
dan carpenter