aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorHolger Schurig <hs4233@mail.mn-solutions.de>2008-03-19 05:11:00 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-03-25 16:41:48 -0400
commit8db4a2b986befabd2ad25c269e40444f06a6bda3 (patch)
tree9b4d4edd92ba25dd739e12ae6a188b5c53ae75e9 /drivers/net
parent712b6cf57a53da608a682b5f782c5785bda76001 (diff)
libertas: make a handy lbs_cmd_async() command
This uses a static lbs_cmd_async_callback function, which is a noop. Just setting the callback argument to __lbs_cmd_async() to NULL won't work, because then the cmdnode wouldn't be released. This also makes __lbs_cmd_async() a static method, which is now only used by lbs_cmd() and lbs_cmd_async(). Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de> Acked-by: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/libertas/cmd.c84
-rw-r--r--drivers/net/wireless/libertas/cmd.h9
2 files changed, 57 insertions, 36 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 62f9f3bdfdfb..be461c5c42ae 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -20,6 +20,46 @@ static void lbs_set_cmd_ctrl_node(struct lbs_private *priv,
20 20
21 21
22/** 22/**
23 * @brief Simple callback that copies response back into command
24 *
25 * @param priv A pointer to struct lbs_private structure
26 * @param extra A pointer to the original command structure for which
27 * 'resp' is a response
28 * @param resp A pointer to the command response
29 *
30 * @return 0 on success, error on failure
31 */
32int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra,
33 struct cmd_header *resp)
34{
35 struct cmd_header *buf = (void *)extra;
36 uint16_t copy_len;
37
38 copy_len = min(le16_to_cpu(buf->size), le16_to_cpu(resp->size));
39 memcpy(buf, resp, copy_len);
40 return 0;
41}
42EXPORT_SYMBOL_GPL(lbs_cmd_copyback);
43
44/**
45 * @brief Simple callback that ignores the result. Use this if
46 * you just want to send a command to the hardware, but don't
47 * care for the result.
48 *
49 * @param priv ignored
50 * @param extra ignored
51 * @param resp ignored
52 *
53 * @return 0 for success
54 */
55static int lbs_cmd_async_callback(struct lbs_private *priv, unsigned long extra,
56 struct cmd_header *resp)
57{
58 return 0;
59}
60
61
62/**
23 * @brief Checks whether a command is allowed in Power Save mode 63 * @brief Checks whether a command is allowed in Power Save mode
24 * 64 *
25 * @param command the command ID 65 * @param command the command ID
@@ -1242,7 +1282,7 @@ void lbs_complete_command(struct lbs_private *priv, struct cmd_ctrl_node *cmd,
1242 cmd->cmdwaitqwoken = 1; 1282 cmd->cmdwaitqwoken = 1;
1243 wake_up_interruptible(&cmd->cmdwait_q); 1283 wake_up_interruptible(&cmd->cmdwait_q);
1244 1284
1245 if (!cmd->callback) 1285 if (!cmd->callback || cmd->callback == lbs_cmd_async_callback)
1246 __lbs_cleanup_and_insert_cmd(priv, cmd); 1286 __lbs_cleanup_and_insert_cmd(priv, cmd);
1247 priv->cur_cmd = NULL; 1287 priv->cur_cmd = NULL;
1248} 1288}
@@ -2018,32 +2058,10 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode)
2018} 2058}
2019 2059
2020 2060
2021/** 2061static struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv,
2022 * @brief Simple callback that copies response back into command 2062 uint16_t command, struct cmd_header *in_cmd, int in_cmd_size,
2023 * 2063 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
2024 * @param priv A pointer to struct lbs_private structure 2064 unsigned long callback_arg)
2025 * @param extra A pointer to the original command structure for which
2026 * 'resp' is a response
2027 * @param resp A pointer to the command response
2028 *
2029 * @return 0 on success, error on failure
2030 */
2031int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra,
2032 struct cmd_header *resp)
2033{
2034 struct cmd_header *buf = (void *)extra;
2035 uint16_t copy_len;
2036
2037 copy_len = min(le16_to_cpu(buf->size), le16_to_cpu(resp->size));
2038 memcpy(buf, resp, copy_len);
2039 return 0;
2040}
2041EXPORT_SYMBOL_GPL(lbs_cmd_copyback);
2042
2043struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv, uint16_t command,
2044 struct cmd_header *in_cmd, int in_cmd_size,
2045 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
2046 unsigned long callback_arg)
2047{ 2065{
2048 struct cmd_ctrl_node *cmdnode; 2066 struct cmd_ctrl_node *cmdnode;
2049 2067
@@ -2080,9 +2098,6 @@ struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv, uint16_t command
2080 2098
2081 lbs_deb_host("PREP_CMD: command 0x%04x\n", command); 2099 lbs_deb_host("PREP_CMD: command 0x%04x\n", command);
2082 2100
2083 /* here was the big old switch() statement, which is now obsolete,
2084 * because the caller of lbs_cmd() sets up all of *cmd for us. */
2085
2086 cmdnode->cmdwaitqwoken = 0; 2101 cmdnode->cmdwaitqwoken = 0;
2087 lbs_queue_cmd(priv, cmdnode); 2102 lbs_queue_cmd(priv, cmdnode);
2088 wake_up_interruptible(&priv->waitq); 2103 wake_up_interruptible(&priv->waitq);
@@ -2092,6 +2107,15 @@ struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv, uint16_t command
2092 return cmdnode; 2107 return cmdnode;
2093} 2108}
2094 2109
2110void lbs_cmd_async(struct lbs_private *priv, uint16_t command,
2111 struct cmd_header *in_cmd, int in_cmd_size)
2112{
2113 lbs_deb_enter(LBS_DEB_CMD);
2114 __lbs_cmd_async(priv, command, in_cmd, in_cmd_size,
2115 lbs_cmd_async_callback, 0);
2116 lbs_deb_leave(LBS_DEB_CMD);
2117}
2118
2095int __lbs_cmd(struct lbs_private *priv, uint16_t command, 2119int __lbs_cmd(struct lbs_private *priv, uint16_t command,
2096 struct cmd_header *in_cmd, int in_cmd_size, 2120 struct cmd_header *in_cmd, int in_cmd_size,
2097 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *), 2121 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h
index d250e6bc0609..3dfc2d43c224 100644
--- a/drivers/net/wireless/libertas/cmd.h
+++ b/drivers/net/wireless/libertas/cmd.h
@@ -18,12 +18,9 @@
18#define lbs_cmd_with_response(priv, cmdnr, cmd) \ 18#define lbs_cmd_with_response(priv, cmdnr, cmd) \
19 lbs_cmd(priv, cmdnr, cmd, lbs_cmd_copyback, (unsigned long) (cmd)) 19 lbs_cmd(priv, cmdnr, cmd, lbs_cmd_copyback, (unsigned long) (cmd))
20 20
21/* __lbs_cmd() will free the cmdnode and return success/failure. 21void lbs_cmd_async(struct lbs_private *priv, uint16_t command,
22 __lbs_cmd_async() requires that the callback free the cmdnode */ 22 struct cmd_header *in_cmd, int in_cmd_size);
23struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv, uint16_t command, 23
24 struct cmd_header *in_cmd, int in_cmd_size,
25 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
26 unsigned long callback_arg);
27int __lbs_cmd(struct lbs_private *priv, uint16_t command, 24int __lbs_cmd(struct lbs_private *priv, uint16_t command,
28 struct cmd_header *in_cmd, int in_cmd_size, 25 struct cmd_header *in_cmd, int in_cmd_size,
29 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *), 26 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),