Linux wireless drivers development
 help / color / mirror / Atom feed
From: Jeff Johnson <quic_jjohnson@quicinc.com>
To: Wenli Looi <wlooi@ucalgary.ca>
Cc: "Toke Høiland-Jørgensen" <toke@toke.dk>,
	"Kalle Valo" <kvalo@kernel.org>,
	linux-wireless@vger.kernel.org
Subject: Re: [PATCH v2 2/9] ath9k: basic support for QCN550x
Date: Wed, 18 May 2022 14:19:25 -0700	[thread overview]
Message-ID: <7c05bbc5-c51f-2eb6-84a2-3a20c45b8b22@quicinc.com> (raw)
In-Reply-To: <CAKe_nd3u+iiCGC7M_i+ovF+_bgDMkFUh0OpJ7HFWMhmgZQa7bw@mail.gmail.com>

On 5/17/2022 11:08 PM, Wenli Looi wrote:
> On Thu, May 12, 2022 at 2:45 PM Jeff Johnson <quic_jjohnson@quicinc.com> wrote:
>>
>> On 5/12/2022 12:53 PM, Wenli Looi wrote:
>>> QCN550x is very similar to QCA956x. Note that AR_CH0_XTAL is
>>> intentionally unchanged. Certain arrays are no longer static because
>>> they are no longer constant.
>>
>> I don't understand the last sentence. You removed the 'static' keyword
>> but left the 'const' keyword, hence they are still constant.
>>
>> And I didn't actually see any instances where the arrays are being modified.
>>
>> Can you highlight which are being modified?
> 
> I changed several arrays from "static const" to "const" because their
> values now depend on ah, so it won't compile if they are static. For
> example, offset_array contains AR_PHY_RX_IQCAL_CORR_B0 which depends
> on AR_CHAN_BASE (which now depends on ah but did not before).

So the values are no longer constant, hence IMO the 'const' qualifier 
should also be removed

> 
>>> -#define AR_CHAN_BASE 0x9800
>>> +#define AR_CHAN_BASE (AR_SREV_5502(ah) ? 0x29800 : 0x9800)
>>
>> this violates the coding style:
>> <https://www.kernel.org/doc/html/latest/process/coding-style.html#macros-enums-and-rtl>
>>
>> Things to avoid when using macros:
>> macros that depend on having a local variable with a magic name
>>
>> So you should add ah as a parameter to the macro
>>
>> Repeat for all instances below where ah is being used
>>
> 
> The macros like AR_CHAN_BASE and AR_SM_BASE are referenced by a lot of
> other macros, some of which already have a "magic name" dependency on
> ah like these ones:
> 
> https://github.com/torvalds/linux/blob/210e04ff768142b96452030c4c2627512b30ad95/drivers/net/wireless/ath/ath9k/ar9003_phy.h#L527
> 
> However I think it's probably good to avoid introducing new macros
> with the magic name dependency. If desired, for every macro that I
> have modified, I could try to add the ah parameter to all dependent
> macros. This would probably be a rather large change so it might make
> sense to be a separate commit.

Your current change illustrates one of the many pitfalls of using magic 
names. IMO you should have a precursor patch that changes all of the 
"bad" macros to take ah as a parameter rather than be a magic name.

At a minimum you should add ah as a parameter to the ones you are 
modifying so that it is clear why you need to change the attributes of 
those arrays.

/jeff

  reply	other threads:[~2022-05-18 21:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-12 19:53 [PATCH v2 0/9] ath9k: add support for QCN550x Wenli Looi
2022-05-12 19:53 ` [PATCH v2 1/9] ath9k: add QCN550x device IDs Wenli Looi
2022-05-12 19:53 ` [PATCH v2 2/9] ath9k: basic support for QCN550x Wenli Looi
2022-05-12 21:45   ` Jeff Johnson
2022-05-18  6:08     ` Wenli Looi
2022-05-18 21:19       ` Jeff Johnson [this message]
2022-05-12 19:53 ` [PATCH v2 3/9] ath9k: add QCN550x initvals Wenli Looi
2022-05-12 19:53 ` [PATCH v2 4/9] ath9k: implement QCN550x rx Wenli Looi
2022-05-12 19:53 ` [PATCH v2 5/9] ath9k: implement QCN550x tx Wenli Looi
2022-05-12 19:53 ` [PATCH v2 6/9] ath9k: group some ar9300 eeprom functions at the top Wenli Looi
2022-05-12 19:53 ` [PATCH v2 7/9] ath9k: add abstractions over ar9300 eeprom Wenli Looi
2022-05-12 19:53 ` [PATCH v2 8/9] ath9k: rename ar9300_eeprom to ar9300_eeprom_v1 Wenli Looi
2022-05-12 19:53 ` [PATCH v2 9/9] ath9k: add ar9300_eeprom_v2 Wenli Looi

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=7c05bbc5-c51f-2eb6-84a2-3a20c45b8b22@quicinc.com \
    --to=quic_jjohnson@quicinc.com \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=toke@toke.dk \
    --cc=wlooi@ucalgary.ca \
    /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