diff options
author | David Woodhouse <dwmw2@infradead.org> | 2007-12-17 23:48:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:07:49 -0500 |
commit | 3fbe104cecdb8c812976fdb0cc41be65491b85ee (patch) | |
tree | 768ab4fb16f26289f0ad5dc6d413fc5a0cf1eaf5 /drivers/net/wireless/libertas | |
parent | 6e5cc4fb35c45a8f8478d25c4e89e8d9c543056e (diff) |
libertas: convert SLEEP_PARAMS to a direct command
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas')
-rw-r--r-- | drivers/net/wireless/libertas/cmd.c | 56 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/cmd.h | 2 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/cmdresp.c | 26 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/debugfs.c | 66 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/dev.h | 15 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/hostcmd.h | 7 |
6 files changed, 74 insertions, 98 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index 57d17077a6d8..3d9ad0ec9542 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -198,33 +198,45 @@ int lbs_cmd_802_11_inactivity_timeout(struct lbs_private *priv, | |||
198 | return 0; | 198 | return 0; |
199 | } | 199 | } |
200 | 200 | ||
201 | static int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, | 201 | int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, uint16_t cmd_action, |
202 | struct cmd_ds_command *cmd, | 202 | struct sleep_params *sp) |
203 | u16 cmd_action) | ||
204 | { | 203 | { |
205 | struct cmd_ds_802_11_sleep_params *sp = &cmd->params.sleep_params; | 204 | struct cmd_ds_802_11_sleep_params cmd; |
205 | int ret; | ||
206 | 206 | ||
207 | lbs_deb_enter(LBS_DEB_CMD); | 207 | lbs_deb_enter(LBS_DEB_CMD); |
208 | 208 | ||
209 | cmd->size = cpu_to_le16((sizeof(struct cmd_ds_802_11_sleep_params)) + | ||
210 | S_DS_GEN); | ||
211 | cmd->command = cpu_to_le16(CMD_802_11_SLEEP_PARAMS); | ||
212 | |||
213 | if (cmd_action == CMD_ACT_GET) { | 209 | if (cmd_action == CMD_ACT_GET) { |
214 | memset(&priv->sp, 0, sizeof(struct sleep_params)); | 210 | memset(&cmd, 0, sizeof(cmd)); |
215 | memset(sp, 0, sizeof(struct cmd_ds_802_11_sleep_params)); | 211 | } else { |
216 | sp->action = cpu_to_le16(cmd_action); | 212 | cmd.error = cpu_to_le16(sp->sp_error); |
217 | } else if (cmd_action == CMD_ACT_SET) { | 213 | cmd.offset = cpu_to_le16(sp->sp_offset); |
218 | sp->action = cpu_to_le16(cmd_action); | 214 | cmd.stabletime = cpu_to_le16(sp->sp_stabletime); |
219 | sp->error = cpu_to_le16(priv->sp.sp_error); | 215 | cmd.calcontrol = sp->sp_calcontrol; |
220 | sp->offset = cpu_to_le16(priv->sp.sp_offset); | 216 | cmd.externalsleepclk = sp->sp_extsleepclk; |
221 | sp->stabletime = cpu_to_le16(priv->sp.sp_stabletime); | 217 | cmd.reserved = cpu_to_le16(sp->sp_reserved); |
222 | sp->calcontrol = (u8) priv->sp.sp_calcontrol; | ||
223 | sp->externalsleepclk = (u8) priv->sp.sp_extsleepclk; | ||
224 | sp->reserved = cpu_to_le16(priv->sp.sp_reserved); | ||
225 | } | 218 | } |
219 | cmd.hdr.size = cpu_to_le16(sizeof(cmd)); | ||
220 | cmd.action = cpu_to_le16(cmd_action); | ||
226 | 221 | ||
227 | lbs_deb_leave(LBS_DEB_CMD); | 222 | ret = lbs_cmd_with_response(priv, CMD_802_11_SLEEP_PARAMS, &cmd); |
223 | |||
224 | if (!ret) { | ||
225 | lbs_deb_cmd("error 0x%x, offset 0x%x, stabletime 0x%x, " | ||
226 | "calcontrol 0x%x extsleepclk 0x%x\n", | ||
227 | le16_to_cpu(cmd.error), le16_to_cpu(cmd.offset), | ||
228 | le16_to_cpu(cmd.stabletime), cmd.calcontrol, | ||
229 | cmd.externalsleepclk); | ||
230 | |||
231 | sp->sp_error = le16_to_cpu(cmd.error); | ||
232 | sp->sp_offset = le16_to_cpu(cmd.offset); | ||
233 | sp->sp_stabletime = le16_to_cpu(cmd.stabletime); | ||
234 | sp->sp_calcontrol = cmd.calcontrol; | ||
235 | sp->sp_extsleepclk = cmd.externalsleepclk; | ||
236 | sp->sp_reserved = le16_to_cpu(cmd.reserved); | ||
237 | } | ||
238 | |||
239 | lbs_deb_leave_args(LBS_DEB_CMD, "ret %d", ret); | ||
228 | return 0; | 240 | return 0; |
229 | } | 241 | } |
230 | 242 | ||
@@ -1520,10 +1532,6 @@ int lbs_prepare_and_send_command(struct lbs_private *priv, | |||
1520 | cmd_no, cmd_action); | 1532 | cmd_no, cmd_action); |
1521 | break; | 1533 | break; |
1522 | 1534 | ||
1523 | case CMD_802_11_SLEEP_PARAMS: | ||
1524 | ret = lbs_cmd_802_11_sleep_params(priv, cmdptr, cmd_action); | ||
1525 | break; | ||
1526 | |||
1527 | case CMD_802_11_TPC_CFG: | 1535 | case CMD_802_11_TPC_CFG: |
1528 | cmdptr->command = cpu_to_le16(CMD_802_11_TPC_CFG); | 1536 | cmdptr->command = cpu_to_le16(CMD_802_11_TPC_CFG); |
1529 | cmdptr->size = | 1537 | cmdptr->size = |
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h index 50821e76a883..ca09b1803d15 100644 --- a/drivers/net/wireless/libertas/cmd.h +++ b/drivers/net/wireless/libertas/cmd.h | |||
@@ -49,5 +49,7 @@ int lbs_resume(struct lbs_private *priv); | |||
49 | 49 | ||
50 | int lbs_cmd_802_11_inactivity_timeout(struct lbs_private *priv, | 50 | int lbs_cmd_802_11_inactivity_timeout(struct lbs_private *priv, |
51 | uint16_t cmd_action, uint16_t *timeout); | 51 | uint16_t cmd_action, uint16_t *timeout); |
52 | int lbs_cmd_802_11_sleep_params(struct lbs_private *priv, uint16_t cmd_action, | ||
53 | struct sleep_params *sp); | ||
52 | 54 | ||
53 | #endif /* _LBS_CMD_H */ | 55 | #endif /* _LBS_CMD_H */ |
diff --git a/drivers/net/wireless/libertas/cmdresp.c b/drivers/net/wireless/libertas/cmdresp.c index f7fb8c74014a..40615a88dc88 100644 --- a/drivers/net/wireless/libertas/cmdresp.c +++ b/drivers/net/wireless/libertas/cmdresp.c | |||
@@ -146,29 +146,6 @@ static int lbs_ret_reg_access(struct lbs_private *priv, | |||
146 | return ret; | 146 | return ret; |
147 | } | 147 | } |
148 | 148 | ||
149 | static int lbs_ret_802_11_sleep_params(struct lbs_private *priv, | ||
150 | struct cmd_ds_command *resp) | ||
151 | { | ||
152 | struct cmd_ds_802_11_sleep_params *sp = &resp->params.sleep_params; | ||
153 | |||
154 | lbs_deb_enter(LBS_DEB_CMD); | ||
155 | |||
156 | lbs_deb_cmd("error 0x%x, offset 0x%x, stabletime 0x%x, calcontrol 0x%x " | ||
157 | "extsleepclk 0x%x\n", le16_to_cpu(sp->error), | ||
158 | le16_to_cpu(sp->offset), le16_to_cpu(sp->stabletime), | ||
159 | sp->calcontrol, sp->externalsleepclk); | ||
160 | |||
161 | priv->sp.sp_error = le16_to_cpu(sp->error); | ||
162 | priv->sp.sp_offset = le16_to_cpu(sp->offset); | ||
163 | priv->sp.sp_stabletime = le16_to_cpu(sp->stabletime); | ||
164 | priv->sp.sp_calcontrol = sp->calcontrol; | ||
165 | priv->sp.sp_extsleepclk = sp->externalsleepclk; | ||
166 | priv->sp.sp_reserved = le16_to_cpu(sp->reserved); | ||
167 | |||
168 | lbs_deb_enter(LBS_DEB_CMD); | ||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | static int lbs_ret_802_11_stat(struct lbs_private *priv, | 149 | static int lbs_ret_802_11_stat(struct lbs_private *priv, |
173 | struct cmd_ds_command *resp) | 150 | struct cmd_ds_command *resp) |
174 | { | 151 | { |
@@ -551,9 +528,6 @@ static inline int handle_cmd_response(struct lbs_private *priv, | |||
551 | ret = lbs_ret_802_11d_domain_info(priv, resp); | 528 | ret = lbs_ret_802_11d_domain_info(priv, resp); |
552 | break; | 529 | break; |
553 | 530 | ||
554 | case CMD_RET(CMD_802_11_SLEEP_PARAMS): | ||
555 | ret = lbs_ret_802_11_sleep_params(priv, resp); | ||
556 | break; | ||
557 | case CMD_RET(CMD_802_11_TPC_CFG): | 531 | case CMD_RET(CMD_802_11_TPC_CFG): |
558 | spin_lock_irqsave(&priv->driver_lock, flags); | 532 | spin_lock_irqsave(&priv->driver_lock, flags); |
559 | memmove((void *)priv->cur_cmd->callback_arg, &resp->params.tpccfg, | 533 | memmove((void *)priv->cur_cmd->callback_arg, &resp->params.tpccfg, |
diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c index f27815967142..44be3929c027 100644 --- a/drivers/net/wireless/libertas/debugfs.c +++ b/drivers/net/wireless/libertas/debugfs.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include "decl.h" | 10 | #include "decl.h" |
11 | #include "host.h" | 11 | #include "host.h" |
12 | #include "debugfs.h" | 12 | #include "debugfs.h" |
13 | #include "cmd.h" | ||
13 | 14 | ||
14 | static struct dentry *lbs_dir; | 15 | static struct dentry *lbs_dir; |
15 | static char *szStates[] = { | 16 | static char *szStates[] = { |
@@ -103,71 +104,64 @@ static ssize_t lbs_sleepparams_write(struct file *file, | |||
103 | loff_t *ppos) | 104 | loff_t *ppos) |
104 | { | 105 | { |
105 | struct lbs_private *priv = file->private_data; | 106 | struct lbs_private *priv = file->private_data; |
106 | ssize_t buf_size, res; | 107 | ssize_t buf_size, ret; |
108 | struct sleep_params sp; | ||
107 | int p1, p2, p3, p4, p5, p6; | 109 | int p1, p2, p3, p4, p5, p6; |
108 | unsigned long addr = get_zeroed_page(GFP_KERNEL); | 110 | unsigned long addr = get_zeroed_page(GFP_KERNEL); |
109 | char *buf = (char *)addr; | 111 | char *buf = (char *)addr; |
110 | 112 | ||
111 | buf_size = min(count, len - 1); | 113 | buf_size = min(count, len - 1); |
112 | if (copy_from_user(buf, user_buf, buf_size)) { | 114 | if (copy_from_user(buf, user_buf, buf_size)) { |
113 | res = -EFAULT; | 115 | ret = -EFAULT; |
114 | goto out_unlock; | 116 | goto out_unlock; |
115 | } | 117 | } |
116 | res = sscanf(buf, "%d %d %d %d %d %d", &p1, &p2, &p3, &p4, &p5, &p6); | 118 | ret = sscanf(buf, "%d %d %d %d %d %d", &p1, &p2, &p3, &p4, &p5, &p6); |
117 | if (res != 6) { | 119 | if (ret != 6) { |
118 | res = -EFAULT; | 120 | ret = -EINVAL; |
119 | goto out_unlock; | 121 | goto out_unlock; |
120 | } | 122 | } |
121 | priv->sp.sp_error = p1; | 123 | sp.sp_error = p1; |
122 | priv->sp.sp_offset = p2; | 124 | sp.sp_offset = p2; |
123 | priv->sp.sp_stabletime = p3; | 125 | sp.sp_stabletime = p3; |
124 | priv->sp.sp_calcontrol = p4; | 126 | sp.sp_calcontrol = p4; |
125 | priv->sp.sp_extsleepclk = p5; | 127 | sp.sp_extsleepclk = p5; |
126 | priv->sp.sp_reserved = p6; | 128 | sp.sp_reserved = p6; |
127 | 129 | ||
128 | res = lbs_prepare_and_send_command(priv, | 130 | ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_SET, &sp); |
129 | CMD_802_11_SLEEP_PARAMS, | 131 | if (!ret) |
130 | CMD_ACT_SET, | 132 | ret = count; |
131 | CMD_OPTION_WAITFORRSP, 0, NULL); | 133 | else if (ret > 0) |
132 | 134 | ret = -EINVAL; | |
133 | if (!res) | ||
134 | res = count; | ||
135 | else | ||
136 | res = -EINVAL; | ||
137 | 135 | ||
138 | out_unlock: | 136 | out_unlock: |
139 | free_page(addr); | 137 | free_page(addr); |
140 | return res; | 138 | return ret; |
141 | } | 139 | } |
142 | 140 | ||
143 | static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf, | 141 | static ssize_t lbs_sleepparams_read(struct file *file, char __user *userbuf, |
144 | size_t count, loff_t *ppos) | 142 | size_t count, loff_t *ppos) |
145 | { | 143 | { |
146 | struct lbs_private *priv = file->private_data; | 144 | struct lbs_private *priv = file->private_data; |
147 | ssize_t res; | 145 | ssize_t ret; |
148 | size_t pos = 0; | 146 | size_t pos = 0; |
147 | struct sleep_params sp; | ||
149 | unsigned long addr = get_zeroed_page(GFP_KERNEL); | 148 | unsigned long addr = get_zeroed_page(GFP_KERNEL); |
150 | char *buf = (char *)addr; | 149 | char *buf = (char *)addr; |
151 | 150 | ||
152 | res = lbs_prepare_and_send_command(priv, | 151 | ret = lbs_cmd_802_11_sleep_params(priv, CMD_ACT_GET, &sp); |
153 | CMD_802_11_SLEEP_PARAMS, | 152 | if (ret) |
154 | CMD_ACT_GET, | ||
155 | CMD_OPTION_WAITFORRSP, 0, NULL); | ||
156 | if (res) { | ||
157 | res = -EFAULT; | ||
158 | goto out_unlock; | 153 | goto out_unlock; |
159 | } | ||
160 | 154 | ||
161 | pos += snprintf(buf, len, "%d %d %d %d %d %d\n", priv->sp.sp_error, | 155 | pos += snprintf(buf, len, "%d %d %d %d %d %d\n", sp.sp_error, |
162 | priv->sp.sp_offset, priv->sp.sp_stabletime, | 156 | sp.sp_offset, sp.sp_stabletime, |
163 | priv->sp.sp_calcontrol, priv->sp.sp_extsleepclk, | 157 | sp.sp_calcontrol, sp.sp_extsleepclk, |
164 | priv->sp.sp_reserved); | 158 | sp.sp_reserved); |
165 | 159 | ||
166 | res = simple_read_from_buffer(userbuf, count, ppos, buf, pos); | 160 | ret = simple_read_from_buffer(userbuf, count, ppos, buf, pos); |
167 | 161 | ||
168 | out_unlock: | 162 | out_unlock: |
169 | free_page(addr); | 163 | free_page(addr); |
170 | return res; | 164 | return ret; |
171 | } | 165 | } |
172 | 166 | ||
173 | static ssize_t lbs_extscan(struct file *file, const char __user *userbuf, | 167 | static ssize_t lbs_extscan(struct file *file, const char __user *userbuf, |
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h index 1c6ec4d61988..362975189e92 100644 --- a/drivers/net/wireless/libertas/dev.h +++ b/drivers/net/wireless/libertas/dev.h | |||
@@ -77,12 +77,12 @@ struct current_bss_params { | |||
77 | 77 | ||
78 | /** sleep_params */ | 78 | /** sleep_params */ |
79 | struct sleep_params { | 79 | struct sleep_params { |
80 | u16 sp_error; | 80 | uint16_t sp_error; |
81 | u16 sp_offset; | 81 | uint16_t sp_offset; |
82 | u16 sp_stabletime; | 82 | uint16_t sp_stabletime; |
83 | u8 sp_calcontrol; | 83 | uint8_t sp_calcontrol; |
84 | u8 sp_extsleepclk; | 84 | uint8_t sp_extsleepclk; |
85 | u16 sp_reserved; | 85 | uint16_t sp_reserved; |
86 | }; | 86 | }; |
87 | 87 | ||
88 | /* Mesh statistics */ | 88 | /* Mesh statistics */ |
@@ -300,9 +300,6 @@ struct lbs_private { | |||
300 | u8 cur_rate; | 300 | u8 cur_rate; |
301 | u8 auto_rate; | 301 | u8 auto_rate; |
302 | 302 | ||
303 | /** sleep_params */ | ||
304 | struct sleep_params sp; | ||
305 | |||
306 | /** RF calibration data */ | 303 | /** RF calibration data */ |
307 | 304 | ||
308 | #define MAX_REGION_CHANNEL_NUM 2 | 305 | #define MAX_REGION_CHANNEL_NUM 2 |
diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h index 2ad32bc2cf24..855c2d0df863 100644 --- a/drivers/net/wireless/libertas/hostcmd.h +++ b/drivers/net/wireless/libertas/hostcmd.h | |||
@@ -355,6 +355,8 @@ struct cmd_ds_802_11_beacon_control { | |||
355 | }; | 355 | }; |
356 | 356 | ||
357 | struct cmd_ds_802_11_sleep_params { | 357 | struct cmd_ds_802_11_sleep_params { |
358 | struct cmd_header hdr; | ||
359 | |||
358 | /* ACT_GET/ACT_SET */ | 360 | /* ACT_GET/ACT_SET */ |
359 | __le16 action; | 361 | __le16 action; |
360 | 362 | ||
@@ -368,10 +370,10 @@ struct cmd_ds_802_11_sleep_params { | |||
368 | __le16 stabletime; | 370 | __le16 stabletime; |
369 | 371 | ||
370 | /* control periodic calibration */ | 372 | /* control periodic calibration */ |
371 | u8 calcontrol; | 373 | uint8_t calcontrol; |
372 | 374 | ||
373 | /* control the use of external sleep clock */ | 375 | /* control the use of external sleep clock */ |
374 | u8 externalsleepclk; | 376 | uint8_t externalsleepclk; |
375 | 377 | ||
376 | /* reserved field, should be set to zero */ | 378 | /* reserved field, should be set to zero */ |
377 | __le16 reserved; | 379 | __le16 reserved; |
@@ -715,7 +717,6 @@ struct cmd_ds_command { | |||
715 | struct cmd_ds_802_11d_domain_info domaininfo; | 717 | struct cmd_ds_802_11d_domain_info domaininfo; |
716 | struct cmd_ds_802_11d_domain_info domaininforesp; | 718 | struct cmd_ds_802_11d_domain_info domaininforesp; |
717 | 719 | ||
718 | struct cmd_ds_802_11_sleep_params sleep_params; | ||
719 | struct cmd_ds_802_11_tpc_cfg tpccfg; | 720 | struct cmd_ds_802_11_tpc_cfg tpccfg; |
720 | struct cmd_ds_802_11_pwr_cfg pwrcfg; | 721 | struct cmd_ds_802_11_pwr_cfg pwrcfg; |
721 | struct cmd_ds_802_11_afc afc; | 722 | struct cmd_ds_802_11_afc afc; |