summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorInaky Perez-Gonzalez <inaky@linux.intel.com>2009-02-12 00:50:52 -0800
committerInaky Perez-Gonzalez <inaky@linux.intel.com>2009-02-12 00:50:52 -0800
commitd56d0a89b99adeee273e63a6cfc9e35111c89889 (patch)
tree8d35851b28e11c1e55d37a72bb1b2f38be38d11b /lib
parent66978103a6a0f7a8ca48fd4b31eeb25bc6b985d4 (diff)
wimaxll_open: if the interface requested is not WiMAX, fail
Due to the changes done during the mainline merge, wimaxll_open() wasn't really verifying that the interface being requested was a WiMAX interface. As such, the user would only find out when trying to execute any function, as it would fail with -ENODEV. So now, before returning in wimaxll_open(), call rfkill query. If it fails with -ENODEV, we know the device is not WiMAX. Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/op-open.c11
-rw-r--r--lib/op-rfkill.c2
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/op-open.c b/lib/op-open.c
index 2d5b480..a222c5c 100644
--- a/lib/op-open.c
+++ b/lib/op-open.c
@@ -421,9 +421,20 @@ struct wimaxll_handle *wimaxll_open(const char *device)
wmx->mcg_id, result);
goto error_nl_add_membership;
}
+ /* Now we check if the device is a WiMAX supported device, by
+ * just querying for the RFKILL status. If this is not a WiMAX
+ * device, it will fail with -ENODEV. */
+ result = wimaxll_rfkill(wmx, WIMAX_RF_QUERY);
+ if (result == -ENODEV) {
+ wimaxll_msg(wmx, "E: device %s is not a WiMAX device; or "
+ "supports an interface unknown to libwimaxll: %d\n",
+ wmx->name, result);
+ goto error_rfkill;
+ }
d_fnend(3, wmx, "(device %s) = %p\n", device, wmx);
return wmx;
+error_rfkill:
error_nl_add_membership:
error_gnl_resolve:
nl_close(wmx->nlh_rx);
diff --git a/lib/op-rfkill.c b/lib/op-rfkill.c
index 3e9e793..5cdf738 100644
--- a/lib/op-rfkill.c
+++ b/lib/op-rfkill.c
@@ -120,7 +120,7 @@ int wimaxll_rfkill(struct wimaxll_handle *wmx, enum wimax_rf_state state)
}
/* Read the message ACK from netlink */
result = wimaxll_wait_for_ack(wmx);
- if (result < 0)
+ if (result < 0 && result != -ENODEV)
wimaxll_msg(wmx, "E: RFKILL: operation failed: %zd\n", result);
error_msg_prep:
error_msg_send: