linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kai-Heng Feng <kai.heng.feng@canonical.com>
To: Kalle Valo <kvalo@codeaurora.org>
Cc: Tony Chuang <yhchuang@realtek.com>,
	"David S. Miller" <davem@davemloft.net>,
	"open list:REALTEK WIRELESS DRIVER (rtw88)" 
	<linux-wireless@vger.kernel.org>,
	"open list:NETWORKING DRIVERS" <netdev@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rtw88: Add delay on polling h2c command status bit
Date: Tue, 7 Apr 2020 15:20:33 +0800	[thread overview]
Message-ID: <E3E792CF-AC1A-466E-A1B2-F1CFAE9BC673@canonical.com> (raw)
In-Reply-To: <87k12syanf.fsf@kamboji.qca.qualcomm.com>



> On Apr 6, 2020, at 22:03, Kalle Valo <kvalo@codeaurora.org> wrote:
> 
> Kai-Heng Feng <kai.heng.feng@canonical.com> writes:
> 
>>> On Apr 6, 2020, at 21:24, Kalle Valo <kvalo@codeaurora.org> wrote:
>>> 
>>> Kai-Heng Feng <kai.heng.feng@canonical.com> writes:
>>> 
>>>>> On Apr 6, 2020, at 20:17, Kalle Valo <kvalo@codeaurora.org> wrote:
>>>>> 
>>>>> Kai-Heng Feng <kai.heng.feng@canonical.com> writes:
>>>>> 
>>>>>> --- a/drivers/net/wireless/realtek/rtw88/hci.h
>>>>>> +++ b/drivers/net/wireless/realtek/rtw88/hci.h
>>>>>> @@ -253,6 +253,10 @@ rtw_write8_mask(struct rtw_dev *rtwdev, u32
>>>>>> addr, u32 mask, u8 data)
>>>>>> 	rtw_write8(rtwdev, addr, set);
>>>>>> }
>>>>>> 
>>>>>> +#define rr8(addr)      rtw_read8(rtwdev, addr)
>>>>>> +#define rr16(addr)     rtw_read16(rtwdev, addr)
>>>>>> +#define rr32(addr)     rtw_read32(rtwdev, addr)
>>>>> 
>>>>> For me these macros reduce code readability, not improve anything. They
>>>>> hide the use of rtwdev variable, which is evil, and a name like rr8() is
>>>>> just way too vague. Please keep the original function names as is.
>>>> 
>>>> The inspiration is from another driver.
>>>> readx_poll_timeout macro only takes one argument for the op.
>>>> Some other drivers have their own poll_timeout implementation,
>>>> and I guess it makes sense to make one specific for rtw88.
>>> 
>>> I'm not even understanding the problem you are tying to fix with these
>>> macros. The upstream philosopyhy is to have the source code readable and
>>> maintainable, not to use minimal number of characters. There's a reason
>>> why we don't name our functions a(), b(), c() and so on.
>> 
>> The current h2c polling doesn't have delay between each interval, so
>> the polling is too fast and the following logic considers it's a
>> timeout.
>> The readx_poll_timeout() macro provides a generic mechanism to setup
>> an interval delay and timeout which is what we need here.
>> However readx_poll_timeout only accepts one parameter which usually is
>> memory address, while we need to pass both rtwdev and address.
>> 
>> So if hiding rtwdev is evil, we can roll our own variant of
>> readx_poll_timeout() to make the polling readable.
> 
> Can't you do:
> 
> ret = read_poll_timeout(rtw_read8, box_state,
>                        !((box_state >> box) & 0x1), 100,
>                        3000, false, rtw_dev, REG_HMETFR);
> 
> No ugly macros needed and it should function the same. But I did not
> test this in any way, so no idea if it even compiles.

Yes that will do. Didn't notice the recently added macro.

Will send v2.

Kai-Heng

> 
> -- 
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


      reply	other threads:[~2020-04-07  7:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-06  9:36 [PATCH] rtw88: Add delay on polling h2c command status bit Kai-Heng Feng
2020-04-06 11:01 ` Tony Chuang
2020-04-06 11:56   ` Kai-Heng Feng
2020-04-06 12:17 ` Kalle Valo
2020-04-06 13:18   ` Kai-Heng Feng
2020-04-06 13:24     ` Kalle Valo
2020-04-06 13:35       ` Kai-Heng Feng
2020-04-06 14:03         ` Kalle Valo
2020-04-07  7:20           ` Kai-Heng Feng [this message]

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=E3E792CF-AC1A-466E-A1B2-F1CFAE9BC673@canonical.com \
    --to=kai.heng.feng@canonical.com \
    --cc=davem@davemloft.net \
    --cc=kvalo@codeaurora.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --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).