summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/b43/phy_g.c
diff options
context:
space:
mode:
authorMichael Buesch <mb@bu3sch.de>2008-09-02 15:00:34 +0400
committerJohn W. Linville <linville@tuxdriver.com>2008-09-06 00:17:49 +0400
commitfb11137af83b7b66c7aab8dbc5f09d2c95684fed (patch)
tree08251ad486eb4c115f56ee4ddfb56a80c2d7c287 /drivers/net/wireless/b43/phy_g.c
parent7cb770729ba895f73253dfcd46c3fcba45d896f9 (diff)
downloadlinux-fb11137af83b7b66c7aab8dbc5f09d2c95684fed.tar.xz
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)
{
struct b43_phy_g *gphy;
struct b43_txpower_lo_control *lo;
- int err, i;
+ int err;
gphy = kzalloc(sizeof(*gphy), GFP_KERNEL);
if (!gphy) {
@@ -2644,6 +2644,51 @@ static int b43_gphy_op_allocate(struct b43_wldev *dev)
}
dev->phy.g = gphy;
+ lo = kzalloc(sizeof(*lo), GFP_KERNEL);
+ if (!lo) {
+ err = -ENOMEM;
+ goto err_free_gphy;
+ }
+ gphy->lo_control = lo;
+
+ err = b43_gphy_init_tssi2dbm_table(dev);
+ if (err)
+ goto err_free_lo;
+
+ return 0;
+
+err_free_lo:
+ kfree(lo);
+err_free_gphy:
+ kfree(gphy);
+error:
+ return err;
+}
+
+static void b43_gphy_op_prepare_structs(struct b43_wldev *dev)
+{
+ struct b43_phy *phy = &dev->phy;
+ struct b43_phy_g *gphy = phy->g;
+ const void *tssi2dbm;
+ int tgt_idle_tssi;
+ struct b43_txpower_lo_control *lo;
+ unsigned int i;
+
+ /* tssi2dbm table is constant, so it is initialized at alloc time.
+ * Save a copy of the pointer. */
+ tssi2dbm = gphy->tssi2dbm;
+ tgt_idle_tssi = gphy->tgt_idle_tssi;
+ /* Save the LO pointer. */
+ lo = gphy->lo_control;
+
+ /* Zero out the whole PHY structure. */
+ memset(gphy, 0, sizeof(*gphy));
+
+ /* Restore pointers. */
+ gphy->tssi2dbm = tssi2dbm;
+ gphy->tgt_idle_tssi = tgt_idle_tssi;
+ gphy->lo_control = lo;
+
memset(gphy->minlowsig, 0xFF, sizeof(gphy->minlowsig));
/* NRSSI */
@@ -2662,31 +2707,28 @@ static int b43_gphy_op_allocate(struct b43_wldev *dev)
gphy->average_tssi = 0xFF;
- lo = kzalloc(sizeof(*lo), GFP_KERNEL);
- if (!lo) {
- err = -ENOMEM;
- goto err_free_gphy;
- }
- gphy->lo_control = lo;
-
+ /* Local Osciallator structure */
lo->tx_bias = 0xFF;
INIT_LIST_HEAD(&lo->calib_list);
+}
- err = b43_gphy_init_tssi2dbm_table(dev);
- if (err)
- goto err_free_lo;
+static void b43_gphy_op_free(struct b43_wldev *dev)
+{
+ struct b43_phy *phy = &dev->phy;
+ struct b43_phy_g *gphy = phy->g;
- return 0;
+ kfree(gphy->lo_control);
+
+ if (gphy->dyn_tssi_tbl)
+ kfree(gphy->tssi2dbm);
+ gphy->dyn_tssi_tbl = 0;
+ gphy->tssi2dbm = NULL;
-err_free_lo:
- kfree(lo);
-err_free_gphy:
kfree(gphy);
-error:
- return err;
+ dev->phy.g = NULL;
}
-static int b43_gphy_op_prepare(struct b43_wldev *dev)
+static int b43_gphy_op_prepare_hardware(struct b43_wldev *dev)
{
struct b43_phy *phy = &dev->phy;
struct b43_phy_g *gphy = phy->g;
@@ -2718,28 +2760,14 @@ static int b43_gphy_op_prepare(struct b43_wldev *dev)
static int b43_gphy_op_init(struct b43_wldev *dev)
{
- struct b43_phy_g *gphy = dev->phy.g;
-
b43_phy_initg(dev);
- gphy->initialised = 1;
return 0;
}
static void b43_gphy_op_exit(struct b43_wldev *dev)
{
- struct b43_phy_g *gphy = dev->phy.g;
-
- if (gphy->initialised) {
- //TODO
- gphy->initialised = 0;
- }
b43_lo_g_cleanup(dev);
- kfree(gphy->lo_control);
- if (gphy->dyn_tssi_tbl)
- kfree(gphy->tssi2dbm);
- kfree(gphy);
- dev->phy.g = NULL;
}
static 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)
const struct b43_phy_operations b43_phyops_g = {
.allocate = b43_gphy_op_allocate,
- .prepare = b43_gphy_op_prepare,
+ .free = b43_gphy_op_free,
+ .prepare_structs = b43_gphy_op_prepare_structs,
+ .prepare_hardware = b43_gphy_op_prepare_hardware,
.init = b43_gphy_op_init,
.exit = b43_gphy_op_exit,
.phy_read = b43_gphy_op_read,