diff options
author | Dan Williams <dcbw@redhat.com> | 2007-12-11 12:40:35 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:06:41 -0500 |
commit | a8bdcd71fd33e4a919f9f0cb32207c644b70853f (patch) | |
tree | f1c3d008e5d830800302fcb0b5ef189980e1eee2 /drivers/net | |
parent | 7ad994dec7d36c319cb35cbf3a920d3bda96e6b0 (diff) |
libertas: add simple copyback command callback
A simple callback which copies the response back into the
command buffer that was used to send the command to the
card. Will allow for direct command processing outside
the mega-switches in cmd.c and cmdresp.c.
Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/libertas/cmd.c | 29 | ||||
-rw-r--r-- | drivers/net/wireless/libertas/cmd.h | 7 |
2 files changed, 35 insertions, 1 deletions
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index 78870c770428..c4b32a05de10 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -1972,6 +1972,34 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode) | |||
1972 | 1972 | ||
1973 | 1973 | ||
1974 | /** | 1974 | /** |
1975 | * @brief Simple callback that copies response back into command | ||
1976 | * | ||
1977 | * @param priv A pointer to struct lbs_private structure | ||
1978 | * @param extra A pointer to the original command structure for which | ||
1979 | * 'resp' is a response | ||
1980 | * @param resp A pointer to the command response | ||
1981 | * | ||
1982 | * @return 0 on success, error on failure | ||
1983 | */ | ||
1984 | int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra, | ||
1985 | struct cmd_header *resp) | ||
1986 | { | ||
1987 | struct cmd_header *buf = (void *)extra; | ||
1988 | uint16_t copy_len; | ||
1989 | |||
1990 | lbs_deb_enter(LBS_DEB_CMD); | ||
1991 | |||
1992 | copy_len = min(le16_to_cpu(buf->size), le16_to_cpu(resp->size)); | ||
1993 | lbs_deb_cmd("Copying back %u bytes; command response was %u bytes, " | ||
1994 | "copy back buffer was %u bytes", copy_len, resp->size, | ||
1995 | buf->size); | ||
1996 | memcpy(buf, resp, copy_len); | ||
1997 | |||
1998 | lbs_deb_leave(LBS_DEB_CMD); | ||
1999 | return 0; | ||
2000 | } | ||
2001 | |||
2002 | /** | ||
1975 | * @brief Simple way to call firmware functions | 2003 | * @brief Simple way to call firmware functions |
1976 | * | 2004 | * |
1977 | * @param priv A pointer to struct lbs_private structure | 2005 | * @param priv A pointer to struct lbs_private structure |
@@ -1987,7 +2015,6 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv, u16 psmode) | |||
1987 | * @return -1 in case of a higher level error, otherwise | 2015 | * @return -1 in case of a higher level error, otherwise |
1988 | * the result code from the firmware | 2016 | * the result code from the firmware |
1989 | */ | 2017 | */ |
1990 | |||
1991 | int __lbs_cmd(struct lbs_private *priv, uint16_t command, | 2018 | int __lbs_cmd(struct lbs_private *priv, uint16_t command, |
1992 | struct cmd_header *in_cmd, int in_cmd_size, | 2019 | struct cmd_header *in_cmd, int in_cmd_size, |
1993 | int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *), | 2020 | 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 259d3e87193f..72857a1a2482 100644 --- a/drivers/net/wireless/libertas/cmd.h +++ b/drivers/net/wireless/libertas/cmd.h | |||
@@ -10,9 +10,16 @@ | |||
10 | __lbs_cmd(priv, cmdnr, (struct cmd_header *) &cmd, sizeof(cmd), \ | 10 | __lbs_cmd(priv, cmdnr, (struct cmd_header *) &cmd, sizeof(cmd), \ |
11 | callback, callback_arg) | 11 | callback, callback_arg) |
12 | 12 | ||
13 | #define lbs_cmd_with_response(priv, cmdnr, cmd) \ | ||
14 | __lbs_cmd(priv, cmdnr, (struct cmd_header *) &cmd, sizeof(cmd), \ | ||
15 | lbs_cmd_copyback, (unsigned long) &cmd) | ||
16 | |||
13 | int __lbs_cmd(struct lbs_private *priv, uint16_t command, | 17 | int __lbs_cmd(struct lbs_private *priv, uint16_t command, |
14 | struct cmd_header *in_cmd, int in_cmd_size, | 18 | struct cmd_header *in_cmd, int in_cmd_size, |
15 | int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *), | 19 | int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *), |
16 | unsigned long callback_arg); | 20 | unsigned long callback_arg); |
17 | 21 | ||
22 | int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra, | ||
23 | struct cmd_header *resp); | ||
24 | |||
18 | #endif /* _LBS_CMD_H */ | 25 | #endif /* _LBS_CMD_H */ |