From 0d7aa128d0bbf290b958f50851085a1586d63efa Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 20 Feb 2013 02:09:03 +0100 Subject: [PATCH] add an option for releasing client ids --- dev.c | 7 +++++++ main.c | 17 ++++++++++++++++- uqmi.h | 1 + 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/dev.c b/dev.c index 2e20274..76a8f30 100644 --- a/dev.c +++ b/dev.c @@ -261,6 +261,13 @@ static void __qmi_service_disconnect(struct qmi_dev *qmi, int idx) qmi_request_wait(qmi, &req); } +int qmi_service_release_client_id(struct qmi_dev *qmi, QmiService svc) +{ + int idx = qmi_get_service_idx(svc); + qmi->service_keep_cid &= ~(1 << idx); + return 0; +} + static void qmi_close_all_services(struct qmi_dev *qmi) { uint32_t connected = qmi->service_connected; diff --git a/main.c b/main.c index 5a4a8e8..3a86c84 100644 --- a/main.c +++ b/main.c @@ -19,7 +19,8 @@ static const char *device; static const struct option uqmi_getopt[] = { __uqmi_commands, { "device", required_argument, NULL, 'd' }, - { "keep-client-id", required_argument, NULL, 'K' }, + { "keep-client-id", required_argument, NULL, 'k' }, + { "release-client-id", required_argument, NULL, 'r' }, { NULL, 0, NULL, 0 } }; #undef __uqmi_command @@ -31,6 +32,7 @@ static int usage(const char *progname) " --device=NAME, -d NAME: Set device name to NAME (required)\n" " --keep-client-id : Keep Client ID for service \n" " (implies --keep-client-id)\n" + " --release-client-id : Release Client ID after exiting\n" "\n" "Services: dms, nas, pds, wds, wms\n" "\n" @@ -57,6 +59,16 @@ static void keep_client_id(struct qmi_dev *qmi, const char *optarg) qmi_service_get_client_id(qmi, svc); } +static void release_client_id(struct qmi_dev *qmi, const char *optarg) +{ + QmiService svc = qmi_service_get_by_name(optarg); + if (svc < 0) { + fprintf(stderr, "Invalid service %s\n", optarg); + exit(1); + } + qmi_service_release_client_id(qmi, svc); +} + static void handle_exit_signal(int signal) { cancel_all_requests = true; @@ -81,6 +93,9 @@ int main(int argc, char **argv) } switch(ch) { + case 'r': + release_client_id(&dev, optarg); + break; case 'k': keep_client_id(&dev, optarg); break; diff --git a/uqmi.h b/uqmi.h index 842fb9b..4c899b6 100644 --- a/uqmi.h +++ b/uqmi.h @@ -94,6 +94,7 @@ static inline bool qmi_request_pending(struct qmi_request *req) int qmi_service_connect(struct qmi_dev *qmi, QmiService svc, int client_id); int qmi_service_get_client_id(struct qmi_dev *qmi, QmiService svc); +int qmi_service_release_client_id(struct qmi_dev *qmi, QmiService svc); QmiService qmi_service_get_by_name(const char *str); const char *qmi_get_error_str(int code); -- 2.25.1