diff options
author | Ivo van Doorn <ivdoorn@gmail.com> | 2008-12-02 12:20:22 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-12-05 09:35:50 -0500 |
commit | 0b927a079106e5f66c736e297370d3feb008e28e (patch) | |
tree | 4484805e93961dd362c6c2bff183f1d62c9998c7 /drivers/net/wireless/rt2x00/rt2x00config.c | |
parent | 42c8285767dd17f450d986bdb163a8d56fb0330a (diff) |
rt2x00: Remove duplicate code
Simplify rt2x00lib_config_antenna() by moving
duplicate code into a seperate static inlined
function.
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00config.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00config.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00config.c b/drivers/net/wireless/rt2x00/rt2x00config.c index b3bc8b49be83..e66fb316cd61 100644 --- a/drivers/net/wireless/rt2x00/rt2x00config.c +++ b/drivers/net/wireless/rt2x00/rt2x00config.c | |||
@@ -108,33 +108,34 @@ void rt2x00lib_config_erp(struct rt2x00_dev *rt2x00dev, | |||
108 | rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp); | 108 | rt2x00dev->ops->lib->config_erp(rt2x00dev, &erp); |
109 | } | 109 | } |
110 | 110 | ||
111 | static inline | ||
112 | enum antenna rt2x00lib_config_antenna_check(enum antenna current_ant, | ||
113 | enum antenna default_ant) | ||
114 | { | ||
115 | if (current_ant != ANTENNA_SW_DIVERSITY) | ||
116 | return current_ant; | ||
117 | return (default_ant != ANTENNA_SW_DIVERSITY) ? default_ant : ANTENNA_B; | ||
118 | } | ||
119 | |||
111 | void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev, | 120 | void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev, |
112 | struct antenna_setup *ant) | 121 | struct antenna_setup *ant) |
113 | { | 122 | { |
123 | struct antenna_setup *def = &rt2x00dev->default_ant; | ||
124 | struct antenna_setup *active = &rt2x00dev->link.ant.active; | ||
125 | |||
114 | /* | 126 | /* |
115 | * Failsafe: Make sure we are not sending the | 127 | * Failsafe: Make sure we are not sending the |
116 | * ANTENNA_SW_DIVERSITY state to the driver. | 128 | * ANTENNA_SW_DIVERSITY state to the driver. |
117 | * If that happes fallback to hardware default, | 129 | * If that happes fallback to hardware default, |
118 | * or our own default. | 130 | * or our own default. |
131 | * The calls to rt2x00lib_config_antenna_check() | ||
132 | * might have caused that we restore back to the already | ||
133 | * active setting. If that has happened we can quit. | ||
119 | */ | 134 | */ |
120 | if (ant->rx == ANTENNA_SW_DIVERSITY) { | 135 | ant->rx = rt2x00lib_config_antenna_check(ant->rx, def->rx); |
121 | if (rt2x00dev->default_ant.rx == ANTENNA_SW_DIVERSITY) | 136 | ant->tx = rt2x00lib_config_antenna_check(ant->tx, def->tx); |
122 | ant->rx = ANTENNA_B; | ||
123 | else | ||
124 | ant->rx = rt2x00dev->default_ant.rx; | ||
125 | } | ||
126 | if (ant->tx == ANTENNA_SW_DIVERSITY) { | ||
127 | if (rt2x00dev->default_ant.tx == ANTENNA_SW_DIVERSITY) | ||
128 | ant->tx = ANTENNA_B; | ||
129 | else | ||
130 | ant->tx = rt2x00dev->default_ant.tx; | ||
131 | } | ||
132 | 137 | ||
133 | /* | 138 | if (ant->rx == active->rx && ant->tx == active->tx) |
134 | * Only reconfigure when something has changed. | ||
135 | */ | ||
136 | if (ant->rx == rt2x00dev->link.ant.active.rx && | ||
137 | ant->tx == rt2x00dev->link.ant.active.tx) | ||
138 | return; | 139 | return; |
139 | 140 | ||
140 | /* | 141 | /* |
@@ -154,7 +155,7 @@ void rt2x00lib_config_antenna(struct rt2x00_dev *rt2x00dev, | |||
154 | rt2x00lib_reset_link_tuner(rt2x00dev); | 155 | rt2x00lib_reset_link_tuner(rt2x00dev); |
155 | rt2x00_reset_link_ant_rssi(&rt2x00dev->link); | 156 | rt2x00_reset_link_ant_rssi(&rt2x00dev->link); |
156 | 157 | ||
157 | memcpy(&rt2x00dev->link.ant.active, ant, sizeof(*ant)); | 158 | memcpy(active, ant, sizeof(*ant)); |
158 | 159 | ||
159 | if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) | 160 | if (test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags)) |
160 | rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON_LINK); | 161 | rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_ON_LINK); |