linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bitterblue Smith <rtl8821cerfe2@gmail.com>
To: Ping-Ke Shih <pkshih@realtek.com>, "kvalo@kernel.org" <kvalo@kernel.org>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"Larry.Finger@lwfinger.net" <Larry.Finger@lwfinger.net>,
	"s.l-h@gmx.de" <s.l-h@gmx.de>,
	"chewitt@libreelec.tv" <chewitt@libreelec.tv>
Subject: Re: [PATCH v3 11/12] wifi: rtlwifi: Add rtl8192du/sw.{c,h}
Date: Tue, 9 Apr 2024 14:16:46 +0300	[thread overview]
Message-ID: <ab85199c-e82b-4ecf-994c-77fb418429bd@gmail.com> (raw)
In-Reply-To: <253da7b1650d47b59114c635e7ad8dc3@realtek.com>

On 09/04/2024 03:27, Ping-Ke Shih wrote:
> 
> 
> Bitterblue Smith <rtl8821cerfe2@gmail.com> wrote:
> 
>>
>> On 08/04/2024 05:45, Ping-Ke Shih wrote:
>>>>
>>>>
>>>> static struct usb_interface *rtl92du_get_other_intf(struct ieee80211_hw *hw)
>>>> {
>>>>         struct usb_interface *intf;
>>>>         struct usb_device *udev;
>>>>         u8 other_interfaceindex;
>>>>
>>>>         /* See SET_IEEE80211_DEV(hw, &intf->dev); in usb.c */
>>>>         intf = container_of_const(wiphy_dev(hw->wiphy), struct usb_interface, dev);
>>>>
>>>>         other_interfaceindex = 1 - intf->altsetting[0].desc.bInterfaceNumber;
>>>
>>> The value of bInterfaceNumber for two instances are 0 and 1, right? Then
>>> '1 - x' to get each other -- that looks a little tricky ;-)
>>>
>>
>> The vendor driver assumes bInterfaceNumber can only be 0 or 1.
>> I can make it more explicit:
>>
>>         if (intf->altsetting[0].desc.bInterfaceNumber == 0)
>>                 other_interfaceindex = 1;
>>         else
>>                 other_interfaceindex = 0;
>>
> 
> That looks easier to understand. 
> 
>>>
>>>>
>>>> static void rtl92du_deinit_shared_data(struct ieee80211_hw *hw)
>>>> {
>>>>         struct usb_interface *other_intf = rtl92du_get_other_intf(hw);
>>>>         struct rtl_priv *rtlpriv = rtl_priv(hw);
>>>>
>>>>         if (!other_intf || usb_get_intfdata(other_intf)) {
>>>>                 /* The other interface doesn't exist or was not disconnected yet. */
>>>
>>> For the USB adaptor with single one interface, you don't have other_intf.
>>> Then, just free them.
>>>
>>> If the USB adaptor has two interfaces, it has both other_intf and
>>> usb_get_intfdata(other_intf), so you want to free them. But, I wonder if both
>>> interfaces can enter this branch?
>>>
>>
>> They can't both enter this branch because after the first
>> disconnect usb_get_intfdata() will return NULL.
>>
>>> Also as I mentioned above, how can you ensure other_intf isn't still using the
>>> shared data?
>>>
>>
>> I can make the second disconnect free the shared data by
>> checking if usb_get_intfdata() returns NULL:
>>
>>         if (!other_intf || !usb_get_intfdata(other_intf)) {
>>                 /* The other interface doesn't exist or was already disconnected. */
>>                 kfree(rtlpriv->curveindex_2g);
> 
> Will usb_get_intfdata(other_intf) return NULL if the intf disconnected? 
> If yes, that looks good to me. 
> 
> 

It should. rtl_usb_disconnect() has usb_set_intfdata(intf, NULL);
at the end. Also usb_unbind_interface() in drivers/usb/core/driver.c
does the same after calling rtl_usb_disconnect().

  reply	other threads:[~2024-04-09 11:16 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 19:32 [PATCH v3 00/12] wifi: rtlwifi: Add new rtl8192du driver Bitterblue Smith
2024-03-20 19:33 ` [PATCH v3 01/12] wifi: rtlwifi: rtl8192de: Fix 5 GHz TX power Bitterblue Smith
2024-03-22  1:25   ` Ping-Ke Shih
2024-03-20 19:34 ` [PATCH v3 02/12] wifi: rtlwifi: Move code from rtl8192de to rtl8192d-common Bitterblue Smith
2024-03-22  2:14   ` Ping-Ke Shih
2024-03-26 13:02     ` Bitterblue Smith
2024-03-20 19:35 ` [PATCH v3 03/12] wifi: rtlwifi: Adjust rtl8192d-common for USB Bitterblue Smith
2024-03-22  3:41   ` Ping-Ke Shih
2024-03-20 19:36 ` [PATCH v3 04/12] wifi: rtlwifi: Add rtl8192du/table.{c,h} Bitterblue Smith
2024-03-22  3:46   ` Ping-Ke Shih
2024-03-26 17:30     ` Bitterblue Smith
2024-03-27  9:18       ` Kalle Valo
2024-03-27  9:30         ` Ping-Ke Shih
2024-03-27 12:36           ` Bitterblue Smith
2024-03-27 12:42             ` Ping-Ke Shih
2024-03-27 12:53             ` Kalle Valo
2024-03-27 16:34           ` Jeff Johnson
2024-03-20 19:37 ` [PATCH v3 05/12] wifi: rtlwifi: Add rtl8192du/hw.{c,h} Bitterblue Smith
2024-03-22  4:02   ` Ping-Ke Shih
2024-03-20 19:38 ` [PATCH v3 06/12] wifi: rtlwifi: Add rtl8192du/phy.{c,h} Bitterblue Smith
2024-03-22  5:22   ` Ping-Ke Shih
2024-03-26 22:13     ` Bitterblue Smith
2024-03-27  1:19       ` Ping-Ke Shih
2024-03-20 19:39 ` [PATCH v3 07/12] wifi: rtlwifi: Add rtl8192du/trx.{c,h} Bitterblue Smith
2024-03-22  5:32   ` Ping-Ke Shih
2024-03-20 19:40 ` [PATCH v3 08/12] wifi: rtlwifi: Add rtl8192du/rf.{c,h} Bitterblue Smith
2024-03-22  5:35   ` Ping-Ke Shih
2024-03-20 19:41 ` [PATCH v3 09/12] wifi: rtlwifi: Add rtl8192du/fw.{c,h} and rtl8192du/led.{c,h} Bitterblue Smith
2024-03-22  5:42   ` Ping-Ke Shih
2024-03-20 19:42 ` [PATCH v3 10/12] wifi: rtlwifi: Add rtl8192du/dm.{c,h} Bitterblue Smith
2024-03-22  5:48   ` Ping-Ke Shih
2024-03-20 19:43 ` [PATCH v3 11/12] wifi: rtlwifi: Add rtl8192du/sw.{c,h} Bitterblue Smith
2024-03-22  6:04   ` Ping-Ke Shih
2024-03-27 14:07     ` Bitterblue Smith
2024-03-27 18:48       ` Kalle Valo
2024-03-27 22:53         ` Bitterblue Smith
2024-03-28  1:46           ` Ping-Ke Shih
2024-03-28 13:31             ` Bitterblue Smith
2024-03-29  0:34               ` Ping-Ke Shih
2024-03-31 18:48                 ` Bitterblue Smith
2024-04-01  1:21                   ` Ping-Ke Shih
2024-04-07 12:03                     ` Bitterblue Smith
2024-04-08  2:45                       ` Ping-Ke Shih
2024-04-08  9:01                         ` Bitterblue Smith
2024-04-09  0:27                           ` Ping-Ke Shih
2024-04-09 11:16                             ` Bitterblue Smith [this message]
2024-03-28  1:49       ` Ping-Ke Shih
2024-03-20 19:44 ` [PATCH v3 12/12] wifi: rtlwifi: Enable the new rtl8192du driver Bitterblue Smith
2024-03-22  6:06   ` Ping-Ke Shih
2024-03-21  1:10 ` [PATCH v3 00/12] wifi: rtlwifi: Add " Stefan Lippers-Hollmann
2024-03-22  6:13 ` [PATCH v3 01/12] wifi: rtlwifi: rtl8192de: Fix 5 GHz TX power Ping-Ke Shih

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=ab85199c-e82b-4ecf-994c-77fb418429bd@gmail.com \
    --to=rtl8821cerfe2@gmail.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=chewitt@libreelec.tv \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    --cc=s.l-h@gmx.de \
    /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).