@@ -411,13 +411,15 @@ mt76_check_sband(struct mt76_phy *phy, struct mt76_sband *msband,
411
411
}
412
412
413
413
if (found ) {
414
- phy -> chandef .chan = & sband -> channels [0 ];
414
+ cfg80211_chandef_create (& phy -> chandef , & sband -> channels [0 ],
415
+ NL80211_CHAN_HT20 );
415
416
phy -> chan_state = & msband -> chan [0 ];
416
417
return ;
417
418
}
418
419
419
420
sband -> n_channels = 0 ;
420
- phy -> hw -> wiphy -> bands [band ] = NULL ;
421
+ if (phy -> hw -> wiphy -> bands [band ] == sband )
422
+ phy -> hw -> wiphy -> bands [band ] = NULL ;
421
423
}
422
424
423
425
static int
@@ -429,6 +431,9 @@ mt76_phy_init(struct mt76_phy *phy, struct ieee80211_hw *hw)
429
431
INIT_LIST_HEAD (& phy -> tx_list );
430
432
spin_lock_init (& phy -> tx_lock );
431
433
434
+ if ((void * )phy != hw -> priv )
435
+ return 0 ;
436
+
432
437
SET_IEEE80211_DEV (hw , dev -> dev );
433
438
SET_IEEE80211_PERM_ADDR (hw , phy -> macaddr );
434
439
@@ -480,6 +485,28 @@ mt76_phy_init(struct mt76_phy *phy, struct ieee80211_hw *hw)
480
485
return 0 ;
481
486
}
482
487
488
+ struct mt76_phy *
489
+ mt76_alloc_radio_phy (struct mt76_dev * dev , unsigned int size ,
490
+ u8 band_idx )
491
+ {
492
+ struct ieee80211_hw * hw = dev -> phy .hw ;
493
+ unsigned int phy_size ;
494
+ struct mt76_phy * phy ;
495
+
496
+ phy_size = ALIGN (sizeof (* phy ), 8 );
497
+ phy = devm_kzalloc (dev -> dev , size + phy_size , GFP_KERNEL );
498
+ if (!phy )
499
+ return NULL ;
500
+
501
+ phy -> dev = dev ;
502
+ phy -> hw = hw ;
503
+ phy -> priv = (void * )phy + phy_size ;
504
+ phy -> band_idx = band_idx ;
505
+
506
+ return phy ;
507
+ }
508
+ EXPORT_SYMBOL_GPL (mt76_alloc_radio_phy );
509
+
483
510
struct mt76_phy *
484
511
mt76_alloc_phy (struct mt76_dev * dev , unsigned int size ,
485
512
const struct ieee80211_ops * ops , u8 band_idx )
@@ -552,9 +579,11 @@ int mt76_register_phy(struct mt76_phy *phy, bool vht,
552
579
mt76_check_sband (phy , & phy -> sband_5g , NL80211_BAND_5GHZ );
553
580
mt76_check_sband (phy , & phy -> sband_6g , NL80211_BAND_6GHZ );
554
581
555
- ret = ieee80211_register_hw (phy -> hw );
556
- if (ret )
557
- return ret ;
582
+ if ((void * )phy == phy -> hw -> priv ) {
583
+ ret = ieee80211_register_hw (phy -> hw );
584
+ if (ret )
585
+ return ret ;
586
+ }
558
587
559
588
set_bit (MT76_STATE_REGISTERED , & phy -> state );
560
589
phy -> dev -> phys [phy -> band_idx ] = phy ;
0 commit comments