linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@codeaurora.org>
To: <yhchuang@realtek.com>
Cc: <linux-wireless@vger.kernel.org>, <johannes@sipsolutions.net>,
	<pkshih@realtek.com>, <tehuang@realtek.com>,
	<Larry.Finger@lwfinger.net>, <sgruszka@redhat.com>,
	<briannorris@chromium.org>, <gregkh@linuxfoundation.org>
Subject: Re: [PATCH v9 04/14] rtw88: trx files
Date: Tue, 30 Apr 2019 15:45:40 +0300	[thread overview]
Message-ID: <87bm0npsp7.fsf@kamboji.qca.qualcomm.com> (raw)
In-Reply-To: <1555653004-1795-5-git-send-email-yhchuang@realtek.com> (yhchuang@realtek.com's message of "Fri, 19 Apr 2019 13:49:54 +0800")

<yhchuang@realtek.com> writes:

> From: Yan-Hsuan Chuang <yhchuang@realtek.com>
>
> trx files for Realtek 802.11ac wireless network chips
>
> Reviewed-by: Stanislaw Gruszka <sgruszka@redhat.com>
> Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>

[...]

> --- /dev/null
> +++ b/drivers/net/wireless/realtek/rtw88/rx.h
> @@ -0,0 +1,41 @@
> +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
> +/* Copyright(c) 2018-2019  Realtek Corporation
> + */
> +
> +#ifndef __RTW_RX_H_
> +#define __RTW_RX_H_
> +
> +#define GET_RX_DESC_PHYST(rxdesc)                                              \
> +	le32_get_bits(*((__le32 *)(rxdesc) + 0x00), BIT(26))
> +#define GET_RX_DESC_ICV_ERR(rxdesc)                                            \
> +	le32_get_bits(*((__le32 *)(rxdesc) + 0x00), BIT(15))
> +#define GET_RX_DESC_CRC32(rxdesc)                                              \
> +	le32_get_bits(*((__le32 *)(rxdesc) + 0x00), BIT(14))
> +#define GET_RX_DESC_SWDEC(rxdesc)                                              \
> +	le32_get_bits(*((__le32 *)(rxdesc) + 0x00), BIT(27))
> +#define GET_RX_DESC_C2H(rxdesc)                                                \
> +	le32_get_bits(*((__le32 *)(rxdesc) + 0x02), BIT(28))
> +#define GET_RX_DESC_PKT_LEN(rxdesc)                                            \
> +	le32_get_bits(*((__le32 *)(rxdesc) + 0x00), GENMASK(13, 0))
> +#define GET_RX_DESC_DRV_INFO_SIZE(rxdesc)                                      \
> +	le32_get_bits(*((__le32 *)(rxdesc) + 0x00), GENMASK(19, 16))
> +#define GET_RX_DESC_SHIFT(rxdesc)                                              \
> +	le32_get_bits(*((__le32 *)(rxdesc) + 0x00), GENMASK(25, 24))
> +#define GET_RX_DESC_RX_RATE(rxdesc)                                            \
> +	le32_get_bits(*((__le32 *)(rxdesc) + 0x03), GENMASK(6, 0))
> +#define GET_RX_DESC_MACID(rxdesc)                                              \
> +	le32_get_bits(*((__le32 *)(rxdesc) + 0x01), GENMASK(6, 0))
> +#define GET_RX_DESC_PPDU_CNT(rxdesc)                                           \
> +	le32_get_bits(*((__le32 *)(rxdesc) + 0x02), GENMASK(30, 29))
> +#define GET_RX_DESC_TSFL(rxdesc)                                               \
> +	le32_get_bits(*((__le32 *)(rxdesc) + 0x05), GENMASK(31, 0))

I'm not really fond of these "byte macros" or whatever they should be
called, you use these a lot in rtw88 but I have seen the same usage also
other drivers. The upstream way of doing this is to create a struct,
which also acts as a documentation, and you can pass it around different
functions. And the GENMASK()s are defined close the struct.

Also you could change these defines to static inline functions, which
take the struct as a pointer, and that you get type checking from the
compiler. And that way you would get rid of that ugly casting as well.

-- 
Kalle Valo

  reply	other threads:[~2019-04-30 12:45 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-19  5:49 [PATCH v9 00/14] rtw88: mac80211 driver for Realtek 802.11ac wireless network chips yhchuang
2019-04-19  5:49 ` [PATCH v9 01/14] rtw88: main files yhchuang
2019-04-30 10:30   ` Kalle Valo
2019-04-30 10:32   ` Kalle Valo
2019-04-30 11:45   ` Kalle Valo
2019-04-30 12:16   ` Kalle Valo
2019-04-19  5:49 ` [PATCH v9 02/14] rtw88: core files yhchuang
2019-04-19  5:49 ` [PATCH v9 03/14] rtw88: hci files yhchuang
2019-04-19  5:49 ` [PATCH v9 04/14] rtw88: trx files yhchuang
2019-04-30 12:45   ` Kalle Valo [this message]
2019-05-01 18:18     ` Larry Finger
2019-05-01 18:30       ` Kalle Valo
2019-05-01 20:09         ` Larry Finger
2019-05-02 18:23         ` Brian Norris
2019-04-19  5:49 ` [PATCH v9 05/14] rtw88: mac files yhchuang
2019-04-30 11:48   ` Kalle Valo
2019-04-19  5:49 ` [PATCH v9 06/14] rtw88: fw and efuse files yhchuang
2019-04-19  5:49 ` [PATCH v9 07/14] rtw88: phy files yhchuang
2019-04-19  5:49 ` [PATCH v9 08/14] rtw88: debug files yhchuang
2019-04-19  5:49 ` [PATCH v9 09/14] rtw88: chip files yhchuang
2019-04-30 10:26   ` Kalle Valo
2019-04-30 12:00     ` Kalle Valo
2019-04-30 12:06   ` Kalle Valo
2019-04-19  5:50 ` [PATCH v9 10/14] rtw88: 8822B init table yhchuang
2019-04-19  5:50 ` [PATCH v9 11/14] rtw88: 8822C " yhchuang
2019-04-19  5:50 ` [PATCH v9 12/14] rtw88: Kconfig & Makefile yhchuang
2019-04-30 11:53   ` Kalle Valo
2019-04-19  5:50 ` [PATCH v9 13/14] rtw88: add MAINTAINERS entry yhchuang
     [not found] ` <1555653004-1795-15-git-send-email-yhchuang@realtek.com>
2019-04-26 12:09   ` [PATCH v9 14/14] staging: rtlwifi: remove staging rtlwifi driver Kalle Valo
2019-04-26 12:19     ` Tony Chuang
2019-04-27  6:36       ` gregkh
2019-04-30 12:40 ` [PATCH v9 00/14] rtw88: mac80211 driver for Realtek 802.11ac wireless network chips Kalle Valo
2019-04-30 15:58   ` Stanislaw Gruszka
2019-04-30 16:47     ` Kalle Valo
2019-04-30 17:42       ` Greg KH
2019-05-01  7:09         ` Kalle Valo
2019-05-01  8:19           ` Greg KH
2019-05-01  8:42             ` Greg KH
2019-05-02  2:05   ` Tony Chuang
2021-06-18 12:08 ` rtw88: SDIO Support Rudi Heitbaum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bm0npsp7.fsf@kamboji.qca.qualcomm.com \
    --to=kvalo@codeaurora.org \
    --cc=Larry.Finger@lwfinger.net \
    --cc=briannorris@chromium.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    --cc=sgruszka@redhat.com \
    --cc=tehuang@realtek.com \
    --cc=yhchuang@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).