Bitterblue Smith <rtl8821cerfe2@xxxxxxxxx> wrote: > These contain the new module's entry point. > > Signed-off-by: Bitterblue Smith <rtl8821cerfe2@xxxxxxxxx> > --- > .../wireless/realtek/rtlwifi/rtl8192du/sw.c | 397 ++++++++++++++++++ Subject is "wifi: rtlwifi: Add rtl8192du/sw.{c,h}", but actually you don't have sw.h. > 1 file changed, 397 insertions(+) > create mode 100644 drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c > > diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c > b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c > new file mode 100644 > index 000000000000..18a855b041c3 > --- /dev/null > +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c > @@ -0,0 +1,397 @@ [...] > + > +static int rtl92du_init_shared_data(struct ieee80211_hw *hw) > +{ > + struct usb_interface *other_intf = rtl92du_get_other_intf(hw); > + struct rtl_priv *rtlpriv = rtl_priv(hw); > + struct rtl_priv *other_rtlpriv = NULL; > + struct ieee80211_hw *other_hw = NULL; > + > + if (other_intf) > + other_hw = usb_get_intfdata(other_intf); > + > + if (other_hw) { > + /* The other interface was already probed. */ > + other_rtlpriv = rtl_priv(other_hw); > + rtlpriv->curveindex_2g = other_rtlpriv->curveindex_2g; > + rtlpriv->curveindex_5g = other_rtlpriv->curveindex_5g; > + rtlpriv->mutex_for_power_on_off = other_rtlpriv->mutex_for_power_on_off; > + rtlpriv->mutex_for_hw_init = other_rtlpriv->mutex_for_hw_init; > + > + if (!rtlpriv->curveindex_2g || !rtlpriv->curveindex_5g || > + !rtlpriv->mutex_for_power_on_off || !rtlpriv->mutex_for_hw_init) > + return 1; return standard errno. > + > + return 0; > + } > + > + /* The other interface doesn't exist or was not probed yet. */ > + rtlpriv->curveindex_2g = kcalloc(TARGET_CHNL_NUM_2G, > + sizeof(*rtlpriv->curveindex_2g), > + GFP_KERNEL); > + rtlpriv->curveindex_5g = kcalloc(TARGET_CHNL_NUM_5G, > + sizeof(*rtlpriv->curveindex_5g), > + GFP_KERNEL); > + rtlpriv->mutex_for_power_on_off = > + kzalloc(sizeof(*rtlpriv->mutex_for_power_on_off), GFP_KERNEL); > + rtlpriv->mutex_for_hw_init = > + kzalloc(sizeof(*rtlpriv->mutex_for_hw_init), GFP_KERNEL); > + > + if (!rtlpriv->curveindex_2g || !rtlpriv->curveindex_5g || > + !rtlpriv->mutex_for_power_on_off || !rtlpriv->mutex_for_hw_init) { > + kfree(rtlpriv->curveindex_2g); > + kfree(rtlpriv->curveindex_5g); > + kfree(rtlpriv->mutex_for_power_on_off); > + kfree(rtlpriv->mutex_for_hw_init); > + rtlpriv->curveindex_2g = NULL; > + rtlpriv->curveindex_5g = NULL; > + rtlpriv->mutex_for_power_on_off = NULL; > + rtlpriv->mutex_for_hw_init = NULL; > + return 1; ditto. > + } > + > + mutex_init(rtlpriv->mutex_for_power_on_off); > + mutex_init(rtlpriv->mutex_for_hw_init); > + > + return 0; > +} > + > +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 already disconnected. */ > + kfree(rtlpriv->curveindex_2g); > + kfree(rtlpriv->curveindex_5g); > + if (rtlpriv->mutex_for_power_on_off) > + mutex_destroy(rtlpriv->mutex_for_power_on_off); > + if (rtlpriv->mutex_for_hw_init) > + mutex_destroy(rtlpriv->mutex_for_hw_init); > + kfree(rtlpriv->mutex_for_power_on_off); > + kfree(rtlpriv->mutex_for_hw_init); > + } > +} > + > +static int rtl92du_init_sw_vars(struct ieee80211_hw *hw) > +{ > + const char *fw_name = "rtlwifi/rtl8192dufw.bin"; > + struct rtl_priv *rtlpriv = rtl_priv(hw); > + int err; > + > + if (rtl92du_init_shared_data(hw)) > + return 1; return standard errno. > + > + rtlpriv->dm.dm_initialgain_enable = true; > + rtlpriv->dm.dm_flag = 0; > + rtlpriv->dm.disable_framebursting = false; > + rtlpriv->dm.thermalvalue = 0; > + rtlpriv->dm.useramask = true; > + > + /* dual mac */ > + if (rtlpriv->rtlhal.current_bandtype == BAND_ON_5G) > + rtlpriv->phy.current_channel = 36; > + else > + rtlpriv->phy.current_channel = 1; > + > + if (rtlpriv->rtlhal.macphymode != SINGLEMAC_SINGLEPHY) > + rtlpriv->rtlhal.disable_amsdu_8k = true; > + > + /* for LPS & IPS */ > + rtlpriv->psc.inactiveps = rtlpriv->cfg->mod_params->inactiveps; > + rtlpriv->psc.swctrl_lps = rtlpriv->cfg->mod_params->swctrl_lps; > + rtlpriv->psc.fwctrl_lps = rtlpriv->cfg->mod_params->fwctrl_lps; > + if (!rtlpriv->psc.inactiveps) > + pr_info("Inactive Power Save off (module option)\n"); > + > + /* for early mode */ > + rtlpriv->rtlhal.earlymode_enable = false; > + > + /* for firmware buf */ > + rtlpriv->rtlhal.pfirmware = kmalloc(0x8000, GFP_KERNEL); > + if (!rtlpriv->rtlhal.pfirmware) > + return 1; ditto. > + > + rtlpriv->max_fw_size = 0x8000; > + pr_info("Driver for Realtek RTL8192DU WLAN interface\n"); > + pr_info("Loading firmware file %s\n", fw_name); > + > + /* request fw */ > + err = request_firmware_nowait(THIS_MODULE, 1, fw_name, > + rtlpriv->io.dev, GFP_KERNEL, hw, > + rtl_fw_cb); > + if (err) { > + pr_err("Failed to request firmware!\n"); > + kfree(rtlpriv->rtlhal.pfirmware); > + rtlpriv->rtlhal.pfirmware = NULL; > + return 1; ditto. > + } > + > + return 0; > +} > + [...]