void wlc_phyreg_enter(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        wlapi_bmac_ucode_wake_override_phyreg_set(pi->sh->physhim);
 }
 
 void wlc_phyreg_exit(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        wlapi_bmac_ucode_wake_override_phyreg_clear(pi->sh->physhim);
 }
 
 void wlc_radioreg_enter(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        wlapi_bmac_mctrl(pi->sh->physhim, MCTL_LOCK_RADIO, MCTL_LOCK_RADIO);
 
        udelay(10);
 
 void wlc_radioreg_exit(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        (void)bcma_read16(pi->d11core, D11REGOFFS(phyversion));
        pi->phy_wreg = 0;
 
 void wlc_phy_detach(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        if (pih) {
                if (--pi->refcnt)
 wlc_phy_get_phyversion(struct brcms_phy_pub *pih, u16 *phytype, u16 *phyrev,
                       u16 *radioid, u16 *radiover)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        *phytype = (u16) pi->pubpi.phy_type;
        *phyrev = (u16) pi->pubpi.phy_rev;
        *radioid = pi->pubpi.radioid;
 
 bool wlc_phy_get_encore(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        return pi->pubpi.abgphy_encore;
 }
 
 u32 wlc_phy_get_coreflags(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        return pi->pubpi.coreflags;
 }
 
 void wlc_phy_anacore(struct brcms_phy_pub *pih, bool on)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        if (ISNPHY(pi)) {
                if (on) {
 
 u32 wlc_phy_clk_bwbits(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        u32 phy_bw_clkbits = 0;
 
 
 void wlc_phy_por_inform(struct brcms_phy_pub *ppi)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        pi->phy_init_por = true;
 }
 
 void wlc_phy_edcrs_lock(struct brcms_phy_pub *pih, bool lock)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        pi->edcrs_threshold_lock = lock;
 
 
 void wlc_phy_initcal_enable(struct brcms_phy_pub *pih, bool initcal)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        pi->do_initcal = initcal;
 }
 
 void wlc_phy_hw_clk_state_upd(struct brcms_phy_pub *pih, bool newstate)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        if (!pi || !pi->sh)
                return;
 
 void wlc_phy_hw_state_upd(struct brcms_phy_pub *pih, bool newstate)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        if (!pi || !pi->sh)
                return;
 {
        u32 mc;
        void (*phy_init)(struct brcms_phy *) = NULL;
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        if (pi->init_in_progress)
                return;
 
 void wlc_phy_cal_init(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        void (*cal_init)(struct brcms_phy *) = NULL;
 
        if (WARN((bcma_read32(pi->d11core, D11REGOFFS(maccontrol)) &
 
 int wlc_phy_down(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        int callbacks = 0;
 
        if (pi->phycal_timer
 
 void wlc_phy_hold_upd(struct brcms_phy_pub *pih, u32 id, bool set)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        if (set)
                mboolset(pi->measure_hold, id);
 
 void wlc_phy_mute_upd(struct brcms_phy_pub *pih, bool mute, u32 flags)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        if (mute)
                mboolset(pi->measure_hold, PHY_HOLD_FOR_MUTE);
 
 void wlc_phy_clear_tssi(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        if (ISNPHY(pi)) {
                return;
 
 void wlc_phy_switch_radio(struct brcms_phy_pub *pih, bool on)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        (void)bcma_read32(pi->d11core, D11REGOFFS(maccontrol));
 
        if (ISNPHY(pi)) {
 
 u16 wlc_phy_bw_state_get(struct brcms_phy_pub *ppi)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        return pi->bw;
 }
 
 void wlc_phy_bw_state_set(struct brcms_phy_pub *ppi, u16 bw)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        pi->bw = bw;
 }
 
 void wlc_phy_chanspec_radio_set(struct brcms_phy_pub *ppi, u16 newch)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
        pi->radio_chanspec = newch;
 
 }
 
 u16 wlc_phy_chanspec_get(struct brcms_phy_pub *ppi)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        return pi->radio_chanspec;
 }
 
 void wlc_phy_chanspec_set(struct brcms_phy_pub *ppi, u16 chanspec)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
        u16 m_cur_channel;
        void (*chanspec_set)(struct brcms_phy *, u16) = NULL;
        m_cur_channel = CHSPEC_CHANNEL(chanspec);
 void wlc_phy_chanspec_ch14_widefilter_set(struct brcms_phy_pub *ppi,
                                          bool wide_filter)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        pi->channel_14_wide_filter = wide_filter;
 
 wlc_phy_chanspec_band_validch(struct brcms_phy_pub *ppi, uint band,
                              struct brcms_chanvec *channels)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
        uint i;
        uint channel;
 
 
 u16 wlc_phy_chanspec_band_firstch(struct brcms_phy_pub *ppi, uint band)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
        uint i;
        uint channel;
        u16 chspec;
 
 int wlc_phy_txpower_get(struct brcms_phy_pub *ppi, uint *qdbm, bool *override)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        *qdbm = pi->tx_user_target[0];
        if (override != NULL)
                                struct txpwr_limits *txpwr)
 {
        bool mac_enabled = false;
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        memcpy(&pi->tx_user_target[TXP_FIRST_CCK],
               &txpwr->cck[0], BRCMS_NUM_RATES_CCK);
 
 int wlc_phy_txpower_set(struct brcms_phy_pub *ppi, uint qdbm, bool override)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
        int i;
 
        if (qdbm > 127)
 wlc_phy_txpower_sromlimit(struct brcms_phy_pub *ppi, uint channel, u8 *min_pwr,
                          u8 *max_pwr, int txp_rate_idx)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
        uint i;
 
        *min_pwr = pi->min_txpower * BRCMS_TXPWR_DB_FACTOR;
 wlc_phy_txpower_sromlimit_max_get(struct brcms_phy_pub *ppi, uint chan,
                                  u8 *max_txpwr, u8 *min_txpwr)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
        u8 tx_pwr_max = 0;
        u8 tx_pwr_min = 255;
        u8 max_num_rate;
 
 u8 wlc_phy_txpower_get_target_min(struct brcms_phy_pub *ppi)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        return pi->tx_power_min;
 }
 
 u8 wlc_phy_txpower_get_target_max(struct brcms_phy_pub *ppi)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        return pi->tx_power_max;
 }
 
 void wlc_phy_txpwr_percent_set(struct brcms_phy_pub *ppi, u8 txpwr_percent)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        pi->txpwr_percent = txpwr_percent;
 }
 
 void wlc_phy_machwcap_set(struct brcms_phy_pub *ppi, u32 machwcap)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        pi->sh->machwcap = machwcap;
 }
 
 void wlc_phy_runbist_config(struct brcms_phy_pub *ppi, bool start_end)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
        u16 rxc;
        rxc = 0;
 
 wlc_phy_txpower_limit_set(struct brcms_phy_pub *ppi, struct txpwr_limits *txpwr,
                          u16 chanspec)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        wlc_phy_txpower_reg_limit_calc(pi, txpwr, chanspec);
 
 
 void wlc_phy_ofdm_rateset_war(struct brcms_phy_pub *pih, bool war)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        pi->ofdm_rateset_war = war;
 }
 
 void wlc_phy_bf_preempt_enable(struct brcms_phy_pub *pih, bool bf_preempt)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        pi->bf_preempt_4306 = bf_preempt;
 }
 
 bool wlc_phy_txpower_hw_ctrl_get(struct brcms_phy_pub *ppi)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        if (ISNPHY(pi))
                return pi->nphy_txpwrctrl;
 
 void wlc_phy_txpower_hw_ctrl_set(struct brcms_phy_pub *ppi, bool hwpwrctrl)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
        bool suspend;
 
        if (!pi->hwpwrctrl_capable)
 wlc_phy_txpower_get_current(struct brcms_phy_pub *ppi, struct tx_power *power,
                            uint channel)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
        uint rate, num_rates;
        u8 min_pwr, max_pwr;
 
 
 void wlc_phy_antsel_type_set(struct brcms_phy_pub *ppi, u8 antsel_type)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        pi->antsel_type = antsel_type;
 }
 
 bool wlc_phy_test_ison(struct brcms_phy_pub *ppi)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        return pi->phytest_on;
 }
 
 void wlc_phy_ant_rxdiv_set(struct brcms_phy_pub *ppi, u8 val)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
        bool suspend;
 
        pi->sh->rx_antdiv = val;
 
 void wlc_phy_noise_sample_intr(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        u16 jssi_aux;
        u8 channel = 0;
        s8 noise_dbm = PHY_NOISE_FIXED_VAL_NPHY;
 static void
 wlc_phy_noise_sample_request(struct brcms_phy_pub *pih, u8 reason, u8 ch)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        s8 noise_dbm = PHY_NOISE_FIXED_VAL_NPHY;
        bool sampling_in_progress = (pi->phynoise_state != 0);
        bool wait_for_intr = true;
 {
        int rssi = rxh->PhyRxStatus_1 & PRXS1_JSSI_MASK;
        uint radioid = pih->radioid;
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        if ((pi->sh->corerev >= 11)
            && !(rxh->RxStatus2 & RXS_PHYRXST_VALID)) {
 
 void wlc_phy_watchdog(struct brcms_phy_pub *pih)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        bool delay_phy_cal = false;
        pi->sh->now++;
 
 
 void wlc_phy_BSSinit(struct brcms_phy_pub *pih, bool bonlyap, int rssi)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        uint i;
        uint k;
 
        s16 nphy_currtemp = 0;
        s16 delta_temp = 0;
        bool do_periodic_cal = true;
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        if (!ISNPHY(pi))
                return;
 
 void wlc_phy_stf_chain_init(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        pi->sh->hw_phytxchain = txchain;
        pi->sh->hw_phyrxchain = rxchain;
 
 void wlc_phy_stf_chain_set(struct brcms_phy_pub *pih, u8 txchain, u8 rxchain)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        pi->sh->phytxchain = txchain;
 
 
 void wlc_phy_stf_chain_get(struct brcms_phy_pub *pih, u8 *txchain, u8 *rxchain)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        *txchain = pi->sh->phytxchain;
        *rxchain = pi->sh->phyrxchain;
 {
        s16 nphy_currtemp;
        u8 active_bitmap;
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
 
        active_bitmap = (pi->phy_txcore_heatedup) ? 0x31 : 0x33;
 
 
 s8 wlc_phy_stf_ssmode_get(struct brcms_phy_pub *pih, u16 chanspec)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) pih;
+       struct brcms_phy *pi = container_of(pih, struct brcms_phy, pubpi_ro);
        u8 siso_mcs_id, cdd_mcs_id;
 
        siso_mcs_id =
 
 bool wlc_phy_txpower_ipa_ison(struct brcms_phy_pub *ppi)
 {
-       struct brcms_phy *pi = (struct brcms_phy *) ppi;
+       struct brcms_phy *pi = container_of(ppi, struct brcms_phy, pubpi_ro);
 
        if (ISNPHY(pi))
                return wlc_phy_n_txpower_ipa_ison(pi);