From patchwork Tue Feb 20 22:40:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13564645 Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (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 6CA601468E0 for ; Tue, 20 Feb 2024 22:42:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468926; cv=none; b=RgUFLguAllGbjzDOjvDLLsW/BSZe0/TodinTwVn05xc2wNGbg0+nkXuTMUGNaUNWoemc5yp/nC1V9Ci917VF4C6FToCnQyf3dQOw8dKr6ZSssoFcxl9u9NnqZOEXjfMZuP38N76T6jJXeICypm3COcSSFMhbfan7JOro/KnqvC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468926; c=relaxed/simple; bh=if2CZNJ0qIOL5MDsiw3rQ9BRo8SzIdSocUN8j3tfyyA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Du92MsbVoPKmZCN5ZS55E5llv2NKNEZpHV5e7a80NNjYX+ukX60AXe88N1tg3BE8rekMEMLxYuTsxHdgkuUHdRnJbR4aM0JZnT0OhOVkiL2BEqxdwwQXeMGn6pgZecVTzWqy+AFHro7LYQaKPQe3Dl39+fbuRJQ0lUVthInfzNk= 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=SZMQHeE4; arc=none smtp.client-ip=209.85.160.44 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="SZMQHeE4" Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-204235d0913so3759458fac.1 for ; Tue, 20 Feb 2024 14:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708468923; x=1709073723; 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=y56zb0+xyFv/JiVTwipsKTYobWIQ1w7D+moGGFVJfys=; b=SZMQHeE4cA0wq/5Np4P281gsERCoM0OYCODRgkROddpRLPUtT3H3Vqv6yyz6j4h+g3 vS6uNGqCYxQJGAGOXTccqdNED+G4EfZ7Rrg8TQSEdxYQGZS7XHBuBY62HpC/e2jTi4gF Q3ZydPYyv/LJV11zj9Uvn+5SorFPzlBnlhlOQTqWpOCNC3jkZ+gGgLSi+HPRHYrZXp3V mY+YS3wTqZKbjekCCq2VJXm5tboINtYEHkhXClC3Hs6XY17WMq3kDKQ0FUZzdbGL8eQu 9PmmZ52+2SVUEseBLTqs2TQ7BDrR4O7r+CmGsUikZ+K/Hk1Z4tYm5Nf3dDMqisWThA7H ctiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708468923; x=1709073723; 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=y56zb0+xyFv/JiVTwipsKTYobWIQ1w7D+moGGFVJfys=; b=RhOtsewnwsIfGNsk8WAkv2g2g8Pi1uysXywb04jjYJ64KKAJ8cRmRH8eTAkTM+7Mob ZTj5mSa5I0zlq5dXVKGs835FxBLTxuy1mkF5SBcuK2XLSStRsP405PhcD8PA32JiloeA yDr1ik2UjbJCmdghqRNhTKvCOVSw39SaKjCZbQmS8d2sFp5Vxa1pp6TTw+eFCmEXFHO+ rF0plRBfDr7GNYCKk9UvmTO8MV12TKWnUInM3p5WLN75qu2bUNF+dFR3v+mP9g8n958r GGm3ojiLm9q6Hy/JyAy75M2/m0jYFNXZSRGgFHt8IxqtkbjLx3175bZEmZtOMcoq23rg 3cEQ== X-Gm-Message-State: AOJu0YzcjyqtCekDRtOz3SmtYlVyCDan8/O4dD6xvQITir3lHC2d5U5C Rt8DiOy+o81G2RVZ7Z4hTJlsO0nV4lEnZXJD83tflZGqYXorYho/sodfmIRb X-Google-Smtp-Source: AGHT+IEJqqPOVymAJDsMmCVXcbXElwc/249e5iiZ9mRH7YYHp/Fr+kHZJ1cI8WEAJlLvz8i9yqHu1g== X-Received: by 2002:a05:6870:5588:b0:21e:ddc2:c15b with SMTP id qj8-20020a056870558800b0021eddc2c15bmr7213669oac.14.1708468923181; Tue, 20 Feb 2024 14:42:03 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id nd15-20020a056871440f00b0021a1492f000sm2056403oab.38.2024.02.20.14.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 14:42:02 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 1/7] qmi: Remove qmi_device_sync Date: Tue, 20 Feb 2024 16:40:54 -0600 Message-ID: <20240220224115.1254853-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 is an implementation detail of the QMUX/CTL interface. Since the only caller always invokes SYNC after discovery if supported, simplify the SYNC operation to be part of the discovery procedure and remove the relevant APIs from qmi_device. --- drivers/qmimodem/qmi.c | 88 +++++++++++++++++------------------------- drivers/qmimodem/qmi.h | 5 --- plugins/gobi.c | 10 ++--- 3 files changed, 39 insertions(+), 64 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index c9c809757427..ee51a7db2368 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1176,6 +1176,35 @@ static void discover_data_free(gpointer user_data) g_free(data); } +static void qmi_device_sync_callback(uint16_t message, uint16_t length, + const void *buffer, void *user_data) +{ + struct discover_data *data = user_data; + + if (data->func) + data->func(data->user_data); + + __qmi_device_discovery_complete(data->device, &data->super); +} + +/* sync will release all previous clients */ +static bool qmi_device_sync(struct qmi_device *device, + struct discover_data *data) +{ + struct qmi_request *req; + + __debug_device(device, "Sending sync to reset QMI"); + + req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, + QMI_CTL_SYNC, NULL, 0, + qmi_device_sync_callback, data); + + __request_submit(device, req); + + return true; +} + + static void discover_callback(uint16_t message, uint16_t length, const void *buffer, void *user_data) { @@ -1249,6 +1278,13 @@ done: device->version_list = list; device->version_count = count; + /* if the device support the QMI call SYNC over the CTL interface */ + if ((device->control_major == 1 && device->control_minor >= 5) || + device->control_major > 1) { + qmi_device_sync(data->device, data); + return; + } + if (data->func) data->func(data->user_data); @@ -1414,58 +1450,6 @@ bool qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, return true; } -struct sync_data { - qmi_sync_func_t func; - void *user_data; -}; - -static void qmi_device_sync_callback(uint16_t message, uint16_t length, - const void *buffer, void *user_data) -{ - struct sync_data *data = user_data; - - if (data->func) - data->func(data->user_data); - - g_free(data); -} - -/* sync will release all previous clients */ -bool qmi_device_sync(struct qmi_device *device, - qmi_sync_func_t func, void *user_data) -{ - struct qmi_request *req; - struct sync_data *func_data; - - if (!device) - return false; - - __debug_device(device, "Sending sync to reset QMI"); - - func_data = g_new0(struct sync_data, 1); - func_data->func = func; - func_data->user_data = user_data; - - req = __request_alloc(QMI_SERVICE_CONTROL, 0x00, - QMI_CTL_SYNC, - NULL, 0, - qmi_device_sync_callback, func_data); - - __request_submit(device, req); - - return true; -} - -/* if the device support the QMI call SYNC over the CTL interface */ -bool qmi_device_is_sync_supported(struct qmi_device *device) -{ - if (device == NULL) - return false; - - return (device->control_major > 1 || - (device->control_major == 1 && device->control_minor >= 5)); -} - static bool get_device_file_name(struct qmi_device *device, char *file_name, int size) { diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 21537a76c64e..fc2a309578c4 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -78,7 +78,6 @@ typedef void (*qmi_destroy_func_t)(void *user_data); struct qmi_device; typedef void (*qmi_debug_func_t)(const char *str, void *user_data); -typedef void (*qmi_sync_func_t)(void *user_data); typedef void (*qmi_shutdown_func_t)(void *user_data); typedef void (*qmi_discover_func_t)(void *user_data); @@ -101,10 +100,6 @@ bool qmi_device_has_service(struct qmi_device *device, uint16_t type); bool qmi_device_get_service_version(struct qmi_device *device, uint16_t type, uint16_t *major, uint16_t *minor); -bool qmi_device_sync(struct qmi_device *device, - qmi_sync_func_t func, void *user_data); -bool qmi_device_is_sync_supported(struct qmi_device *device); - enum qmi_device_expected_data_format qmi_device_get_expected_data_format( struct qmi_device *device); bool qmi_device_set_expected_data_format(struct qmi_device *device, diff --git a/plugins/gobi.c b/plugins/gobi.c index 76c9d68d2df5..020d6ba2685e 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -364,13 +364,12 @@ error: shutdown_device(modem); } -static void create_shared_dms(void *user_data) +static void create_shared_dms(struct ofono_modem *modem) { - struct ofono_modem *modem = user_data; struct gobi_data *data = ofono_modem_get_data(modem); qmi_service_create_shared(data->device, QMI_SERVICE_DMS, - create_dms_cb, modem, NULL); + create_dms_cb, modem, NULL); } static void discover_cb(void *user_data) @@ -417,10 +416,7 @@ static void discover_cb(void *user_data) return; } - if (qmi_device_is_sync_supported(data->device)) - qmi_device_sync(data->device, create_shared_dms, modem); - else - create_shared_dms(modem); + create_shared_dms(modem); } static int gobi_enable(struct ofono_modem *modem) From patchwork Tue Feb 20 22:40:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13564646 Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) (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 35FF9153BDD for ; Tue, 20 Feb 2024 22:42:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468926; cv=none; b=ddNwm62cmeZdsSh8U+JX7dIfxDJ47NZjD5KbuGwU9eftek47fvUXgeMxyaeU0P2Fsy8QHEpq2OqGBGzD8n5QSNCOrcnVkEoy7i9yuaD50HSoK6NwCXViJATnCQjLFoorlTVxUWnk0jvgTnprIaxpxlxKq+xoG8YOxfkk6Vij1TU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468926; c=relaxed/simple; bh=8eDo5PSpDRPvjhgGVqf3JdM9PduMbxEPuwiAs+KRiQw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G+jJKGTqng9cIvGaVIvRV2B6BqVTQ3Kj/FIkml9DTESWw6pnWl6bKU+Ze0Sh8s+c/QyloB2FGGi/vnTak0S6Nz31e+K5YqVpjsMYnBYuxtAZG4HHachOkm6acLznEGeMR+2iat8TtiCI0fn9sfXbkUQ+3RS37UO0lqP7ThdOaTI= 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=LYG6oNRS; arc=none smtp.client-ip=209.85.160.45 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="LYG6oNRS" Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-21e6be74db4so2713648fac.2 for ; Tue, 20 Feb 2024 14:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708468924; x=1709073724; 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=lunPUoDCNCZkBDcXsOpMZQFsd6MlY7UAu7A2KFNl9Gg=; b=LYG6oNRS4lqACA9pqqOeKMx0E9WZFdwbaSDnotncdYKGISHsTthOeHLmSGQTEIU6r2 YuYjRsqyi+C2Jk8ALgynRwd+WY/24dKsxjcabWjuWbS0/9pH0gma7k1oNcMF+owe6+x1 hmZ6a/UGgppOo964abPnsXyQNoI5Smfv/7tTzlOQ4pJqtebwu1vlxzIIOtWcBTZn82n+ dA6oxJ0JxwTXpwTxRtNuvQd4gIHA+LPuy7GDJC0V8NzB7Hk5qDMtn9ax7zAxRbRGd+qZ zQiwPUM072jCPV3qnqYDza7dXRx1tglC3OfPbvEoflqxQrjDYvzgwymV6eShXsRnwASA zl2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708468924; x=1709073724; 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=lunPUoDCNCZkBDcXsOpMZQFsd6MlY7UAu7A2KFNl9Gg=; b=Ied+QNNTXHYRUsekQ8v7GbsZgs0SirYmqhN3A+tmWF+apPjV4wU7Wa+Zjc+kCUCDXj 0eicQSkZDfQByh+qfwKhuz98B8gb3OEzuP+7/Uv5jc3XZqCh/8jroWTAs1VbtC+YExXv 7AzQTOvtY2Yr/+BXwoBi9nY9SqGaQPNb/f42Y667Gb+ueKy042J1MOEw/XFsJuYz4RSq V0fMLwQpxnJd3KWB6odH3EDoFZ5+Re6xM6/1vrs/RwwPLodjlt24rcaoy3JI07NK9d3s ge25IQp9dMSg1On2E9hhqfg5Xaq7ED3xWH2x73+o5aX0d4r6hvpK1sYBx1mrD6jaA7ek vvUw== X-Gm-Message-State: AOJu0Yy7OypWOCGTz3I5dbKWNW5IL4Rf03kvrgJELedC33wLl/2eCNnX 9H2NSbpv14fu2KBX46xoPU0NgIJTI9QApgPzXsH+4hUBwva/PLPNvPcuoHEq X-Google-Smtp-Source: AGHT+IF6MO40Zoi0DghBmN1z1+kWFtnnLF/4LvOuCEpP3RqzfSTwFOUuWu5quacXKem3YI+YiwwNAQ== X-Received: by 2002:a05:6870:610f:b0:21e:7a1d:b783 with SMTP id s15-20020a056870610f00b0021e7a1db783mr11664412oae.33.1708468924007; Tue, 20 Feb 2024 14:42:04 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id nd15-20020a056871440f00b0021a1492f000sm2056403oab.38.2024.02.20.14.42.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 14:42:03 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 2/7] qmi: Introduce qmi_device_new_qmux Date: Tue, 20 Feb 2024 16:40:55 -0600 Message-ID: <20240220224115.1254853-2-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240220224115.1254853-1-denkenz@gmail.com> References: <20240220224115.1254853-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In preparation for QRTR support, remove the existing qmi_device_new API and rename it to qmi_device_new_qmux. Since QMUX usually runs on top of a character device, have the constructor take in the character device path, instead of having the caller open it manually. As part of this refactoring, introduce the initial qmi_device_ops structure which will be used to abstract qmi operation over QMUX and QRTR. --- drivers/qmimodem/qmi.c | 70 ++++++++++++++++++++++++++++++++---------- drivers/qmimodem/qmi.h | 4 +-- plugins/gobi.c | 11 +------ 3 files changed, 57 insertions(+), 28 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index ee51a7db2368..89e1f8f40381 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -34,6 +34,7 @@ #include #include +#include #include @@ -54,6 +55,10 @@ struct qmi_version { const char *name; }; +struct qmi_device_ops { + void (*destroy)(struct qmi_device *device); +}; + struct qmi_device { int ref_count; int fd; @@ -80,10 +85,15 @@ struct qmi_device { void *shutdown_user_data; qmi_destroy_func_t shutdown_destroy; guint shutdown_source; + const struct qmi_device_ops *ops; bool shutting_down : 1; bool destroyed : 1; }; +struct qmi_device_qmux { + struct qmi_device super; +}; + struct qmi_service { int ref_count; struct qmi_device *device; @@ -949,15 +959,11 @@ static void service_destroy(gpointer data) service->device = NULL; } -struct qmi_device *qmi_device_new(int fd) +static int qmi_device_init(struct qmi_device *device, int fd, + const struct qmi_device_ops *ops) { - struct qmi_device *device; long flags; - device = g_try_new0(struct qmi_device, 1); - if (!device) - return NULL; - __debug_device(device, "device %p new", device); device->ref_count = 1; @@ -966,16 +972,14 @@ struct qmi_device *qmi_device_new(int fd) device->close_on_unref = false; flags = fcntl(device->fd, F_GETFL, NULL); - if (flags < 0) { - g_free(device); - return NULL; - } + if (flags < 0) + return -EIO; if (!(flags & O_NONBLOCK)) { - if (fcntl(device->fd, F_SETFL, flags | O_NONBLOCK) < 0) { - g_free(device); - return NULL; - } + int r = fcntl(device->fd, F_SETFL, flags | O_NONBLOCK); + + if (r < 0) + return -errno; } device->io = g_io_channel_unix_new(device->fd); @@ -1000,7 +1004,9 @@ struct qmi_device *qmi_device_new(int fd) device->next_control_tid = 1; device->next_service_tid = 256; - return device; + device->ops = ops; + + return 0; } struct qmi_device *qmi_device_ref(struct qmi_device *device) @@ -1055,7 +1061,7 @@ void qmi_device_unref(struct qmi_device *device) if (device->shutting_down) device->destroyed = true; else - g_free(device); + device->ops->destroy(device); } void qmi_device_set_debug(struct qmi_device *device, @@ -1646,6 +1652,38 @@ done: return res; } +static void qmi_device_qmux_destroy(struct qmi_device *device) +{ + struct qmi_device_qmux *qmux = + l_container_of(device, struct qmi_device_qmux, super); + + l_free(qmux); +} + +static const struct qmi_device_ops qmux_ops = { + .destroy = qmi_device_qmux_destroy, +}; + +struct qmi_device *qmi_device_new_qmux(const char *device) +{ + struct qmi_device_qmux *qmux; + int fd; + + fd = open(device, O_RDWR | O_NONBLOCK | O_CLOEXEC); + if (fd < 0) + return NULL; + + qmux = l_new(struct qmi_device_qmux, 1); + + if (qmi_device_init(&qmux->super, fd, &qmux_ops) < 0) { + close(fd); + l_free(qmux); + return NULL; + } + + return &qmux->super; +} + struct qmi_param *qmi_param_new(void) { struct qmi_param *param; diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index fc2a309578c4..410ada04d8d7 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -81,8 +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_new(int fd); - struct qmi_device *qmi_device_ref(struct qmi_device *device); void qmi_device_unref(struct qmi_device *device); @@ -105,6 +103,8 @@ enum qmi_device_expected_data_format qmi_device_get_expected_data_format( bool qmi_device_set_expected_data_format(struct qmi_device *device, enum qmi_device_expected_data_format format); +struct qmi_device *qmi_device_new_qmux(const char *device); + struct qmi_param; struct qmi_param *qmi_param_new(void); diff --git a/plugins/gobi.c b/plugins/gobi.c index 020d6ba2685e..07994666ded5 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -423,7 +423,6 @@ static int gobi_enable(struct ofono_modem *modem) { struct gobi_data *data = ofono_modem_get_data(modem); const char *device; - int fd; DBG("%p", modem); @@ -431,15 +430,7 @@ static int gobi_enable(struct ofono_modem *modem) if (!device) return -EINVAL; - fd = open(device, O_RDWR | O_NONBLOCK | O_CLOEXEC); - if (fd < 0) - return -EIO; - - data->device = qmi_device_new(fd); - if (!data->device) { - close(fd); - return -ENOMEM; - } + data->device = qmi_device_new_qmux(device); if (getenv("OFONO_QMI_DEBUG")) qmi_device_set_debug(data->device, gobi_debug, "QMI: "); From patchwork Tue Feb 20 22:40:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13564647 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 E397A153BE6 for ; Tue, 20 Feb 2024 22:42:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468927; cv=none; b=e2WB6Sqr1z9k8riYzpV2qf8s7kaPwRgZZH7OygNDQSVEqK73gX7Bq2mSZNpsk4GX33AZh+mdWzlb1sC1iJwtbAyoUzTfVNll65hI6bu7/VKFs9Q4KddvxAPBK+ZX+IB+32T6jIcQSRBzxHirvuxJhYZi769mB/XjSyI/nIIalfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468927; c=relaxed/simple; bh=qvDZmHmEZTId2QSMfa1f9fQMjNM1/rS6esU64eFhnzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ht+bwmkxEkfVRk7D7kdA7Emm7JPfUgpbeVTzUawVoKvKwti6gqZIfhqXQhYKeqWsBO8/mGEIPzTlugdKHfOZfubclm6MpzQ8MtaemK3sgXyOrQUBOmj/sXaAOuVmHVus1P43BX7Enz390Py5Z5+0YCPI/CpRxxSwhY3yuPLmoBA= 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=AkzjLiVK; arc=none smtp.client-ip=209.85.210.50 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="AkzjLiVK" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6e28bd74883so3387878a34.1 for ; Tue, 20 Feb 2024 14:42:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708468925; x=1709073725; 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=cDfOnIP1F+LKQjT2c7FZmbYnZMm10x7fHbhEec8jENY=; b=AkzjLiVKNgLQcI4ZJLO+IMKhIvCxIfDOgQWME7Mlut3g6KIN6uWbsqRi3+WfF1o8js zVyKdLxmJIxiImhBu4lbrSxvl6NCrKSq7Eozl51r33NYYL78sbJ1tL3YIJl6s5EowjGP 6FnBDI54N0bWDOZW2RNuLds2uXaM4lYODdP2GSzL5Tw6G9t2XLUBqLmwXfVGRkSKTz5R +5AEDFRC2xZbXMo/l1uXkBS9rfv434jhxvAivjvixhUwCnsJ1eX5NTRYiMAL2N8movcL cUyLNfJPMgdn/VXrNp+lk9LBxiy++gbxQWrSU7gh/V1e8e2DEkcD610730J/mZ848Byc Odpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708468925; x=1709073725; 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=cDfOnIP1F+LKQjT2c7FZmbYnZMm10x7fHbhEec8jENY=; b=gLQjskTLnuIihwCCfnX1GNvWQ9kn3K2hY2Ton2rIzLP1exsTUUsV28U3kd7CbNBzsj bDj40Nk85wnxvQ2FyhLzPDPsaKIiLxL2hHpeOvJYBqPJgQllF159AZPKnq0fpS9hWDIt B+Bv7Sz0japEkE+mjTG8riqRobYL1qvjd/J5JIyB0v8u2KXUJOMPR0eVi39uoOKILku+ u5zYuNh6FriPEhZgqz794qwWf0NwnEcnPsh6kZilWAZkR6g7ol33/huSLTHk+wacnvCs gasAV0W4G1AYaFYMylAeDQ404pOkgvONS6bvC+SYgMwAquMEgaNxasqrBNSeEswSaEf/ ShRA== X-Gm-Message-State: AOJu0YzDG7fV2g0swf+W0B6JhFrVUryR7M0YM2swCzTaEZoM9XxsDpFC rvUUYbsD0fS70WIELVCaTwV4skJjq1Mu4KKMGs5AeD0e/AUzJsCIKKJnhQqE X-Google-Smtp-Source: AGHT+IFRfAcZJUOCiP0h6KtPJH1qzJVxVUiluSkpialj+yHq8Sk3RrqOwUwHQ0dYfuVCmReaqTwL4g== X-Received: by 2002:a05:6871:73aa:b0:21e:74d8:8f49 with SMTP id na42-20020a05687173aa00b0021e74d88f49mr5233505oac.24.1708468924790; Tue, 20 Feb 2024 14:42:04 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id nd15-20020a056871440f00b0021a1492f000sm2056403oab.38.2024.02.20.14.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 14:42:04 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 3/7] qmi: Remove qmi_device_set_close_on_unref Date: Tue, 20 Feb 2024 16:40:56 -0600 Message-ID: <20240220224115.1254853-3-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240220224115.1254853-1-denkenz@gmail.com> References: <20240220224115.1254853-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The only caller of this method always sets close_on_unref to true. Since the underlying file descriptor is no longer exposed, it is safe to remove this method and assume that the file descriptor should always be closed when qmi_device is cleaned up. --- drivers/qmimodem/qmi.c | 13 +------------ drivers/qmimodem/qmi.h | 2 -- plugins/gobi.c | 2 -- 3 files changed, 1 insertion(+), 16 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 89e1f8f40381..8de5170674f8 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -63,7 +63,6 @@ struct qmi_device { int ref_count; int fd; GIOChannel *io; - bool close_on_unref; guint read_watch; guint write_watch; GQueue *req_queue; @@ -969,7 +968,6 @@ static int qmi_device_init(struct qmi_device *device, int fd, device->ref_count = 1; device->fd = fd; - device->close_on_unref = false; flags = fcntl(device->fd, F_GETFL, NULL); if (flags < 0) @@ -1047,8 +1045,7 @@ void qmi_device_unref(struct qmi_device *device) if (device->read_watch > 0) g_source_remove(device->read_watch); - if (device->close_on_unref) - close(device->fd); + close(device->fd); if (device->shutdown_source) g_source_remove(device->shutdown_source); @@ -1074,14 +1071,6 @@ void qmi_device_set_debug(struct qmi_device *device, device->debug_data = user_data; } -void qmi_device_set_close_on_unref(struct qmi_device *device, bool do_close) -{ - if (!device) - return; - - device->close_on_unref = do_close; -} - void qmi_result_print_tlvs(struct qmi_result *result) { const void *ptr = result->data; diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index 410ada04d8d7..ab0ee479c89d 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -87,8 +87,6 @@ void qmi_device_unref(struct qmi_device *device); void qmi_device_set_debug(struct qmi_device *device, qmi_debug_func_t func, void *user_data); -void qmi_device_set_close_on_unref(struct qmi_device *device, bool do_close); - bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, void *user_data, qmi_destroy_func_t destroy); bool qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, diff --git a/plugins/gobi.c b/plugins/gobi.c index 07994666ded5..e22b8146cf93 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -435,8 +435,6 @@ static int gobi_enable(struct ofono_modem *modem) if (getenv("OFONO_QMI_DEBUG")) qmi_device_set_debug(data->device, gobi_debug, "QMI: "); - qmi_device_set_close_on_unref(data->device, true); - qmi_device_discover(data->device, discover_cb, modem, NULL); return -EINPROGRESS; From patchwork Tue Feb 20 22:40:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13564648 Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 6CA1B1468E0 for ; Tue, 20 Feb 2024 22:42:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468927; cv=none; b=GIVpdW3hbwKcvwbt1OMnhS2RNZyD/uFIBbcOM0LSa1qetb+gcOLf9eRgl3v4l70W02iq2Qb7hs7iNYrx3vl+uPQarxDJUxmqxxGqtIg106Sm5CzZID8bp1hLs+yb9ntbYOEwyX72tkEYPZSPMtZTlLtSTbBDVGJpZrMOSD2nkxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468927; c=relaxed/simple; bh=OEU1xpqThKW8XFaZn/NSxip7qRGfJFeG8AMs+fzGvGA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FjwrF5nfdRfZXuzADXro22yaPpjiRK0HQ9iEhLZLZ8Gbxtivekr7OcvgoGGAenjUV162cVnKmZtEyhLJRA8DiCq682wINfAhtPKbACs48CfkddiC8aHzLOR6/rFcHoTiSgaYvrU0X/pY3yGNX+uWSXKrZGcVsMdEnlcsttMOKrQ= 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=VTy3NtV+; arc=none smtp.client-ip=209.85.160.43 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="VTy3NtV+" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-21e2673a206so3863831fac.2 for ; Tue, 20 Feb 2024 14:42:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708468925; x=1709073725; 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=GT2n1ZhFZMKX4SFCmBfRS0JOvgzdVRGbzfbOfsTlYBU=; b=VTy3NtV+Txx1NDZ2nRK7OdAUxM0asU0k/q1Eo8QMfkKQcE4xYIf+Z7MswLT4eb3GRJ 8lwhaaflC2WBUYzyWB/H29A3HT/lZ6lanpVGkqb2nccC3DIdW2iidbC16Sob5jj3DsVp KTgh9pniwYnoZw/3e5hfBKIRMCC2oH8ZEcB52Tvue4sVu1R+vABuhZvScMNPQjUNsHxF WZbaCi12QQnvBquad+1pwLP9yO1D3MgZV8p8YO1vWQA1tW4g92t6KxV76TGisoG0pOxV D1K5C0/5Tm8VFyZPb4HMY1+pCbjLyWlBfkPR8ow6Y56jegnqPqDRLKiPEA2Wb7QLVn7e 2uXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708468925; x=1709073725; 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=GT2n1ZhFZMKX4SFCmBfRS0JOvgzdVRGbzfbOfsTlYBU=; b=iLA4lbbU1ksTAp68UoAK06AW/nQCR+8ql7s7lklTHPZdjIG7QA/Cd45amN64RO9ues yNIx7zSTPXg9yvu7181xVIWS/GJPQCo//hXkkKxN2Cw2xSbzgIwDIfMWzUvg9CGAb5jU tqagG0HjiXjLE6bqt2Bno1E6Zj7ZaOE44kem8Ewj4uNnRXizTXXpo5gIQnYTQOJliFqF reLIJbEVk1FLsOVBVsLw1D4db4dZdcgu4l6vwRbexry+NwbnabyzJ7xvJC0ru42RLnXv ApzRpWpvkW518CjKlloGzSWWVvU/dDcYNTSwsUjb/ERfW+C/n2fAefePiB0oFyqrroC+ FMqQ== X-Gm-Message-State: AOJu0YzeFqFc6EhSpZ3/JjM2vgXkBtb3rgdBE5z/AZ/WLKjoZhhgnY3Z 61D4OXZsHPvG5AJrcYQ/MRFzLWvTxmwbsEY5UqM6dFsUvs6Ee+Ah8wagXGGz X-Google-Smtp-Source: AGHT+IF5I3gTegCDWTUW+tziuaS+tbYz+Gch/GFAY8MLlCAd1n0r60kxnbk3RZrnpHDUZPlyA5enIQ== X-Received: by 2002:a05:6870:1613:b0:21e:b667:22 with SMTP id b19-20020a056870161300b0021eb6670022mr11023351oae.7.1708468925433; Tue, 20 Feb 2024 14:42:05 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id nd15-20020a056871440f00b0021a1492f000sm2056403oab.38.2024.02.20.14.42.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 14:42:05 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 4/7] qmi: Move control_{major|minor} to qmux sublcass Date: Tue, 20 Feb 2024 16:40:57 -0600 Message-ID: <20240220224115.1254853-4-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240220224115.1254853-1-denkenz@gmail.com> References: <20240220224115.1254853-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Move the following members to the qmux subclass: - control_major - control_minor --- drivers/qmimodem/qmi.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 8de5170674f8..dae540251118 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -73,8 +73,6 @@ struct qmi_device { uint16_t next_service_tid; qmi_debug_func_t debug_func; void *debug_data; - uint16_t control_major; - uint16_t control_minor; char *version_str; struct qmi_version *version_list; uint8_t version_count; @@ -91,6 +89,8 @@ struct qmi_device { struct qmi_device_qmux { struct qmi_device super; + uint16_t control_major; + uint16_t control_minor; }; struct qmi_service { @@ -1205,6 +1205,8 @@ static void discover_callback(uint16_t message, uint16_t length, { struct discover_data *data = user_data; struct qmi_device *device = data->device; + struct qmi_device_qmux *qmux = + l_container_of(device, struct qmi_device_qmux, super); const struct qmi_result_code *result_code; const struct qmi_service_list *service_list; const void *ptr; @@ -1250,8 +1252,8 @@ static void discover_callback(uint16_t message, uint16_t length, type, major, minor); if (type == QMI_SERVICE_CONTROL) { - device->control_major = major; - device->control_minor = minor; + qmux->control_major = major; + qmux->control_minor = minor; continue; } @@ -1274,8 +1276,8 @@ done: device->version_count = count; /* if the device support the QMI call SYNC over the CTL interface */ - if ((device->control_major == 1 && device->control_minor >= 5) || - device->control_major > 1) { + if ((qmux->control_major == 1 && qmux->control_minor >= 5) || + qmux->control_major > 1) { qmi_device_sync(data->device, data); return; } From patchwork Tue Feb 20 22:40:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13564649 Received: from mail-oa1-f46.google.com (mail-oa1-f46.google.com [209.85.160.46]) (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 2666D153BDD for ; Tue, 20 Feb 2024 22:42:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468928; cv=none; b=N8kaRTIhcKCxcMgk4K4kOlZvkYDgnw8QF3aWy/Av4BhmyGDgcsToJmKlQDDPYJeQ+AxPvdmQ3EsMmq76X33Ngh+FDRQeTo40iY5wJwU1rD64nt6AI1diEG79u5QXVPk1hydkxBrthZDiiYroknDVlnbz2MVl1fswt/XPcUosFt4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468928; c=relaxed/simple; bh=RhBSKqRpApsLQHZ6P7+QG1Mtrv6i+R3BQoONgBjCrLY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IIXPcpOHOJbhLtJtTMNb+iqk24NRBqo2wBy80RWYfDlW1ie25US2XIT1gJS+wyxN2cWbk6bzpFtoeeyEBeSbP8MV1Wpvkubt8XVhtqYLdWyrC3z97tCwpRm6etTM8apHInY+KgbICEK9N+6MnuLjeXZxcpcKYk7MIAvN91n6s4U= 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=ixEz17hx; arc=none smtp.client-ip=209.85.160.46 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="ixEz17hx" Received: by mail-oa1-f46.google.com with SMTP id 586e51a60fabf-204235d0913so3759479fac.1 for ; Tue, 20 Feb 2024 14:42:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708468926; x=1709073726; 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=Lf1gjBRkNUxU/zigl7LWX0W3eEotXOcrDqDM7grgO0s=; b=ixEz17hxnHbqvYWqQ5fzy9PZQDHmjHEZklDth7/tqIr+1nZxUjkaSzSI30Krw5x4R4 EIP9h3yW8tq+gWxG2wTNtnGxxSvITIJ+rD2i62TWlp5SflknND92a5QQBxjykBU+7oNj X3gPs/3GRQZkTvd8mssdggLIxW1ZO7jiYJfFAFhoHZiEcyTfq2bMh5Fcyl3SWCvWuxHg TIFkNa8Y1VWb8/0u9a675y0bnCDMvoAT0i/3TKbF4JsrMjgxejGoURMYolhqL8jRVNv5 d/jIBJLeOYf7f6lvX7NOQhutNm8zNw+qps2q+XHooGCRdPl8rbFoPXp2BhiYUvo8zSNK 8+PQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708468926; x=1709073726; 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=Lf1gjBRkNUxU/zigl7LWX0W3eEotXOcrDqDM7grgO0s=; b=t0RVBDwczjj1En+W2pSCvn6bOXtbh/yQu6PI7lTphHienio9tmrP8yNiLbREFKd3y0 9maSx4LwlO89nxd6TrqTqJcbHjbF1f+TQQA+fcg7Qi5ixMtN9oSO2ks4dI35hIIVVh64 qWwWuxB5iQadfvxC0wMy5GzIvbn308n2Dmet/sJJ2pJ/tbZsVxpb3xcjUV6TW5W0H49q LvVF+l8JpMm117sWB6ap/U/POgmOlKuIZWMIq1tKWAKMPi95MfnYufhA8Hdz/iH7PuKK 6rw7EfZyVctq4dHhXgM92L5septOVIiOs8DXrqyoFj/A0Qe8AGFWBC9h/P2Py0Xm58Q9 TMhQ== X-Gm-Message-State: AOJu0Yyav9R93/VWlWMM8Tihd5BxnAVLLpP81KLDvIsYxkmRhk3pFjcY FmfNHV8RhwQHxe971dXmjH6mlXqjcS43Uxff+7PvHoMIMER/3U7Z9tq8PNen X-Google-Smtp-Source: AGHT+IF//ByJGGZelJrAobijFObGC9W+g24LzAXAYzn4L65MxcbzG+IA5zv4nWTWO5d5ySoi8+fKZQ== X-Received: by 2002:a05:6870:1581:b0:21e:bb30:e2b7 with SMTP id j1-20020a056870158100b0021ebb30e2b7mr9685658oab.50.1708468926122; Tue, 20 Feb 2024 14:42:06 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id nd15-20020a056871440f00b0021a1492f000sm2056403oab.38.2024.02.20.14.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 14:42:05 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 5/7] qmi: Move version_str to qmux subclass Date: Tue, 20 Feb 2024 16:40:58 -0600 Message-ID: <20240220224115.1254853-5-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240220224115.1254853-1-denkenz@gmail.com> References: <20240220224115.1254853-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The version_str member is only available on QMUX based devices, and only on certain ones. Move this member out to the qmux subclass and add a debug statement to print it out if available. --- drivers/qmimodem/qmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index dae540251118..47a9bbe2cb59 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -73,7 +73,6 @@ struct qmi_device { uint16_t next_service_tid; qmi_debug_func_t debug_func; void *debug_data; - char *version_str; struct qmi_version *version_list; uint8_t version_count; GHashTable *service_list; @@ -91,6 +90,7 @@ struct qmi_device_qmux { struct qmi_device super; uint16_t control_major; uint16_t control_minor; + char *version_str; }; struct qmi_service { @@ -1052,7 +1052,6 @@ void qmi_device_unref(struct qmi_device *device) g_hash_table_destroy(device->service_list); - g_free(device->version_str); g_free(device->version_list); if (device->shutting_down) @@ -1269,7 +1268,8 @@ static void discover_callback(uint16_t message, uint16_t length, if (!ptr) goto done; - device->version_str = strndup(ptr + 1, *((uint8_t *) ptr)); + qmux->version_str = l_strndup(ptr + 1, *((uint8_t *) ptr)); + __debug_device(device, "version string: %s", qmux->version_str); done: device->version_list = list; @@ -1648,6 +1648,7 @@ static void qmi_device_qmux_destroy(struct qmi_device *device) struct qmi_device_qmux *qmux = l_container_of(device, struct qmi_device_qmux, super); + l_free(qmux->version_str); l_free(qmux); } From patchwork Tue Feb 20 22:40:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13564650 Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) (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 D5069153BE6 for ; Tue, 20 Feb 2024 22:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468929; cv=none; b=Ov7KXdDeMItxeB+Y1H0/Erwl0P7fTMbEprYODByrR8txMnbwwBXgO+GXYAdoyKqH3qdoSJlBrQOjsBongL7UIsAauXZGDzTSFpiuPAM1T2rnBCnpXLuc3pZ18rtJy1BcyesEsRs33dv7hLxz7uOnfhjVvqoQdtFKJLdHOo0Z41g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468929; c=relaxed/simple; bh=ZZMFeD43R8zS9wJOxatOE+EHxypzPPbZFQ5e61+ytA4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OOzU+Tv0FocrEIsLs7ymIv6nEJJslb9+90Ro5iOFjXT+1J94dE7AVW+LhTrrCLvod7H1+1QTAq7K6VeG3VpNy/eOixx1q9AJAixG3Xv3WxgFz+kceapiMhANxVuMByGyY95Vo1YS+79qbyDlhdbSAb2i6sXQKpSD/UPVuPt+w4U= 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=MfQwGAFO; arc=none smtp.client-ip=209.85.161.54 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="MfQwGAFO" Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-59d78deb469so3792389eaf.1 for ; Tue, 20 Feb 2024 14:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708468927; x=1709073727; 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=qkdkGos4yPBFYAElfKIcxQB5NBFE1tbEEdtjMzwjAKo=; b=MfQwGAFOCRUP0MbWFaZ0Na6JmcXEMIhLTwGIKKUfaigI3EPelwdYOzp7XncCfLNphN 0r3zmwLH7kdi/YYovxe8yZ23eAxyVd33MS500Aug4EiILhOSD477EZjl2hCjwq2dngvk IKQWedOb2pwPcSIPLcWG6JSK+mpBjMJ7J3E6RTIyVAOEUovrPi8ld4UfP7Lut9WpYB98 WB4arrMHu0Kwkue0i1KiVJVzmkxCKYwPfuWCkV9G6Bl4XjBajuafP1Filio4HkI4XSIS wq/6LYfrk2cnBZ8UoTa347K1IWozy2C31LWbcuwZ7CteimPGJsATuQHDKaPNnCUg7s0D ortQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708468927; x=1709073727; 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=qkdkGos4yPBFYAElfKIcxQB5NBFE1tbEEdtjMzwjAKo=; b=N1zYM7Lu00kqCPgU+gieGIirhoJHq9HQDxBMhmQH4qfTZI3Somd6OvX6WpE1KAd5sv uAD55i7NhE0lnhm4uLzj9lYUgCEGU87ow9us2ILO2rtaFDBBDVGkZJh5zJseWx83VNVC y4DdMc+8JObeh+qLeyf/CmjFC7hqhJRmJZnqHOML2A2J16RVGdYG+F89k+4UZlvPK6Uk DzmfMKQfY7hNMviroxlBOB/P/9UUi5dEBopOm5mqnziSwOnF6d/NMmJ31GDDQMKd3MpV /0i4yg4gVWe5uB3ooJSTsNuZofQ1v8o7jCG/P/ZujQwLlFXZo+srxlXricm0gsa0CQQ+ JugA== X-Gm-Message-State: AOJu0YxaAPR4g67Nf8i+8+hNuCjB+YV+enfOA4+GwllAEAkD7cGisFt1 8fbXDSm9yPjIepLBqINlLWrpvHuQHnbbVcijV7e1IGXfEbo89WLCyZ7R4nDm X-Google-Smtp-Source: AGHT+IG/sloZInGxcimUYVZGy8AeZykVRPVN7D5c6fTLtGoOr7aEo9korNqIzcV35D6564CHmgvMGw== X-Received: by 2002:a05:6871:58a4:b0:21e:9eac:b0ae with SMTP id ok36-20020a05687158a400b0021e9eacb0aemr9288135oac.40.1708468926835; Tue, 20 Feb 2024 14:42:06 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id nd15-20020a056871440f00b0021a1492f000sm2056403oab.38.2024.02.20.14.42.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 14:42:06 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 6/7] qmi: Introduce shutdown operation Date: Tue, 20 Feb 2024 16:40:59 -0600 Message-ID: <20240220224115.1254853-6-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240220224115.1254853-1-denkenz@gmail.com> References: <20240220224115.1254853-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 the shutdown operation waits for all low-level service handles to be released, then calls the shutdown callback / destroy functions. Low level service handles on QMUX protocol are released via qmi_service_unref, which in turn sends a QMUX control message. On the other hand, in QRTR, there is no need to explicitly release handles. They are released automatically when the underlying QRTR socket is closed. Abstract the shutdown operation behind a shutdown method in the ops structure, and move the QMUX specific implementation there. While here, change the return signature of qmi_device_shutdown to return an int, such that better error reporting can be supported. For example, QRTR might choose not to implement the shutdown method entirely, in which case an -EOPNOTSUP will be returned. --- drivers/qmimodem/qmi.c | 129 ++++++++++++++++++++++++----------------- drivers/qmimodem/qmi.h | 2 +- 2 files changed, 77 insertions(+), 54 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 47a9bbe2cb59..5543df027c15 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -56,6 +56,9 @@ struct qmi_version { }; struct qmi_device_ops { + int (*shutdown)(struct qmi_device *device, + qmi_shutdown_func_t shutdown_func, + void *user, qmi_destroy_func_t destroy); void (*destroy)(struct qmi_device *device); }; @@ -77,10 +80,6 @@ struct qmi_device { uint8_t version_count; GHashTable *service_list; unsigned int release_users; - qmi_shutdown_func_t shutdown_func; - void *shutdown_user_data; - qmi_destroy_func_t shutdown_destroy; - guint shutdown_source; const struct qmi_device_ops *ops; bool shutting_down : 1; bool destroyed : 1; @@ -91,6 +90,10 @@ struct qmi_device_qmux { uint16_t control_major; uint16_t control_minor; char *version_str; + qmi_shutdown_func_t shutdown_func; + void *shutdown_user_data; + qmi_destroy_func_t shutdown_destroy; + guint shutdown_source; }; struct qmi_service { @@ -1017,6 +1020,12 @@ struct qmi_device *qmi_device_ref(struct qmi_device *device) return device; } +static void __qmi_device_shutdown_finished(struct qmi_device *device) +{ + if (device->destroyed) + device->ops->destroy(device); +} + void qmi_device_unref(struct qmi_device *device) { if (!device) @@ -1047,9 +1056,6 @@ void qmi_device_unref(struct qmi_device *device) close(device->fd); - if (device->shutdown_source) - g_source_remove(device->shutdown_source); - g_hash_table_destroy(device->service_list); g_free(device->version_list); @@ -1393,58 +1399,16 @@ static void release_client(struct qmi_device *device, __request_submit(device, req); } -static void shutdown_destroy(gpointer user_data) -{ - struct qmi_device *device = user_data; - - if (device->shutdown_destroy) - device->shutdown_destroy(device->shutdown_user_data); - - device->shutdown_source = 0; - - if (device->destroyed) - g_free(device); -} - -static gboolean shutdown_callback(gpointer user_data) -{ - struct qmi_device *device = user_data; - - if (device->release_users > 0) - return TRUE; - - device->shutting_down = true; - - if (device->shutdown_func) - device->shutdown_func(device->shutdown_user_data); - - device->shutting_down = true; - - return FALSE; -} - -bool qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, +int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, void *user_data, qmi_destroy_func_t destroy) { if (!device) return false; - if (device->shutdown_source > 0) - return false; - - __debug_device(device, "device %p shutdown", device); - - device->shutdown_source = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, - 0, shutdown_callback, device, - shutdown_destroy); - if (device->shutdown_source == 0) - return false; + if (!device->ops->shutdown) + return -ENOTSUP; - device->shutdown_func = func; - device->shutdown_user_data = user_data; - device->shutdown_destroy = destroy; - - return true; + return device->ops->shutdown(device, func, user_data, destroy); } static bool get_device_file_name(struct qmi_device *device, @@ -1643,16 +1607,75 @@ done: return res; } +static void qmux_shutdown_destroy(gpointer user_data) +{ + struct qmi_device_qmux *qmux = user_data; + + if (qmux->shutdown_destroy) + qmux->shutdown_destroy(qmux->shutdown_user_data); + + qmux->shutdown_source = 0; + + __qmi_device_shutdown_finished(&qmux->super); +} + +static gboolean qmux_shutdown_callback(gpointer user_data) +{ + struct qmi_device_qmux *qmux = user_data; + + if (qmux->super.release_users > 0) + return TRUE; + + qmux->super.shutting_down = true; + + if (qmux->shutdown_func) + qmux->shutdown_func(qmux->shutdown_user_data); + + qmux->super.shutting_down = false; + + return FALSE; +} + +static int qmi_device_qmux_shutdown(struct qmi_device *device, + qmi_shutdown_func_t func, + void *user_data, + qmi_destroy_func_t destroy) +{ + struct qmi_device_qmux *qmux = + l_container_of(device, struct qmi_device_qmux, super); + + if (qmux->shutdown_source > 0) + return -EALREADY; + + __debug_device(&qmux->super, "device %p shutdown", &qmux->super); + + qmux->shutdown_source = g_timeout_add_seconds_full(G_PRIORITY_DEFAULT, + 0, qmux_shutdown_callback, + qmux, qmux_shutdown_destroy); + if (qmux->shutdown_source == 0) + return -EIO; + + qmux->shutdown_func = func; + qmux->shutdown_user_data = user_data; + qmux->shutdown_destroy = destroy; + + return 0; +} + static void qmi_device_qmux_destroy(struct qmi_device *device) { struct qmi_device_qmux *qmux = l_container_of(device, struct qmi_device_qmux, super); + if (qmux->shutdown_source) + g_source_remove(qmux->shutdown_source); + l_free(qmux->version_str); l_free(qmux); } static const struct qmi_device_ops qmux_ops = { + .shutdown = qmi_device_qmux_shutdown, .destroy = qmi_device_qmux_destroy, }; diff --git a/drivers/qmimodem/qmi.h b/drivers/qmimodem/qmi.h index ab0ee479c89d..df4bc39644a2 100644 --- a/drivers/qmimodem/qmi.h +++ b/drivers/qmimodem/qmi.h @@ -89,7 +89,7 @@ void qmi_device_set_debug(struct qmi_device *device, bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, void *user_data, qmi_destroy_func_t destroy); -bool qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, +int qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func, void *user_data, qmi_destroy_func_t destroy); bool qmi_device_has_service(struct qmi_device *device, uint16_t type); From patchwork Tue Feb 20 22:41:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13564651 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) (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 9A16E1468E0 for ; Tue, 20 Feb 2024 22:42:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468931; cv=none; b=ostLN5vUUjduFdJYysLU9vMUWF0w9U23C9j5suV9EsEJdJ2/bC0qXZmLeO/pC2vR74Tx5F3LNzUVRuWPMj1UjWDvuS5DbwJBMQI0njZCTK2rmX3bPDxEAB8tGVmNXED1L+Gu/UblMWNCr/MVRPOEqgx2ltNQyHmRdvVPV/dR79Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708468931; c=relaxed/simple; bh=i7tvfcKFmnVh78d8KtLw3QfEElFRS6FPwMN02y3MjuY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aG90GdvoCtFdRDEKvebPHlMdV6cSsNNdDHGUuV3qACjyogi1bFBD00djle8YPbilobRcqmcaI3s/ovrVlb2Y6ynCvDJRDA/rNJ3QbWN6N+z5Af60IA8DX7OsVlsecyYtyrMBUf0Wcg0ShjleTA597JEZNmAX0Fzdgdmv6aa7UC4= 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=X7EcITkd; arc=none smtp.client-ip=209.85.167.177 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="X7EcITkd" Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3bbbc6bcc78so4489550b6e.1 for ; Tue, 20 Feb 2024 14:42:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708468927; x=1709073727; 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=GUxnPqn+84Zt1123ccdhiKW5ymXzGKm/tisgzCQrOLY=; b=X7EcITkd4sgszfoXdrwFhGS79U7qutlr3qXgJlR1+esLPjc3oAxtkApC0JmafehANG 8VZkhXff0vkg8HENllVY4uAeCA1fBoOqpc82Yh+nOuJWvjOl6iUp2Jn2AKqXWombfIIi GHIPj7VUmNp8TvRb2d1cWNhtcB1WzwI+IqW8jdcsRECEObW5ZwOlOWJsT48yuBjICheq Xqr80f4S1jC+mpEqDnEflqQBmgxWkkGob0VG7ha3wmQ0xuaFKLHlSP+rSikrOBh3TPwN l0GUuHpf3rnrO4aJSkoO98DeMD7jKCwkvFdCSKKy3py3OHWtQv9o4NGkmIDg+mOA/tMe m4nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708468927; x=1709073727; 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=GUxnPqn+84Zt1123ccdhiKW5ymXzGKm/tisgzCQrOLY=; b=KYGtBYmhqO8/e9W+xSoLf6NmdVq876QiCYNeaX231q1oZ6zQbmQIgw7QqMufGEvWO7 VI2NH4zIsRQgOvU0hAFVHqpJowQkIrVkT+XRJtc8+6izJMOCmwjgQOz85hTMMtf05/YT KZJi5fYKylYpLIeJJDNO9KvtY7KXS94spQUJzZ4tbUiRmsUJfyMYB9+1+DI6F3ax6Tqq OO25iEAp1zCjGjY7IS0Urbw12GYle3iR8m7VkZYC/jzgh0lJl+WKzVByjcZ2AzB+4qmg sySH1EPaRu71nELjSz4I/wmD/qJz4p20lAyPe63Xc3AHQzWXGfynO09XpJbX9WPuThf8 RNJQ== X-Gm-Message-State: AOJu0YySB8wdafIJ99q5FxaBOkORXj/0ZXs9lzR5RxQ/v9wQ31RvCOfY U/QUDVjJTZHWoJRyNYGEhL8DbErzuLqkEpH+a8AN/NCd3/3kfdpg2iwKniu5 X-Google-Smtp-Source: AGHT+IE9wiHDTFcZ4kV3WWiZJGQk0MUhjTc3buxocRLBTNai2CGneNMEFI//NzQrN48+43k8Wr9B0w== X-Received: by 2002:a05:6871:58d:b0:21e:ac8c:d39e with SMTP id u13-20020a056871058d00b0021eac8cd39emr9433640oan.13.1708468927624; Tue, 20 Feb 2024 14:42:07 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id nd15-20020a056871440f00b0021a1492f000sm2056403oab.38.2024.02.20.14.42.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 14:42:07 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 7/7] gobi: Fail if device could not be created Date: Tue, 20 Feb 2024 16:41:00 -0600 Message-ID: <20240220224115.1254853-7-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240220224115.1254853-1-denkenz@gmail.com> References: <20240220224115.1254853-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If for some reason the qmux device creation fails, indicate failure early and do not rely on the 5 second modem powered timeout. --- plugins/gobi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/gobi.c b/plugins/gobi.c index e22b8146cf93..4134c62d398e 100644 --- a/plugins/gobi.c +++ b/plugins/gobi.c @@ -431,6 +431,8 @@ static int gobi_enable(struct ofono_modem *modem) return -EINVAL; data->device = qmi_device_new_qmux(device); + if (!data->device) + return -EIO; if (getenv("OFONO_QMI_DEBUG")) qmi_device_set_debug(data->device, gobi_debug, "QMI: ");