aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/b43/phy_g.c
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2008-09-02 07:00:34 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-09-05 16:17:49 -0400
commitfb11137af83b7b66c7aab8dbc5f09d2c95684fed (patch)
tree08251ad486eb4c115f56ee4ddfb56a80c2d7c287 /drivers/net/wireless/b43/phy_g.c
parent7cb770729ba895f73253dfcd46c3fcba45d896f9 (diff)
b43: Split PHY alloc and init
This splits the PHY allocation from the PHY init. This is needed in order to properly support Analog handling. Signed-off-by: Michael Buesch <mb@bu3sch.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/b43/phy_g.c')
-rw-r--r--drivers/net/wireless/b43/phy_g.c96
1 files changed, 63 insertions, 33 deletions
diff --git a/drivers/net/wireless/b43/phy_g.c b/drivers/net/wireless/b43/phy_g.c
index 063db5c00ce7..b44740b24e71 100644
--- a/drivers/net/wireless/b43/phy_g.c
+++ b/drivers/net/wireless/b43/phy_g.c
@@ -2635,7 +2635,7 @@ static int b43_gphy_op_allocate(struct b43_wldev *dev)
2635{ 2635{
2636 struct b43_phy_g *gphy; 2636 struct b43_phy_g *gphy;
2637 struct b43_txpower_lo_control *lo; 2637 struct b43_txpower_lo_control *lo;
2638 int err, i; 2638 int err;
2639 2639
2640 gphy = kzalloc(sizeof(*gphy), GFP_KERNEL); 2640 gphy = kzalloc(sizeof(*gphy), GFP_KERNEL);
2641 if (!gphy) { 2641 if (!gphy) {
@@ -2644,6 +2644,51 @@ static int b43_gphy_op_allocate(struct b43_wldev *dev)
2644 } 2644 }
2645 dev->phy.g = gphy; 2645 dev->phy.g = gphy;
2646 2646
2647 lo = kzalloc(sizeof(*lo), GFP_KERNEL);
2648 if (!lo) {
2649 err = -ENOMEM;
2650 goto err_free_gphy;
2651 }
2652 gphy->lo_control = lo;
2653
2654 err = b43_gphy_init_tssi2dbm_table(dev);
2655 if (err)
2656 goto err_free_lo;
2657
2658 return 0;
2659
2660err_free_lo:
2661 kfree(lo);
2662err_free_gphy:
2663 kfree(gphy);
2664error:
2665 return err;
2666}
2667
2668static void b43_gphy_op_prepare_structs(struct b43_wldev *dev)
2669{
2670 struct b43_phy *phy = &dev->phy;
2671 struct b43_phy_g *gphy = phy->g;
2672 const void *tssi2dbm;
2673 int tgt_idle_tssi;
2674 struct b43_txpower_lo_control *lo;
2675 unsigned int i;
2676
2677 /* tssi2dbm table is constant, so it is initialized at alloc time.
2678 * Save a copy of the pointer. */
2679 tssi2dbm = gphy->tssi2dbm;
2680 tgt_idle_tssi = gphy->tgt_idle_tssi;
2681 /* Save the LO pointer. */
2682 lo = gphy->lo_control;
2683
2684 /* Zero out the whole PHY structure. */
2685 memset(gphy, 0, sizeof(*gphy));
2686
2687 /* Restore pointers. */
2688 gphy->tssi2dbm = tssi2dbm;
2689 gphy->tgt_idle_tssi = tgt_idle_tssi;
2690 gphy->lo_control = lo;
2691
2647 memset(gphy->minlowsig, 0xFF, sizeof(gphy->minlowsig)); 2692 memset(gphy->minlowsig, 0xFF, sizeof(gphy->minlowsig));
2648 2693
2649 /* NRSSI */ 2694 /* NRSSI */
@@ -2662,31 +2707,28 @@ static int b43_gphy_op_allocate(struct b43_wldev *dev)
2662 2707
2663 gphy->average_tssi = 0xFF; 2708 gphy->average_tssi = 0xFF;
2664 2709
2665 lo = kzalloc(sizeof(*lo), GFP_KERNEL); 2710 /* Local Osciallator structure */
2666 if (!lo) {
2667 err = -ENOMEM;
2668 goto err_free_gphy;
2669 }
2670 gphy->lo_control = lo;
2671
2672 lo->tx_bias = 0xFF; 2711 lo->tx_bias = 0xFF;
2673 INIT_LIST_HEAD(&lo->calib_list); 2712 INIT_LIST_HEAD(&lo->calib_list);
2713}
2674 2714
2675 err = b43_gphy_init_tssi2dbm_table(dev); 2715static void b43_gphy_op_free(struct b43_wldev *dev)
2676 if (err) 2716{
2677 goto err_free_lo; 2717 struct b43_phy *phy = &dev->phy;
2718 struct b43_phy_g *gphy = phy->g;
2678 2719
2679 return 0; 2720 kfree(gphy->lo_control);
2721
2722 if (gphy->dyn_tssi_tbl)
2723 kfree(gphy->tssi2dbm);
2724 gphy->dyn_tssi_tbl = 0;
2725 gphy->tssi2dbm = NULL;
2680 2726
2681err_free_lo:
2682 kfree(lo);
2683err_free_gphy:
2684 kfree(gphy); 2727 kfree(gphy);
2685error: 2728 dev->phy.g = NULL;
2686 return err;
2687} 2729}
2688 2730
2689static int b43_gphy_op_prepare(struct b43_wldev *dev) 2731static int b43_gphy_op_prepare_hardware(struct b43_wldev *dev)
2690{ 2732{
2691 struct b43_phy *phy = &dev->phy; 2733 struct b43_phy *phy = &dev->phy;
2692 struct b43_phy_g *gphy = phy->g; 2734 struct b43_phy_g *gphy = phy->g;
@@ -2718,28 +2760,14 @@ static int b43_gphy_op_prepare(struct b43_wldev *dev)
2718 2760
2719static int b43_gphy_op_init(struct b43_wldev *dev) 2761static int b43_gphy_op_init(struct b43_wldev *dev)
2720{ 2762{
2721 struct b43_phy_g *gphy = dev->phy.g;
2722
2723 b43_phy_initg(dev); 2763 b43_phy_initg(dev);
2724 gphy->initialised = 1;
2725 2764
2726 return 0; 2765 return 0;
2727} 2766}
2728 2767
2729static void b43_gphy_op_exit(struct b43_wldev *dev) 2768static void b43_gphy_op_exit(struct b43_wldev *dev)
2730{ 2769{
2731 struct b43_phy_g *gphy = dev->phy.g;
2732
2733 if (gphy->initialised) {
2734 //TODO
2735 gphy->initialised = 0;
2736 }
2737 b43_lo_g_cleanup(dev); 2770 b43_lo_g_cleanup(dev);
2738 kfree(gphy->lo_control);
2739 if (gphy->dyn_tssi_tbl)
2740 kfree(gphy->tssi2dbm);
2741 kfree(gphy);
2742 dev->phy.g = NULL;
2743} 2771}
2744 2772
2745static u16 b43_gphy_op_read(struct b43_wldev *dev, u16 reg) 2773static u16 b43_gphy_op_read(struct b43_wldev *dev, u16 reg)
@@ -3232,7 +3260,9 @@ static void b43_gphy_op_pwork_60sec(struct b43_wldev *dev)
3232 3260
3233const struct b43_phy_operations b43_phyops_g = { 3261const struct b43_phy_operations b43_phyops_g = {
3234 .allocate = b43_gphy_op_allocate, 3262 .allocate = b43_gphy_op_allocate,
3235 .prepare = b43_gphy_op_prepare, 3263 .free = b43_gphy_op_free,
3264 .prepare_structs = b43_gphy_op_prepare_structs,
3265 .prepare_hardware = b43_gphy_op_prepare_hardware,
3236 .init = b43_gphy_op_init, 3266 .init = b43_gphy_op_init,
3237 .exit = b43_gphy_op_exit, 3267 .exit = b43_gphy_op_exit,
3238 .phy_read = b43_gphy_op_read, 3268 .phy_read = b43_gphy_op_read,