summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInaky Perez-Gonzalez <inaky.perez-gonzalez>2008-12-05 10:36:28 -0800
committerInaky Perez-Gonzalez <inaky@linux.intel.com>2008-12-05 10:36:28 -0800
commit4552dbe5c165c73b8831ac4bd5bbbf387b6bb567 (patch)
treefdd5886a5b629d11dec62b544941b62e8ce0416c
parenteb04a8250528e2c903ca22706bccd250d3923d6b (diff)
wimax: (fb Johannes Berg) remove RP_RESULT and associated code
Johannes mentioned we should be able to use the normal generic netlink mechanisms to return error codes. We were not using (in user space) libnl correctly, so we weren't seeing the codes ok. Now we are and thus this code becomes obsolete. Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
-rw-r--r--lib/internal.h1
-rw-r--r--lib/op-reset.c2
-rw-r--r--lib/op-rfkill.c2
-rw-r--r--lib/wimax.c135
4 files changed, 2 insertions, 138 deletions
diff --git a/lib/internal.h b/lib/internal.h
index 9fda2ba..1f40508 100644
--- a/lib/internal.h
+++ b/lib/internal.h
@@ -155,7 +155,6 @@ void wimaxll_mch_maybe_set_result(struct wimaxll_mc_handle *mch, int val)
/* Utilities */
-ssize_t wimaxll_wait_for_rp_result(struct wimaxll_handle *);
int wimaxll_wait_for_ack(struct wimaxll_handle *);
int wimaxll_gnl_handle_msg_to_user(struct wimaxll_handle *,
struct wimaxll_mc_handle *,
diff --git a/lib/op-reset.c b/lib/op-reset.c
index c81a033..df94186 100644
--- a/lib/op-reset.c
+++ b/lib/op-reset.c
@@ -111,7 +111,7 @@ int wimaxll_reset(struct wimaxll_handle *wmx)
goto error_msg_send;
}
/* Read the message ACK from netlink */
- result = wimaxll_wait_for_rp_result(wmx);
+ result = wimaxll_wait_for_ack(wmx);
if (result < 0)
wimaxll_msg(wmx, "E: RESET: operation failed: %zd\n", result);
error_msg_prep:
diff --git a/lib/op-rfkill.c b/lib/op-rfkill.c
index 90be4b6..48d1110 100644
--- a/lib/op-rfkill.c
+++ b/lib/op-rfkill.c
@@ -118,7 +118,7 @@ int wimaxll_rfkill(struct wimaxll_handle *wmx, enum wimax_rf_state state)
goto error_msg_send;
}
/* Read the message ACK from netlink */
- result = wimaxll_wait_for_rp_result(wmx);
+ result = wimaxll_wait_for_ack(wmx);
if (result < 0)
wimaxll_msg(wmx, "E: RFKILL: operation failed: %zd\n", result);
error_msg_prep:
diff --git a/lib/wimax.c b/lib/wimax.c
index 650570b..813e0c8 100644
--- a/lib/wimax.c
+++ b/lib/wimax.c
@@ -192,141 +192,6 @@ int wimaxll_wait_for_ack(struct wimaxll_handle *wmx)
/**
- * WIMAX_GNL_RP_RESULT: policy specification
- *
- * \internal
- *
- * Authoritative reference for this is at the kernel code,
- * drivers/net/wimax/stack.c.
- */
-static
-struct nla_policy wimaxll_gnl_result_policy[WIMAX_GNL_ATTR_MAX + 1] = {
- /* This is really a signed-64 bit number that has to be
- * casted from a u64 */
- [WIMAX_GNL_RESULT_CODE] = { .type = NLA_U64 },
-};
-
-
-/**
- * Netlink callback to process a WIMAX_GNL_RP_RESULT message
- *
- * \internal
- *
- * \param msg Netlink message containing the reply
- * \param _mch Pointer to a \a struct wimaxll_mc_handle where the
- * result of the operation will be returned.
- *
- * \return 'enum nl_cb_action', NL_OK if there is no error, NL_STOP on
- * error and _mch->result updated.
- *
- * This will take a received netlink message, check it is a \a
- * WIMAX_GNL_RP_RESULT, parse the status code in it and store it the
- * \m _mch's result data member for the caller to use later on.
- */
-static
-int wimaxll_gnl_rp_result_cb(struct nl_msg *msg, void *_mch)
-{
- int result;
- struct wimaxll_mc_handle *mch = _mch;
- struct wimaxll_handle *wmx = mch->wmx;
- struct nlmsghdr *nl_hdr;
- struct genlmsghdr *genl_hdr;
- struct nlattr *tb[WIMAX_GNL_ATTR_MAX + 1];
-
- d_fnstart(7, wmx, "(msg %p mch %p)\n", msg, _mch);
- nl_hdr = nlmsg_hdr(msg);
- genl_hdr = nlmsg_data(nl_hdr);
-
- if (genl_hdr->cmd != WIMAX_GNL_RP_RESULT) {
- result = NL_SKIP;
- d_printf(1, wmx, "D: ignoring unknown command %d\n",
- genl_hdr->cmd);
- goto error_parse;
- }
-
- /* Parse the attributes */
- result = genlmsg_parse(nl_hdr, 0, tb, WIMAX_GNL_ATTR_MAX,
- wimaxll_gnl_result_policy);
- if (result < 0) {
- wimaxll_msg(wmx, "E: %s: genlmsg_parse() failed: %d\n",
- __func__, result);
- wimaxll_mch_maybe_set_result(mch, -ENXIO);
- result = NL_SKIP;
- goto error_parse;
- }
- if (tb[WIMAX_GNL_RESULT_CODE] == NULL) {
- wimaxll_msg(wmx, "E: %s: No result code argument passed\n",
- __func__);
- wimaxll_mch_maybe_set_result(mch, -ENXIO);
- result = NL_SKIP;
- goto error_no_result_code;
-
- }
- result = (ssize_t) nla_get_u64(tb[WIMAX_GNL_RESULT_CODE]);
- wimaxll_mch_maybe_set_result(mch, result);
- result = NL_OK;
-error_no_result_code:
-error_parse:
- d_fnend(7, wmx, "(msg %p mch %p) = %d\n", msg, _mch, result);
- return result;
-}
-
-
-/**
- * Wait for a WIMAX_GNL_RP_RESULT reply (and an ack) and report its code
- *
- * \internal
- *
- * Many ops we execute in the kernel return just a signed integer for
- * status using a WIMAX_GNL_RP_RESULT command for reply before sending
- * the ACK.
- *
- * This function simplifies waiting for that and getting the reply.
- *
- * \note We use the same handler used for transmission in the TX side
- * and it's callback set, that we modifiy. As noted in the doc for
- * \a struct wimaxll_handle, each call site to nl_recvmsgs_default()
- * on \a wmx->nlh_tx must make sure the NL_CB_VALID and
- * nl_cb_err() callbacks are properly set.
- */
-ssize_t wimaxll_wait_for_rp_result(struct wimaxll_handle *wmx)
-{
- ssize_t result;
- struct nl_cb *cb;
- struct wimaxll_mc_handle fake_mch;
-
- d_fnstart(5, wmx, "(wmx %p)\n", wmx);
- fake_mch.wmx = wmx;
- fake_mch.result = -EINPROGRESS;
- fake_mch.msg_done = 0;
- cb = nl_socket_get_cb(wmx->nlh_tx);
- nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM,
- wimaxll_gnl_ack_cb, &fake_mch);
- nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM,
- wimaxll_gnl_rp_result_cb, &fake_mch);
- nl_cb_err(cb, NL_CB_CUSTOM, wimaxll_gnl_error_cb, &fake_mch);
-
- do
- result = nl_recvmsgs(wmx->nlh_tx, cb);
- while (fake_mch.msg_done == 0 && result >= 0);
- result = fake_mch.result;
- nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, NL_CB_DEFAULT, NULL);
- nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, NL_CB_DEFAULT, NULL);
- nl_cb_err(cb, NL_CB_CUSTOM, NL_CB_DEFAULT, NULL);
- nl_cb_put(cb);
-
- result = fake_mch.result;
- if (result == -EINPROGRESS)
- wimaxll_msg(wmx, "E: %s: the kernel didn't reply with a "
- "WIMAX_GNL_RP_RESULT message\n", __func__);
- else
- d_printf(1, wmx, "D: WIMAX_GNL_RP_RESULT code is %d\n", result);
- d_fnend(5, wmx, "(wmx %p) = %zd\n", wmx, result);
- return result;
-}
-
-
-/**
* \defgroup diagnostics_group Output of diagnostics messages
*
* The \e libwimaxll library prints diagnostics by default to \a