Commit:     f15ebb63b36eca5fa68fabd04ab2f7840bc67205
Parent:     4f59abf190b15350167bec5382dda205030ac9d0
Author:     David Woodhouse <[EMAIL PROTECTED]>
AuthorDate: Wed Dec 19 13:03:19 2007 +0000
Committer:  David S. Miller <[EMAIL PROTECTED]>
CommitDate: Mon Jan 28 15:07:51 2008 -0800

    libertas: change inference about buffer size in lbs_cmd()
    sizeof(*cmd) is going to give the total size of the data structure that
    we allocated, more often than not. But the size of the command to be
    _sent_ could be a lot smaller, as it is in the KEY_MATERIAL and
    SUBSCRIBE_EVENT commands for example. So swap them round; let the caller
    set the _command_ size explicitly in the header, and infer the
    maximum response size from the data structure.
    Signed-off-by: David Woodhouse <[EMAIL PROTECTED]>
    Signed-off-by: John W. Linville <[EMAIL PROTECTED]>
 drivers/net/wireless/libertas/cmd.h |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/wireless/libertas/cmd.h 
index 6efb81e..b9ab85c 100644
--- a/drivers/net/wireless/libertas/cmd.h
+++ b/drivers/net/wireless/libertas/cmd.h
@@ -6,13 +6,15 @@
 #include "hostcmd.h"
 #include "dev.h"
-#define lbs_cmd(priv, cmdnr, cmd, cb, cb_arg)  \
-       __lbs_cmd(priv, cmdnr, &(cmd)->hdr, sizeof(*(cmd)), cb, cb_arg)
+/* lbs_cmd() infers the size of the buffer to copy data back into, from
+   the size of the target of the pointer. Since the command to be sent 
+   may often be smaller, that size is set in cmd->size by the caller.*/
+#define lbs_cmd(priv, cmdnr, cmd, cb, cb_arg)  ({              \
+       uint16_t __sz = le16_to_cpu((cmd)->hdr.size);           \
+       (cmd)->hdr.size = cpu_to_le16(sizeof(*(cmd)));          \
+       __lbs_cmd(priv, cmdnr, &(cmd)->hdr, __sz, cb, cb_arg);  \
-/* lbs_cmd_with_response() infers the size of the command to be _sent_
-   and requires that the caller sets cmd->size to the (LE) size of
-   the _response_ buffer. */
 #define lbs_cmd_with_response(priv, cmdnr, cmd)        \
        lbs_cmd(priv, cmdnr, cmd, lbs_cmd_copyback, (unsigned long) (cmd))
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at

Reply via email to