From patchwork Thu Feb 22 17:14:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13567624 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B05E315530C for ; Thu, 22 Feb 2024 17:15:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708622128; cv=none; b=T4zJhRHTBCqxbEFnGPXFNmXd9BtYorDY5pV+ZhM4MpB42dj3283S/qzw1/aRvjia4fz9PAwESkTAKFj9rK6pHiAQllloeS6V/QefPqi9UMgW3+LR200FyFpQPXoweqvRdNFsb9exVA+ISe8fuwBDdg4/OY579+/IcYAa9Ivtrik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708622128; c=relaxed/simple; bh=W9EuWcdUSjtp/rcKtFlAEIt5sO0szj0lmOEQwb1jIKc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=b4LIlpufN7Ssmx+l65e4HU3Th72qL0GOsb28SXwxgXp01N/4ZsgZXBIpU9xJ21kRR8n72ITTWxZWPnidXM80GpqdOZcACeiPlAVknuIW5B1v065Lf67R8K7MolwuGTiiGN2W81Tx2ZHywuxdLMakWOyWeNKMpa2xpceE5XQtsqY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ch28tr0A; arc=none smtp.client-ip=209.85.167.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ch28tr0A" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3c1652613d3so2322858b6e.1 for ; Thu, 22 Feb 2024 09:15:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708622125; x=1709226925; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vmY0JKrnOFM1cDu9hlc3dINxP9KgHlvo9DYGsAOhKQ0=; b=Ch28tr0ATlfOXbbykiW6xnRyPdq39vZ7RYn7qM0MzFpar+rpQMUwm1A5QN7DySZ/2V pUPheUhjhUxQ4+lwqHSYvPwJbVC9rT/PEptDSWBpKm9zQn9iuncjoo3MrrKgwRSj+Lxr LbAJ2l8gdnmigFFRtkdtrYMJzg5jJML8IF8CgYuJjovZFS8iXIWX4xDGiaulWGEqEtvn Aq+6ki6UjBw06DFgEr80egTOwPfT/5XyZnncMQn6Uc/rSS5BjEhjsAxc5eVZIcmv8hVa BWLgEAOmw8mhfZ876XFym+NRscu//IUZ4qJ1vs8SfvAwdOQhI7bt7EKDPdNiDfM628eh uQcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708622125; x=1709226925; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vmY0JKrnOFM1cDu9hlc3dINxP9KgHlvo9DYGsAOhKQ0=; b=K8wjqzQXrjYi3X7w6lvpFiucewHYE3WwN7Qio9c29kPomSnS1KNkRSVLzbDL4kh4ND u9h4ABO0UUGDflb99ee60+2kDcutRHHYE+euv93VoBGxRqfbE7MzHrpCWyYbykEU4xaQ +Che02TnxHWNX6/NdDVVXrKa1ZbTNTvpIDJxvY1MYlRHN0Xv7Ouk6VQgqjEY9A3e16kG P/2Z2z3AHLOVNjLxa8KaOOM81O2VYxOpRXgzQhv49hM6PiI6ueGZ0LiMvFBR9ZA6BGLm yciYcDSHAVS4FPptbnLCA/xN+IdGKVOGYxaGRsUPb8V5UaBtgWuAuofPFccYs1AulTPw NP7A== X-Gm-Message-State: AOJu0YzB7Qi2a/So2m21pzsWjPosk+Y9rrzVxdLdDhmn3gErVApILr+W 5hTNQSVAb12FuvbEwFyxfLhmNGcUu+kp0F6Qhi6rWnBq06lQ+Zd1zH/tkQwL X-Google-Smtp-Source: AGHT+IEyL8gtI54+tES1AFb4NczU2BHUel4gsja36N7pLNES3FTuwDOZS619OLQbsM1VWEG8BCuMng== X-Received: by 2002:a05:6808:22a4:b0:3c1:8507:9fcc with SMTP id bo36-20020a05680822a400b003c185079fccmr343076oib.53.1708622125641; Thu, 22 Feb 2024 09:15:25 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id cc7-20020a056808324700b003c178f6a504sm355898oib.14.2024.02.22.09.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:15:25 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 1/4] qmi: Drop qmi_device_ref Date: Thu, 22 Feb 2024 11:14:17 -0600 Message-ID: <20240222171438.1291553-1-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This API isn't being used, drop it. --- drivers/qmimodem/qmi.c | 10 ---------- drivers/qmimodem/qmi.h | 1 - 2 files changed, 11 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 52a8e57c23d9..2dde31b11c7c 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -961,16 +961,6 @@ static int qmi_device_init(struct qmi_device *device, int fd, return 0; } -struct qmi_device *qmi_device_ref(struct qmi_device *device) -{ - if (!device) - return NULL; - - __sync_fetch_and_add(&device->ref_count, 1); - - return device; -} - static void __qmi_device_shutdown_finished(struct qmi_device *device) { if (device->destroyed) diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index df4bc39644a2..14ad84e5006a 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -81,7 +81,6 @@ typedef void (*qmi_debug_func_t)(const char *str, void *user_data); typedef void (*qmi_shutdown_func_t)(void *user_data); typedef void (*qmi_discover_func_t)(void *user_data); -struct qmi_device *qmi_device_ref(struct qmi_device *device); void qmi_device_unref(struct qmi_device *device); void qmi_device_set_debug(struct qmi_device *device, From patchwork Thu Feb 22 17:14:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13567625 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6137815530F for ; Thu, 22 Feb 2024 17:15:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708622128; cv=none; b=VOfsVjMoFmZ7spf8TVRk20O4NMW+yl/8nlJFO9qJIQ2evWJnhHS1C0f28Fqpr4sBtuslHwc+gNi7WR+rjuiIHwnMLvT8edOp8o71hLDf1YP5ljXpfklP8LjgNgaLyctL/y0BdhvqNGCmyjOTWvNLg1mfYqTli95OppBiFCzyB4o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708622128; c=relaxed/simple; bh=229YxpFa+dzGCJCVcgZvN0sJCAsvMauC1K8EO6Ioxbs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EGWGWCUa8R8RgPBPTZd4kdTBneLL0GLXu+k43Ne705DmZazWCYsKVm22tGRQGOr2TL1I33wvvawrcFIPL7nNKkrXo6frr5uqgJmXue1cov7YGuBMzpukwu1tG1SHTfkUWi7TDkUJVY+gUF/+1Vz/InvaAPzdGnX3kzwUC5COwQU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DusomVnz; arc=none smtp.client-ip=209.85.167.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DusomVnz" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3c02b993a5aso4946723b6e.1 for ; Thu, 22 Feb 2024 09:15:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708622126; x=1709226926; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3wiTNtc8DZaAnMbfsMLShOYB5fWSND5C3ZuWcKva8EA=; b=DusomVnzzgOYSTX+L8tV/zj2F5Z+ON2V6KtxHdGqw5dqTK0Jf0hnInNm2avd+R3kUv pRqZw2JxCofqGGUNJEn3TlsmMeEd9rBctF6Bcp9x1DwL/6E9rzfETIVPkJeb7XIXYCPw KvNhCtFQ2G8n9GtUJWAIVXJqwL+sjXRBV24Y+RY1Hz5txXBI4NV/pbdkgHvC9YQPS88/ 9FiYsVmxD7oPPwnFshsNsr5KmGiOrJfkl5UoWd9df+aJfer8PTVaVR1y7kJjniDgH5lo FWEapTDdZFy2C3jK/vp7cjeOJWg7xikaCOV6477b/n1IHxL35tfGexm1tOmAUMI3d5h4 HrYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708622126; x=1709226926; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3wiTNtc8DZaAnMbfsMLShOYB5fWSND5C3ZuWcKva8EA=; b=lKT3nKJRqpGGgecj/QDUUDWaobokhC2fTRWaRh5+//YWClcVNLDE/wY48Ylr2tg12j nei7nZpctSdLNi6hMkqTcLqS7MaDbZGbDnP36c+6bn0ABPemXS/RIvgGTmkysV0EnqhO 9FgvtTks7ULcH42xbYZ28td8BAZzzzodxn0lnQAsjJZ7+UDzz3sHSzj8yGEXwm5PI6nf n1tgUkkwYiPkk+5O9kdSf0klRkLiAoC+3AJ1NR9Zf4CSKvuBBeZdP4CsekVPStp4vc7q jNASPft9LC7Fbb6NZhaF2DGwGdWOcGE6S1BrjmLQ+kDW65K//eD1UbW86tbzCwYO+FeH voyA== X-Gm-Message-State: AOJu0Yz0rsMBGR3RPnHNidkJAoT96PpMftllfz79Trk77Dvy1lwOA2/a s2IZqY4vElK58tCe9i91f6izyVMOrVXlL6fnJGNnppDz4bZZPCFDkZK8N6me X-Google-Smtp-Source: AGHT+IEaBUSh14BIczjjdffrmP1uPALBHAF3RMKYfzqdGUZb7kkCah67ivqiknlpYfznXVURNXeRKw== X-Received: by 2002:a05:6808:656:b0:3c0:a25:bb4e with SMTP id z22-20020a056808065600b003c00a25bb4emr20200013oih.35.1708622126308; Thu, 22 Feb 2024 09:15:26 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id cc7-20020a056808324700b003c178f6a504sm355898oib.14.2024.02.22.09.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:15:26 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 2/4] qmi: Rename qmi_device_unref to qmi_device_free Date: Thu, 22 Feb 2024 11:14:18 -0600 Message-ID: <20240222171438.1291553-2-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222171438.1291553-1-denkenz@gmail.com> References: <20240222171438.1291553-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since reference counting wasn't used, rename qmi_device_unref to qmi_device_free. --- drivers/qmimodem/qmi.c | 8 +------- drivers/qmimodem/qmi.h | 2 +- plugins/gobi.c | 4 ++-- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 2dde31b11c7c..8587766efe1f 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -63,7 +63,6 @@ struct qmi_device_ops { }; struct qmi_device { - int ref_count; int fd; GIOChannel *io; guint read_watch; @@ -920,8 +919,6 @@ static int qmi_device_init(struct qmi_device *device, int fd, __debug_device(device, "device %p new", device); - device->ref_count = 1; - device->fd = fd; flags = fcntl(device->fd, F_GETFL, NULL); @@ -967,14 +964,11 @@ static void __qmi_device_shutdown_finished(struct qmi_device *device) device->ops->destroy(device); } -void qmi_device_unref(struct qmi_device *device) +void qmi_device_free(struct qmi_device *device) { if (!device) return; - if (__sync_sub_and_fetch(&device->ref_count, 1)) - return; - __debug_device(device, "device %p free", device); l_queue_destroy(device->control_queue, __request_free); diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 14ad84e5006a..ef2140faad9c 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -81,7 +81,7 @@ typedef void (*qmi_debug_func_t)(const char *str, void *user_data); typedef void (*qmi_shutdown_func_t)(void *user_data); typedef void (*qmi_discover_func_t)(void *user_data); -void qmi_device_unref(struct qmi_device *device); +void qmi_device_free(struct qmi_device *device); void qmi_device_set_debug(struct qmi_device *device, qmi_debug_func_t func, void *user_data); diff --git a/plugins/gobi.c b/plugins/gobi.c index 4134c62d398e..2b29afbefdbe 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -147,7 +147,7 @@ static void gobi_remove(struct ofono_modem *modem) cleanup_services(data); - qmi_device_unref(data->device); + qmi_device_free(data->device); g_free(data); } @@ -161,7 +161,7 @@ static void shutdown_cb(void *user_data) data->discover_attempts = 0; - qmi_device_unref(data->device); + qmi_device_free(data->device); data->device = NULL; ofono_modem_set_powered(modem, FALSE); From patchwork Thu Feb 22 17:14:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13567626 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F2AB39FC7 for ; Thu, 22 Feb 2024 17:15:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708622129; cv=none; b=L/YiCQPP2CAhnX4jKLznmfSNXgGv1xHI6md2xV5SmomkpdOJsivBvUMMYqaqctSL75vjXgXBXRWKXwMwn1pxmBLC/keBDNoGQ1m2c+mK797f3FMePMv60AtIDFYO4L10lM/fLq7/Fu31hu6VoOV6UEy3O9qEw+kbUIUTcqo+7C8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708622129; c=relaxed/simple; bh=XimFDxnGu9aNf9IZidH/osLeXXM9BbEFCGuhoIrJ3NI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l6Y839ZGlQf8D1oCFKKSSGZQv7AzQX0nKBd9PS14yrJKIjlPFzJOc5MakJ19vvBpa5cNSbaSgMdeIUqzf1ZU6Y1uFkH/psoWbEZI75NuTKf3ZfxYzi3lYD0f5nOAqbIdV9UjaG5q5wLz573OHHsM2IuUXrRvD3EaKb6c+4qMwhM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=g3sZMES4; arc=none smtp.client-ip=209.85.167.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g3sZMES4" Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3c15b7b36bbso754092b6e.1 for ; Thu, 22 Feb 2024 09:15:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708622127; x=1709226927; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OZGOSGeE/jrsfV9okl7aggWgZdx42Y02vzP071GRclQ=; b=g3sZMES44Gy33vRjfPOMSHAhkHCrm0rgjsXURWLGEtje41YHox9Z8wcil+Y+uLoCS7 MAqKbDKZw7Wa7FCpmltC6/lbO1Va5fmfz7nWcM/hrBlKMj8g9bSfoV4MyYcHH2cLvxaA 7YNd/e/xROwN+L4LJDuqUP0eFRThbsB4VPUIBXT67MRGrDQSzUW4UCLGFnwlwTgvHmsp k9A6nfMxBaViRIR0I4URo+Z9lnaUcGnIzxXABp3NiPDk7dQ1e3hQJgvSQzPvNOwRmh8H dTKWuo8C0i1TIOBw958OgR8Soz0ULJlo5Pkh851DLqWieMSXvU78QqcD9U9MjRVRXUcj Vlbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708622127; x=1709226927; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OZGOSGeE/jrsfV9okl7aggWgZdx42Y02vzP071GRclQ=; b=NvL7WmgWjWjG9B5+d6aeOR11BxoUfYH35MqRDT7zG6LMzmzMb8Jm/yEJJ0uRvjL8vt I/QJx4zUZroXL7JfTqfT4MscQCZrR6fprZTezlObhLqJe6MtvR11LdtGX9SRH339xH9S vCgkv7sRaMUThA+FKwicZQ0Y4jyTnC1yp3wS4B+mmxh9KFRwTIE6JfjFmgbyo5PJ+qlV PX7c1Jo/3swoDKEkh8467sZjSs5FmABmTCTJJYTnHEicBrjPHdaAXjbScA4L4MK06ziA bfo/CYmXLpPF63XD8YXYsz1QGiloSwKaLhPDa+mI2GSCQmW3lPy9jacln9hzgXLaoGhC kZAg== X-Gm-Message-State: AOJu0Yw+0MjwKJrnsbdqQ7wXlvJt1NKrB2/ZwHe88eG6ZkSp/S2PD8Ep uTCb3AlSk+pC/+V+3xpkK4vVPwH7nE4VsL9LQVg0YILyvIp2VqaHusYgJ0dz X-Google-Smtp-Source: AGHT+IFb8qOYaLegEvhhukJ6ubu3Sks65XEtmZGly8FfYMe0xeAxOjvo0BWw51OuYHu3VYQ1FKBy1Q== X-Received: by 2002:a05:6808:1688:b0:3c0:449c:b6a5 with SMTP id bb8-20020a056808168800b003c0449cb6a5mr27712956oib.0.1708622127021; Thu, 22 Feb 2024 09:15:27 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id cc7-20020a056808324700b003c178f6a504sm355898oib.14.2024.02.22.09.15.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:15:26 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 3/4] qmi: Introduce client_release driver method Date: Thu, 22 Feb 2024 11:14:19 -0600 Message-ID: <20240222171438.1291553-3-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222171438.1291553-1-denkenz@gmail.com> References: <20240222171438.1291553-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When shutting down, any requested QMUX clients must be released properly. This is handled by sending a QMUX Control message with the service type and client id. QRTR doesn't have such a concept, a client is closed by virtue of closing the socket. Abstract away the implementation details behind client_release() driver method. --- drivers/qmimodem/qmi.c | 76 +++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 8587766efe1f..b2f0f72190a1 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -56,6 +56,8 @@ struct qmi_version { }; struct qmi_device_ops { + void (*client_release)(struct qmi_device *device, + uint16_t service_type, uint16_t client_id); int (*shutdown)(struct qmi_device *device, qmi_shutdown_func_t shutdown_func, void *user, qmi_destroy_func_t destroy); @@ -78,7 +80,6 @@ struct qmi_device { struct qmi_version *version_list; uint8_t version_count; struct l_hashmap *service_list; - unsigned int release_users; const struct qmi_device_ops *ops; bool shutting_down : 1; bool destroyed : 1; @@ -93,6 +94,7 @@ struct qmi_device_qmux { void *shutdown_user_data; qmi_destroy_func_t shutdown_destroy; struct l_idle *shutdown_idle; + unsigned int release_users; }; struct qmi_service { @@ -1312,21 +1314,6 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, return true; } -static void release_client(struct qmi_device *device, - uint8_t type, uint8_t client_id, - qmi_message_func_t func, void *user_data) -{ - unsigned char release_req[] = { 0x01, 0x02, 0x00, type, client_id }; - struct qmi_request *req; - - req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, - QMI_CTL_RELEASE_CLIENT_ID, - release_req, sizeof(release_req), - func, user_data); - - __request_submit(device, req); -} - int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, void *user_data, qmi_destroy_func_t destroy) { @@ -1535,7 +1522,34 @@ done: return res; } -static void qmux_shutdown_destroy(void *user_data) +static void qmux_client_release_callback(uint16_t message, uint16_t length, + const void *buffer, void *user_data) +{ + struct qmi_device_qmux *qmux = user_data; + + qmux->release_users--; +} + +static void qmi_device_qmux_client_release(struct qmi_device *device, + uint16_t service_type, + uint16_t client_id) +{ + struct qmi_device_qmux *qmux = + l_container_of(device, struct qmi_device_qmux, super); + uint8_t release_req[] = { 0x01, 0x02, 0x00, service_type, client_id }; + struct qmi_request *req; + + qmux->release_users++; + + req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, + QMI_CTL_RELEASE_CLIENT_ID, + release_req, sizeof(release_req), + qmux_client_release_callback, qmux); + + __request_submit(device, req); +} + +static void qmux_shutdown_destroy(gpointer user_data) { struct qmi_device_qmux *qmux = user_data; @@ -1551,7 +1565,7 @@ static void qmux_shutdown_callback(struct l_idle *idle, void *user_data) { struct qmi_device_qmux *qmux = user_data; - if (qmux->super.release_users > 0) + if (qmux->release_users > 0) return; qmux->super.shutting_down = true; @@ -1603,6 +1617,7 @@ static void qmi_device_qmux_destroy(struct qmi_device *device) } static const struct qmi_device_ops qmux_ops = { + .client_release = qmi_device_qmux_client_release, .shutdown = qmi_device_qmux_shutdown, .destroy = qmi_device_qmux_destroy, }; @@ -2191,17 +2206,6 @@ bool qmi_service_create(struct qmi_device *device, user_data, destroy); } -static void service_release_callback(uint16_t message, uint16_t length, - const void *buffer, void *user_data) -{ - struct qmi_service *service = user_data; - - if (service->device) - service->device->release_users--; - - l_free(service); -} - struct qmi_service *qmi_service_ref(struct qmi_service *service) { if (!service) @@ -2214,6 +2218,7 @@ struct qmi_service *qmi_service_ref(struct qmi_service *service) void qmi_service_unref(struct qmi_service *service) { + struct qmi_device *device; unsigned int hash_id; if (!service) @@ -2222,7 +2227,8 @@ void qmi_service_unref(struct qmi_service *service) if (__sync_sub_and_fetch(&service->ref_count, 1)) return; - if (!service->device) { + device = service->device; + if (!device) { l_free(service); return; } @@ -2232,13 +2238,13 @@ void qmi_service_unref(struct qmi_service *service) hash_id = service->type | (service->client_id << 8); - l_hashmap_remove(service->device->service_list, - L_UINT_TO_PTR(hash_id)); + l_hashmap_remove(device->service_list, L_UINT_TO_PTR(hash_id)); - service->device->release_users++; + if (device->ops->client_release) + device->ops->client_release(device, service->type, + service->client_id); - release_client(service->device, service->type, service->client_id, - service_release_callback, service); + l_free(service); } const char *qmi_service_get_identifier(struct qmi_service *service) From patchwork Thu Feb 22 17:14:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13567627 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C24915530F for ; Thu, 22 Feb 2024 17:15:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708622131; cv=none; b=NDpc3TrOXdlX2lzXdNP/+uRNbwbFGXmpDDvng/uhFAEBZnjsCVlSR6sUZxZhn0FchbWPaNglyh5k86GTzFUJlx0kLiGv3/D0DEn6cPYm0waXvPoy9FQ+xWbNWItZRwX2bHQ+mOwRi3qw9xCGl8yzjgECWTdYnkTO3Y+gQCxVI6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708622131; c=relaxed/simple; bh=fUcfvsRDblGXA4HEmBd2kkiiiBnqtKIt4CwdlBoeBE0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X3UoxrA2K9TCoC5+gyRqeloYdq9xXa9ASVEgPFo2xP2CDDWizXqI092oF37IiF8kVebIkZ5y7r+ldJuYhL9bUJMM0vd5mkGel9CehF6dAbx9EafVe2+ZYlMVromE7qGokyBEkGT/Z+EHDIeJZpKXo1y9NwKKP7evK1g7/njoAk8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fizf2XAO; arc=none smtp.client-ip=209.85.167.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fizf2XAO" Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3bb9d54575cso1337029b6e.2 for ; Thu, 22 Feb 2024 09:15:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708622128; x=1709226928; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6cZTrmZvewyCz9UPHuMDihzz4/pRGJklgTR2XI0KwI4=; b=fizf2XAOM4tXAxTlxWElfZx7+emzlYyNPMywmQ/vYXsix2rgLtsOXZNvXPfqmP/Tgk f3TOlOsSkjLi4XvgMTvWMUDVVosVMjk5TLo4jtv4NAs+nEfz3kg9CFb9hvT1dbEjovhC LtnwTkvYhrR+UaiC4jvGjE+HBemIwrB7+iktBnybJZIjLkoRDloXs1skz6LyyeTWGwLh aa+VRmPBQCTwWEy+RIkpl2iv29S6OlU9BeYjdWRJ2gEEWL3gdI4DhHRhz2VcGp/K1ePK s1f+iQ/VXUKyVE7QSpYnbjwaEZ/PpMrDzQyaoI81An2dxVV/EoTVm66WNPVcFjN0PZyM CgjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708622128; x=1709226928; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6cZTrmZvewyCz9UPHuMDihzz4/pRGJklgTR2XI0KwI4=; b=NndAugKCoX+zWCOSm/Bs5/4PDu2JQd5RhoCX2S+LcQ3KLiRy99SV75zvLk6aWxXje4 NfyiJW7rdWeIsqSDZoJmmOtE6ZJczDK2696rAGfO8794EZkkWn++4/NojfGmkA7riZ2K yFHjWyxAN1SAFe/XIjllQvuANSJldGYkkIlg53u3Dq4NPTQ8pXbrU+1Aey3wWmLnEGV7 9nDiE8OksZigRkyxpwnp0Dsln/ObafXLHiAavCUG9WN16XHwNl3QFZ1cQ7Y1lbNqmn7C 25M4zUk6izVLciJZwT58cnM1RPX0e6Iruo4QWaRmt7yo6GDUXxFs2P5sObmdllfIfk56 FTYQ== X-Gm-Message-State: AOJu0Yz+B0pFngINiPBqI5WHxzKiqFMYTkFjtpJ0J9sNXTokrWk4P451 yWtH8FCm4Tb+FvJZs7rE41uCVz5uCfyHL7SNatsTQw4raz+y76dwlJinnw8J X-Google-Smtp-Source: AGHT+IF6zl0Rzo1GX5HU8o0X0mVd3RqBQRC3yVzNObjC0XCL8KGgdDWr2f906PmzS2JSOrfWRZ1zUQ== X-Received: by 2002:a05:6808:13cd:b0:3c1:7019:ae9b with SMTP id d13-20020a05680813cd00b003c17019ae9bmr6066780oiw.43.1708622127897; Thu, 22 Feb 2024 09:15:27 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id cc7-20020a056808324700b003c178f6a504sm355898oib.14.2024.02.22.09.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:15:27 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 4/4] qmi: Introduce client_create driver method Date: Thu, 22 Feb 2024 11:14:20 -0600 Message-ID: <20240222171438.1291553-4-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240222171438.1291553-1-denkenz@gmail.com> References: <20240222171438.1291553-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On QMUX, before using a particular QMI service, a client must first be created. Client creation is accomplished by sending a specific message to the control service and waiting for the reply. On QRTR, no such round trip is required. A QRTR socket can immediately access all services by virtue of creating a socket, with each QMI service allocating an implicit client identifier. Abstract away the client creation details behind the client_create() driver method. Rename the service_create_data structure to qmux_client_create_data in order to make it clear that this operation is QMUX specific. --- drivers/qmimodem/qmi.c | 450 +++++++++++++++++++++-------------------- 1 file changed, 231 insertions(+), 219 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index b2f0f72190a1..ec7a74778079 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -56,6 +56,10 @@ struct qmi_version { }; struct qmi_device_ops { + int (*client_create)(struct qmi_device *device, + uint16_t service_type, + qmi_create_func_t func, + void *user, qmi_destroy_func_t destroy); void (*client_release)(struct qmi_device *device, uint16_t service_type, uint16_t client_id); int (*shutdown)(struct qmi_device *device, @@ -1522,6 +1526,226 @@ done: return res; } +struct service_create_shared_data { + struct discovery super; + struct qmi_service *service; + struct qmi_device *device; + qmi_create_func_t func; + void *user_data; + qmi_destroy_func_t destroy; + struct l_idle *idle; +}; + +static void service_create_shared_reply(struct l_idle *idle, void *user_data) +{ + struct service_create_shared_data *data = user_data; + + l_idle_remove(data->idle); + data->idle = NULL; + data->func(data->service, data->user_data); + + __qmi_device_discovery_complete(data->device, &data->super); +} + +static void service_create_shared_pending_reply(struct qmi_device *device, + unsigned int type, + struct qmi_service *service) +{ + gpointer key = L_UINT_TO_PTR(type | 0x80000000); + GList **shared = l_hashmap_remove(device->service_list, key); + GList *l; + + for (l = *shared; l; l = l->next) { + struct service_create_shared_data *shared_data = l->data; + + shared_data->service = qmi_service_ref(service); + shared_data->idle = l_idle_create(service_create_shared_reply, + shared_data, NULL); + } + + g_list_free(*shared); + l_free(shared); +} + +static void service_create_shared_data_free(gpointer user_data) +{ + struct service_create_shared_data *data = user_data; + + if (data->idle) + l_idle_remove(data->idle); + + qmi_service_unref(data->service); + + if (data->destroy) + data->destroy(data->user_data); + + l_free(data); +} + +struct qmux_client_create_data { + struct discovery super; + struct qmi_device *device; + uint8_t type; + uint16_t major; + uint16_t minor; + qmi_create_func_t func; + void *user_data; + qmi_destroy_func_t destroy; + struct l_timeout *timeout; + uint16_t tid; +}; + +static void qmux_client_create_data_free(gpointer user_data) +{ + struct qmux_client_create_data *data = user_data; + + if (data->timeout) + l_timeout_remove(data->timeout); + + if (data->destroy) + data->destroy(data->user_data); + + l_free(data); +} + +static void qmux_client_create_reply(struct l_timeout *timeout, void *user_data) +{ + struct qmux_client_create_data *data = user_data; + struct qmi_device *device = data->device; + struct qmi_request *req; + + DBG(""); + + service_create_shared_pending_reply(device, data->type, NULL); + + /* remove request from queues */ + req = find_control_request(device, data->tid); + + l_timeout_remove(data->timeout); + data->timeout = NULL; + + if (data->func) + data->func(NULL, data->user_data); + + __qmi_device_discovery_complete(device, &data->super); + + if (req) + __request_free(req); +} + +static void qmux_client_create_callback(uint16_t message, uint16_t length, + const void *buffer, void *user_data) +{ + struct qmux_client_create_data *data = user_data; + struct qmi_device *device = data->device; + struct qmi_service *service = NULL; + struct qmi_service *old_service = NULL; + const struct qmi_result_code *result_code; + const struct qmi_client_id *client_id; + uint16_t len; + unsigned int hash_id; + + result_code = tlv_get(buffer, length, 0x02, &len); + if (!result_code) + goto done; + + if (len != QMI_RESULT_CODE_SIZE) + goto done; + + client_id = tlv_get(buffer, length, 0x01, &len); + if (!client_id) + goto done; + + if (len != QMI_CLIENT_ID_SIZE) + goto done; + + if (client_id->service != data->type) + goto done; + + service = l_new(struct qmi_service, 1); + + service->ref_count = 1; + service->device = data->device; + + service->type = data->type; + service->major = data->major; + service->minor = data->minor; + + service->client_id = client_id->client; + + __debug_device(device, "service created [client=%d,type=%d]", + service->client_id, service->type); + + hash_id = service->type | (service->client_id << 8); + + l_hashmap_replace(device->service_list, L_UINT_TO_PTR(hash_id), + service, (void **) &old_service); + + if (old_service) + service_destroy(old_service); + +done: + service_create_shared_pending_reply(device, data->type, service); + + data->func(service, data->user_data); + qmi_service_unref(service); + + __qmi_device_discovery_complete(data->device, &data->super); +} + +static int qmi_device_qmux_client_create(struct qmi_device *device, + uint16_t service_type, + qmi_create_func_t func, void *user_data, + qmi_destroy_func_t destroy) +{ + unsigned char client_req[] = { 0x01, 0x01, 0x00, service_type }; + struct qmi_request *req; + struct qmux_client_create_data *data; + GList **shared; + unsigned int type_val = service_type; + int i; + + if (!device->version_list) + return -ENOENT; + + shared = l_new(GList *, 1); + data = l_new(struct qmux_client_create_data, 1); + + data->super.destroy = qmux_client_create_data_free; + data->device = device; + data->type = service_type; + data->func = func; + data->user_data = user_data; + data->destroy = destroy; + + __debug_device(device, "service create [type=%d]", service_type); + + for (i = 0; i < device->version_count; i++) { + if (device->version_list[i].type == data->type) { + data->major = device->version_list[i].major; + data->minor = device->version_list[i].minor; + break; + } + } + + req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, + QMI_CTL_GET_CLIENT_ID, + client_req, sizeof(client_req), + qmux_client_create_callback, data); + + data->tid = __request_submit(device, req); + data->timeout = l_timeout_create(8, qmux_client_create_reply, + data, NULL); + + __qmi_device_discovery_started(device, &data->super); + + /* Mark service creation as pending */ + l_hashmap_insert(device->service_list, + L_UINT_TO_PTR(type_val | 0x80000000), shared); + + return 0; +} + static void qmux_client_release_callback(uint16_t message, uint16_t length, const void *buffer, void *user_data) { @@ -1617,6 +1841,7 @@ static void qmi_device_qmux_destroy(struct qmi_device *device) } static const struct qmi_device_ops qmux_ops = { + .client_create = qmi_device_qmux_client_create, .client_release = qmi_device_qmux_client_release, .shutdown = qmi_device_qmux_shutdown, .destroy = qmi_device_qmux_destroy, @@ -1920,224 +2145,6 @@ bool qmi_result_get_uint64(struct qmi_result *result, uint8_t type, return true; } -struct service_create_data { - struct discovery super; - struct qmi_device *device; - uint8_t type; - uint16_t major; - uint16_t minor; - qmi_create_func_t func; - void *user_data; - qmi_destroy_func_t destroy; - struct l_timeout *timeout; - uint16_t tid; -}; - -static void service_create_data_free(gpointer user_data) -{ - struct service_create_data *data = user_data; - - if (data->timeout) - l_timeout_remove(data->timeout); - - if (data->destroy) - data->destroy(data->user_data); - - l_free(data); -} - -struct service_create_shared_data { - struct discovery super; - struct qmi_service *service; - struct qmi_device *device; - qmi_create_func_t func; - void *user_data; - qmi_destroy_func_t destroy; - struct l_idle *idle; -}; - -static void service_create_shared_reply(struct l_idle *idle, void *user_data) -{ - struct service_create_shared_data *data = user_data; - - l_idle_remove(data->idle); - data->idle = NULL; - data->func(data->service, data->user_data); - - __qmi_device_discovery_complete(data->device, &data->super); -} - -static void service_create_shared_pending_reply(struct qmi_device *device, - unsigned int type, - struct qmi_service *service) -{ - gpointer key = L_UINT_TO_PTR(type | 0x80000000); - GList **shared = l_hashmap_remove(device->service_list, key); - GList *l; - - for (l = *shared; l; l = l->next) { - struct service_create_shared_data *shared_data = l->data; - - shared_data->service = qmi_service_ref(service); - shared_data->idle = l_idle_create(service_create_shared_reply, - shared_data, NULL); - } - - g_list_free(*shared); - l_free(shared); -} - -static void service_create_reply(struct l_timeout *timeout, void *user_data) -{ - struct service_create_data *data = user_data; - struct qmi_device *device = data->device; - struct qmi_request *req; - - DBG(""); - - service_create_shared_pending_reply(device, data->type, NULL); - - /* remove request from queues */ - req = find_control_request(device, data->tid); - - l_timeout_remove(data->timeout); - data->timeout = NULL; - - if (data->func) - data->func(NULL, data->user_data); - - __qmi_device_discovery_complete(device, &data->super); - - if (req) - __request_free(req); -} - -static void service_create_callback(uint16_t message, uint16_t length, - const void *buffer, void *user_data) -{ - struct service_create_data *data = user_data; - struct qmi_device *device = data->device; - struct qmi_service *service = NULL; - struct qmi_service *old_service = NULL; - const struct qmi_result_code *result_code; - const struct qmi_client_id *client_id; - uint16_t len; - unsigned int hash_id; - - result_code = tlv_get(buffer, length, 0x02, &len); - if (!result_code) - goto done; - - if (len != QMI_RESULT_CODE_SIZE) - goto done; - - client_id = tlv_get(buffer, length, 0x01, &len); - if (!client_id) - goto done; - - if (len != QMI_CLIENT_ID_SIZE) - goto done; - - if (client_id->service != data->type) - goto done; - - service = l_new(struct qmi_service, 1); - - service->ref_count = 1; - service->device = data->device; - - service->type = data->type; - service->major = data->major; - service->minor = data->minor; - - service->client_id = client_id->client; - - __debug_device(device, "service created [client=%d,type=%d]", - service->client_id, service->type); - - hash_id = service->type | (service->client_id << 8); - - l_hashmap_replace(device->service_list, L_UINT_TO_PTR(hash_id), - service, (void **) &old_service); - - if (old_service) - service_destroy(old_service); - -done: - service_create_shared_pending_reply(device, data->type, service); - - data->func(service, data->user_data); - qmi_service_unref(service); - - __qmi_device_discovery_complete(data->device, &data->super); -} - -static bool service_create(struct qmi_device *device, - uint8_t type, qmi_create_func_t func, - void *user_data, qmi_destroy_func_t destroy) -{ - struct service_create_data *data; - unsigned char client_req[] = { 0x01, 0x01, 0x00, type }; - struct qmi_request *req; - GList **shared; - unsigned int type_val = type; - int i; - - if (!device->version_list) - return false; - - shared = l_new(GList *, 1); - data = l_new(struct service_create_data, 1); - - data->super.destroy = service_create_data_free; - data->device = device; - data->type = type; - data->func = func; - data->user_data = user_data; - data->destroy = destroy; - - __debug_device(device, "service create [type=%d]", type); - - for (i = 0; i < device->version_count; i++) { - if (device->version_list[i].type == data->type) { - data->major = device->version_list[i].major; - data->minor = device->version_list[i].minor; - break; - } - } - - req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, - QMI_CTL_GET_CLIENT_ID, - client_req, sizeof(client_req), - service_create_callback, data); - - data->tid = __request_submit(device, req); - data->timeout = l_timeout_create(8, service_create_reply, data, NULL); - - __qmi_device_discovery_started(device, &data->super); - - /* Mark service creation as pending */ - l_hashmap_insert(device->service_list, - L_UINT_TO_PTR(type_val | 0x80000000), shared); - - return true; -} - -static void service_create_shared_data_free(gpointer user_data) -{ - struct service_create_shared_data *data = user_data; - - if (data->idle) - l_idle_remove(data->idle); - - qmi_service_unref(data->service); - - if (data->destroy) - data->destroy(data->user_data); - - l_free(data); -} - bool qmi_service_create_shared(struct qmi_device *device, uint16_t type, qmi_create_func_t func, void *user_data, qmi_destroy_func_t destroy) @@ -2145,6 +2152,7 @@ bool qmi_service_create_shared(struct qmi_device *device, uint16_t type, GList **l = NULL; struct qmi_service *service = NULL; unsigned int type_val = type; + int r; if (!device || !func) return false; @@ -2195,7 +2203,11 @@ bool qmi_service_create_shared(struct qmi_device *device, uint16_t type, return true; } - return service_create(device, type, func, user_data, destroy); + if (!device->ops->client_create) + return -ENOTSUP; + + r = device->ops->client_create(device, type, func, user_data, destroy); + return r == 0; } bool qmi_service_create(struct qmi_device *device,