From patchwork Wed Feb 21 16:23:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13565923 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.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 785078173B for ; Wed, 21 Feb 2024 16:24:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532665; cv=none; b=Wx1mMSHV7fkv/Eh+/t8iOUKCJYsRI7oPce2bXHU7xO9GJnRqVebDIQQBuejes00P93LxRbeHkPk6IOwLSEIbyfmkw3scQZZsp8YecXRv57Sl/4raP/0Dnk5i+mrEzZKsmHlhJbmqHr5Cgga8LuAI0tl8ELA4WwXycmJpUcpJC9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532665; c=relaxed/simple; bh=kivg5ioRpPoB6Q3zwKIiGBmbtqRFbz7g2p7u/CR1BpY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RytHiMXuZ2hF/rTi+lVn5TQb+XWBxr9JMNNrY/z1Akd5OXX2mqST8BTjBLMfDIU+nomKzIHfwrCJm9UgImLSD/KSD5HMxweoD6+WgPHY7K02Zb6UE+yYrLF1HYg/LDNmMIX/BGrkgV73jJDF3X6JefiIBbk5tWgFIEKOafmBlHM= 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=P7ODQd9C; arc=none smtp.client-ip=209.85.161.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="P7ODQd9C" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-59caf51d4bcso1891662eaf.1 for ; Wed, 21 Feb 2024 08:24:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708532662; x=1709137462; 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=todh5DbDRtY6KXXkul1NOZ/bnm1sfdin6FSUpI43Feo=; b=P7ODQd9CjorLxyWucUIoUy08XoE+EmnxTDbioFiDsK/Rw10c75nDePUKLIZ/UXlNvH WLO7tXA/ZystTqv5Vs7kYLcKnSAz1gKyUdnwuLWHphArCxgd5GU0UjUxiZKvf9jeP9KC Jxfy1ZEtrg1XBClYHWx3t307tw/XhduSJbUAxZs8dxRrnHatjbe79pitipUv13zYg3W4 l+igss64LWPUOQ2DVZEyKdlmlKSxM/5JhgdfJ7uSVq4W4dJBoojK9cOPcMT8oaegSKLy jUw2GgyBTjpsCrlF449n7Fj2+6Fd22lV6EjFBe7BTV78xhw4b8pYZ2ldPOthZwDCgrpL VFCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708532662; x=1709137462; 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=todh5DbDRtY6KXXkul1NOZ/bnm1sfdin6FSUpI43Feo=; b=v9PWwqsvh5YpRu7Ig+4wclvRFUdj80dI4fdLtn8OUSnKBPva4uMTne1EbgnpazkeP4 EFVFJPIE59pj075KbAUrxra/sfWXrHpst+2W35V/vQuRJJ+zmVwAYF4TbSZPA3uMT1RM yFySn7Soed4Na4oHt/ZifA2N20yxvVOqOs/RXR9XGgWcZUsGy/uHHJYscKReMhd6cM8R NYJaPldTdTcHsouhzRqbvi9IdqVaQSJL+HAizViXYvanBd7PHoq44yi4Wy7+DcUO7/uj zeZGCyYOdzqICWJX7K0ua+5xk4SGFRbjgBBJ+9/Zl8HwSjNxQuXO/KIn4XkLyZ2wzgd5 XNmQ== X-Gm-Message-State: AOJu0Yx5DMenEBD/69yOglYXxzSGNBKLEFWmw9W5P4Cl8CVE+6JEPWhH 3h+e2c46Xd3PMivpym+X+DN1Y1H5+rLERkiMuLImk/tX2O405aeklL/TNulw X-Google-Smtp-Source: AGHT+IEjPEsP9dRBpu816M+nR3QNw9KT0qNR2G3OPO5i04COhN3kLB9MS7DTeLhhFmhKAL736xJQ6g== X-Received: by 2002:a4a:d2d3:0:b0:5a0:19e8:dd9e with SMTP id j19-20020a4ad2d3000000b005a019e8dd9emr729051oos.2.1708532662302; Wed, 21 Feb 2024 08:24:22 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j25-20020a4a92d9000000b00594ee4b4339sm1905405ooh.28.2024.02.21.08.24.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 08:24:22 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 1/7] qmi: Remove qmi_device_sync Date: Wed, 21 Feb 2024 10:23:14 -0600 Message-ID: <20240221162335.1258315-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 | 89 +++++++++++++++++------------------------- drivers/qmimodem/qmi.h | 5 --- plugins/gobi.c | 10 ++--- 3 files changed, 39 insertions(+), 65 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 30c396035593..768fcf12f1eb 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1038,7 +1038,6 @@ void qmi_result_print_tlvs(struct qmi_result *result) } } - static const void *tlv_get(const void *data, uint16_t size, uint8_t type, uint16_t *length) { @@ -1122,6 +1121,35 @@ static void discover_data_free(gpointer user_data) l_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) { @@ -1193,6 +1221,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); @@ -1352,58 +1387,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); - - l_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 = l_new(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 Wed Feb 21 16:23:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13565924 Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (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 34EDF3A1A2 for ; Wed, 21 Feb 2024 16:24:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532665; cv=none; b=VgHquHxQeiEtPISEuDPpxbQVm20UUcywrrlSivrD/EVMEBhc5lTDoe7AIbN0Z5XST0wYJf3PRDZV3keotmD99BU7WRWinknmUp3WMYRgCOp24DEGp65fqjEVPNz+x3Zv06xxkijgzcEnRNIlLtIPE3zkM129Q6Kb473rXyDEX1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532665; c=relaxed/simple; bh=nKbCdK/sLbcVYWBi2M5RIdupRi1WKxTke6PudO1NT3U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Eg0neFWvOhYpmfjJ42p0SUNCNjjzzvT5g8n3q5QJJS+Fnvu+Uxu/+QUovgw4Ls+C7CW6ZESnRv89p8myxrdhD8toWpqNbGzLwseilBhQvr72EjgJVBMjobfqNdXFNsWBwuHHpdY40ltsK3zg12SH4XJ/ij74mvKYZBCAuGyVp3k= 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=Uk6kjJW2; arc=none smtp.client-ip=209.85.167.178 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="Uk6kjJW2" Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3c15cbc6568so687326b6e.1 for ; Wed, 21 Feb 2024 08:24:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708532663; x=1709137463; 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=QOCHv5jYofHMeLmXNtBpYgUPZAL7CHr8cS7c8BpqDIU=; b=Uk6kjJW2+CCGE7RJq3LZXiDnvqmLN/bQLbi5rHyTu3sdu+wmOpVyXiN4/cfgJ4QVE3 2IVv1BcT+j7JVuPlWeh2ViE54qOYlR14ErBZT8T8PJeGpeP+T8JP6zft6eO70ZHHajYY HF47kFNDqu/5QHpFQBFp9oHpYOgF+HbwSKNQJdoSGVXBn26JqApIHePUI/IIRDJAbRP+ VYDskgpNF4aULUtveJ3ee5d7RTxllrx0X+GKrfde692T2By/9b/hX1NPj+T3Ncy8mcIh 3Cnq/NxbB+Y66INrSyQEDpZU3ccpGVnKs3udzrfazBCDWF4/t+GjUpcfX6kwprHm9LY+ QZSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708532663; x=1709137463; 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=QOCHv5jYofHMeLmXNtBpYgUPZAL7CHr8cS7c8BpqDIU=; b=wss2BPFKID+mPwjV4TpjD/bdxrG1X/KbN0exOj9m6XhvX76UKROpx0uvBlE0dC96dS jI9ozGHg8Uqw+o3bg8/3rKjq5De6jUanXAJ7OCdLBUHWyNfvynooduuOEP88a5j5ESLo p7nmpe7DAr/sncF0ewEzdTX5q0afzb/O/TJi/nY8dDqTJqk3/kOHr2ZKzoIg0mUdHUF4 4qDpQuIm8XAHxSIV9/a5OGtrm7CswovHbRlo9Gh31AwSb1sC2fxiJFQHmo7km9T+FVjJ HjC4UVmdBlc1Z/CF7521HinOfUGGwoxODd2pPLgZEicjFBSRZdnYdcvfBxaX8M2VqcXn goVA== X-Gm-Message-State: AOJu0YzubsqMTnJQ+1/+OV0t0ll0fBQ6JJNlrx16QA5jYSqXK3JCMSuk ZbUWjyipzc0k35TkJy2ohiXG+fJynSYKit9aVbPoI67LT/Z2bC2HbBERMcHr X-Google-Smtp-Source: AGHT+IGHZ1I5BxoBlzA+Q9NT0cuDX6BdWWDZE0wb8AV5ZAnmZk4QXPuJJEeUGG3MkY9G10zKctwkDw== X-Received: by 2002:a05:6808:495:b0:3bf:d9fd:d030 with SMTP id z21-20020a056808049500b003bfd9fdd030mr9563330oid.15.1708532662938; Wed, 21 Feb 2024 08:24:22 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j25-20020a4a92d9000000b00594ee4b4339sm1905405ooh.28.2024.02.21.08.24.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 08:24:22 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 2/7] qmi: Introduce qmi_device_new_qmux Date: Wed, 21 Feb 2024 10:23:15 -0600 Message-ID: <20240221162335.1258315-2-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221162335.1258315-1-denkenz@gmail.com> References: <20240221162335.1258315-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 | 67 +++++++++++++++++++++++++++++++++--------- drivers/qmimodem/qmi.h | 4 +-- plugins/gobi.c | 11 +------ 3 files changed, 56 insertions(+), 26 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 768fcf12f1eb..7bfb4bc0d74b 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -55,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; @@ -81,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; @@ -905,13 +914,11 @@ static void service_destroy(void *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 = l_new(struct qmi_device, 1); - __debug_device(device, "device %p new", device); device->ref_count = 1; @@ -920,16 +927,14 @@ struct qmi_device *qmi_device_new(int fd) device->close_on_unref = false; flags = fcntl(device->fd, F_GETFL, NULL); - if (flags < 0) { - l_free(device); - return NULL; - } + if (flags < 0) + return -EIO; if (!(flags & O_NONBLOCK)) { - if (fcntl(device->fd, F_SETFL, flags | O_NONBLOCK) < 0) { - l_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); @@ -953,7 +958,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) @@ -1001,7 +1008,7 @@ void qmi_device_unref(struct qmi_device *device) if (device->shutting_down) device->destroyed = true; else - l_free(device); + device->ops->destroy(device); } void qmi_device_set_debug(struct qmi_device *device, @@ -1583,6 +1590,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 Wed Feb 21 16:23:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13565925 Received: from mail-oo1-f42.google.com (mail-oo1-f42.google.com [209.85.161.42]) (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 035F881722 for ; Wed, 21 Feb 2024 16:24:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532666; cv=none; b=ggoBvZzIu0U4YY3s+FE8fRaRlHIyTQbzjjKZGaqXq/d1Cg8yXOrpoFgJXc9UABCPRIQrhPK1aplerMvt40ZRRtpsePzCjGHFJ33wCGIxh3uB3weqeL6eNncVlIFCIcJ7toYqZeuV0dLBwak+lnGE4Gfdaki93/pCYgwtZ3lO7jg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532666; c=relaxed/simple; bh=MBkliumkcgaCJjDou1BxR4NIIqfMuJQvc28YXNHyy+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kr6FLXCMyEWSvbSh0geqFDoahKS3sbboNxkCsA9zgbKVDXB8dX4KSktUpkNm5KEc8xYHVJ36Rqm/ntfpoyffwkbl3bZA2NmY28lthJyC/nGC0yZzHsDabtWqIY5BSt/monxDUas+oBdivAkKVHJ8S3lDIPr0W/6kvY0SGiaum9E= 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=TKM6nzJ9; arc=none smtp.client-ip=209.85.161.42 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="TKM6nzJ9" Received: by mail-oo1-f42.google.com with SMTP id 006d021491bc7-599f5e71d85so4278641eaf.3 for ; Wed, 21 Feb 2024 08:24:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708532664; x=1709137464; 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=Qfzu3QiTwEiyjKgpyR/+rDeqO020PiZW5paEtks8JqY=; b=TKM6nzJ9Hr1rYBuowMLXLpf3Qb/FJlWPtlKN15lgn5OiGOgd2HMSW3YUcNwkaULsJ5 SJFJUb4Oig6YbZ2k7cf9R5HevNhmJ0lnwTr1zImOvZ+DHxH9hz0oJXk1FO0TbZzIfkjf y/QGde3WyUuZL3hNntoLEaXHW+z14jHbZ6z9IvJaOSpWejBwnRwlbLvGW1NQIydHledp 7/9hAgExvrgkwcBVR7KXfCmZPuLngiLhTZTFIyxnr9rbU0MtjwdO8rsgzJGto+mJES5f b/QD2ouMSGqOud1zZv4fZhOw3jhdCs3rQWAfPRyYoZTMsfqWc+GkXDrsgGUOFGYDKfw+ FMVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708532664; x=1709137464; 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=Qfzu3QiTwEiyjKgpyR/+rDeqO020PiZW5paEtks8JqY=; b=r90ovry4DKrGBJ4orwYjgRZLs3WgIIG6P3N60l2DU7X/eFLBLeWDlEC0RYvN2i/BFN N88vE3b/xI55Ils27w+Tc2zfYZ28SPPCHmW0QOyWrW4y73EQNy6qo15uUePRpJXtnDOF xNvbnnfHyUdOZPblj4Di6fykI9Isuz2ZtZ0+fFMOjdts/ILixYaR40AhGYbkSVYhBxG1 kXoHWoZqSZ/785FgInCfQJx28k92eTKO+L7uvXB1M0JFSJhmTNm8YsUzBMeYWjCrq+tQ aPS8MPbmbxgJiCy8+E3/ciYjENxSl+FX1MF/ueL1+8yNFGJwgI0UwiKPpXpw2ony99+r DuzA== X-Gm-Message-State: AOJu0YwpjQ+F7N20HCUFxZQXR2eEzfXbHRveSLwZcwh1D+hqCbWpXLc8 6vxEiRjjVuFrx+0jGhi+wzFCATgR3MNEIzNtWx+OJiSAIeCZgQSeToEZ4D69 X-Google-Smtp-Source: AGHT+IET8VOgGYlZYsuGjzQaSgFcwBD90Pn5KbCDlI7D7pVQ3LDCLz0mhaBdS1pdDz5PlkqJN5srIQ== X-Received: by 2002:a4a:e8d0:0:b0:5a0:109f:edff with SMTP id h16-20020a4ae8d0000000b005a0109fedffmr1988861ooe.4.1708532663604; Wed, 21 Feb 2024 08:24:23 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j25-20020a4a92d9000000b00594ee4b4339sm1905405ooh.28.2024.02.21.08.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 08:24:23 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 3/7] qmi: Remove qmi_device_set_close_on_unref Date: Wed, 21 Feb 2024 10:23:16 -0600 Message-ID: <20240221162335.1258315-3-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221162335.1258315-1-denkenz@gmail.com> References: <20240221162335.1258315-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 7bfb4bc0d74b..07af29b42b36 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; struct l_queue *req_queue; @@ -924,7 +923,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) @@ -994,8 +992,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); @@ -1021,14 +1018,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 Wed Feb 21 16:23: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: 13565926 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) (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 C565A8173B for ; Wed, 21 Feb 2024 16:24:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532667; cv=none; b=V7OGknlHud9ERQtFfu5BNsfGZoxFjPUlQJ5R3wzXIsEMLqQw8NXgllDRMDCfUgwtiZcpUJZWiQIEoQ6EcWAGayujuKteOVI98DwDpCviPwvFREEVQIDSoQd5uFm5/AciA1B5aXW0b7o2mZ0f6HfYeAH6Uh85xjm+6IcAxmOoD0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532667; c=relaxed/simple; bh=xNjM/igVeN3x+ZxzOHSrh+oNrV9Qm+i5zT1fmzVqhS4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Mn3Qs7p0wmWKwiwi2dbz7ztUsJ1HaVivCEKP8g0qD6CHV44SA2IN9nXymzDAJHoE4VGaaLIFAH772Ia2mG6sK8UWwkS7ixSNc+5FTYMuVcHyZzYf96yr2/MKiblSrYjdrhd1YPPJMqSgkj15b4UK6+FF67snwWdd64fVpU5ob7g= 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=UkYEIyOw; arc=none smtp.client-ip=209.85.161.49 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="UkYEIyOw" Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-59fd69bab3bso1064573eaf.2 for ; Wed, 21 Feb 2024 08:24:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708532664; x=1709137464; 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=Mxtq5LsFZH6DVoNunk8fO4WiGLMQXCj2SSNN5aqRy6c=; b=UkYEIyOwtX0g0QO3kpvESK70h0frnF1lkJtQcST7CiByitYiGSq+EjsMDp0LCoeOrZ cqeiUUhzCNI7nm7LukoTFXBYupoRSkzzQguN1UB3SujuFXP8PcKyaKeH9jLeF5YTEzPY rW4TDSWcClO+elDNjKrsJuKjQAWtijk8UuhfHbsV2UOKKxpmcIN+4JsbS/ESv9OR85i0 irlS2eJ9rl53wyaTqPcZwGtTh17eNcq1nJEtYRkkBetmwUUZAIwkOekBgkGqIXoJTMnU 57eoN75rYOxJtMegzkfeVri3sPJKIRlsqSc8AZ2B7P42BURmK2rPHCGx34eQDsRQ1LvE 7tRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708532664; x=1709137464; 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=Mxtq5LsFZH6DVoNunk8fO4WiGLMQXCj2SSNN5aqRy6c=; b=wmLgQ/Z1nkP6Yg46DspX2LuSk3YSWOIw4/pMDhjMzw8fL8YEQXh4J0jP8etLlxicCr H+0/nkN951sw8eOsXc+q0IEkzKmlzeXjp7JEaLXDfHwOmXKzQ44O4S1HMdGESQyk8arP z1s4rPHmmVV9aiou0HWi18ZfiX0/dj6KY7E2LODuz7325KtnVimQaxx8emNlgk1il4Jr utFihv7BAdd9EFGQaxq5y3Z0sJqlGO1n5FEAEkd4b6K+WLX0PP+FLLRvd73fmNy+tzDu 2NLsgMo1G0B7+Cz+gLQ+AlQK9TVCNtj+8kwTcRh7qHvM5fst6h21TJGwg1w4RWf7wAC8 o/8g== X-Gm-Message-State: AOJu0YzRsfZB4XFtbjHjVWhl34Zacl7dpSnSi76Xb7lnSGDNZ8Ppcj9q jNreKYXJDW/OXXsQq9NsmQRuJ3jZNljUsFrVM1gNLad01XsCALlvHnQSevSg X-Google-Smtp-Source: AGHT+IFsdeaTxeELtF3Tx22VkLWCqKW7q7UYQ8D9W0OkL9e8fYgPuUQVtdSVNgaXfi8mNySmb4XWaA== X-Received: by 2002:a4a:d5cf:0:b0:59f:f90d:49f0 with SMTP id a15-20020a4ad5cf000000b0059ff90d49f0mr5284258oot.2.1708532664631; Wed, 21 Feb 2024 08:24:24 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j25-20020a4a92d9000000b00594ee4b4339sm1905405ooh.28.2024.02.21.08.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 08:24:24 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 4/7] qmi: Move control_{major|minor} to qmux sublcass Date: Wed, 21 Feb 2024 10:23:17 -0600 Message-ID: <20240221162335.1258315-4-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221162335.1258315-1-denkenz@gmail.com> References: <20240221162335.1258315-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 07af29b42b36..08adb0f5fe02 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 { @@ -1151,6 +1151,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; @@ -1194,8 +1196,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; } @@ -1218,8 +1220,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 Wed Feb 21 16:23: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: 13565927 Received: from mail-oo1-f47.google.com (mail-oo1-f47.google.com [209.85.161.47]) (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 4E58281745 for ; Wed, 21 Feb 2024 16:24:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532667; cv=none; b=fmVEwdPwp3N2608lfdUiOKIiZRbRcV5UQhH9x9ltP17E4w9D1doPQ/MrTM+oALL4R/s+r2KtfdMQytvFpK1qJ/iTdWyXh2DKzglKU8WFhxXyS5HUkdm2hzKgwi5eLiZMBM9dY1TwPrBcksJIGMsggNbkQ0xglXICcgdNCrcqR+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532667; c=relaxed/simple; bh=BRq8Dj3TeIywC6HGdCK7uFM9Sy5DGi0B4tR5umyx9V4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FWFEyN7viEof6OUxQFNNtfJC1B3iTUB4DSHiZuUjyRFHD24Og4rVPGa8+FWgaxrn6ZqHw6GaGwqZqXTYkz9xH/egBqMUVDbVEn64qiGH4CrxhOl88oxfYcnRQpBTWpcmN5m33oIOh82VAs1LtEK1xuxa9LKPwGW/Dx/RB9/LrTU= 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=foMZoryd; arc=none smtp.client-ip=209.85.161.47 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="foMZoryd" Received: by mail-oo1-f47.google.com with SMTP id 006d021491bc7-59fc2d22cfaso340857eaf.3 for ; Wed, 21 Feb 2024 08:24:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708532665; x=1709137465; 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=Y3770Jeud+LnpZQqxRP6EgfT+9//ThNEG/jkxbjD2w0=; b=foMZorydlMtE2ja7AaSI2vTRU3ul7vzrVIfwgE2Rtmurrg0TobqBNNeR6ujA4vLiu8 DsJVsZMWdLqhnLvoWZfI2s1d/P8NGoARrotlFGxOd5uhb1bQLcRHqb8CUzEzQhQTgLmr rj3DM5Bnk7iGvu4oLuSm5KoOrPKP7itm/i3WfRaRc/2/e/cwp+CWOin6QanBr9aznlYV lIw+ytht8jTNQ7+8/JU2XRYYxry9sQ/SIw8c1f2yWam08fk3ad35x67/g53ij3lWEozU oml06kT20H55hGWQ0lfh2vupxRsoHuc9HjyHJRdjuK6jlhjE3Hx6ph9Lvfd+CY6jfRhg 6+pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708532665; x=1709137465; 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=Y3770Jeud+LnpZQqxRP6EgfT+9//ThNEG/jkxbjD2w0=; b=S6aAp1hwBVMLmQ9EzsJaFmE949RmxcTvJOMO1vxt8sKvWnnaF2HeWD24uu0DtvJ/hc BwCdftlrqVjg0yMR04RDyng+SmQparzFhQWpHjvStnIw4WO105HTuLmr3PNhM5JyDDE0 3Y+wrxO6z+ZgvDG8Q2U5M6bvTx19p0SvnksRLMYa2Bg+sSaQEFonlEgBZCGrUJ6kmLY/ BAyrDFE5GTaFasxG06nlB7bvGNi3LKg8ynhifSvSvbdKgdLn19wG5f38qW06AwS+nSh3 mx8uB56RUd1qXCDTq9cahe0bNBD/0SqMl9H2zJJkXtm5psIVj17ijJlS0jvyH2L10h27 OSFg== X-Gm-Message-State: AOJu0YxN9verKwqjFIoYS6MphGwLbdJR5Apn/R12Jt553B408QFj9yBg R3gqVHZAWNgA7VneY49sX4qPOjBL3RSCPOOxrCruWTz73wLzg86E2kmnkn8/ X-Google-Smtp-Source: AGHT+IHWIF/H6fLbnNgKzRxFQ+OaLNNjTUPCPbhkEGPoIr/iR5MNp7yUeikoDVcWW2uKpcMNjnGC4A== X-Received: by 2002:a4a:dcc3:0:b0:5a0:1b43:2c91 with SMTP id h3-20020a4adcc3000000b005a01b432c91mr1358405oou.9.1708532665285; Wed, 21 Feb 2024 08:24: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 j25-20020a4a92d9000000b00594ee4b4339sm1905405ooh.28.2024.02.21.08.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 08:24:25 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 5/7] qmi: Move version_str to qmux subclass Date: Wed, 21 Feb 2024 10:23:18 -0600 Message-ID: <20240221162335.1258315-5-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221162335.1258315-1-denkenz@gmail.com> References: <20240221162335.1258315-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 08adb0f5fe02..59a10c8b8f8a 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; struct l_hashmap *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 { @@ -999,7 +999,6 @@ void qmi_device_unref(struct qmi_device *device) l_hashmap_destroy(device->service_list, service_destroy); - l_free(device->version_str); l_free(device->version_list); if (device->shutting_down) @@ -1213,7 +1212,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; @@ -1586,6 +1586,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 Wed Feb 21 16:23: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: 13565928 Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.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 0FFEE81722 for ; Wed, 21 Feb 2024 16:24:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532668; cv=none; b=S3XJAcHfm0u0cowTrrtaleKLmNTvu/FjyRI4eUV4F9I/lCkjlOXT8RbntrKbWcyQqGvs4hF7Eq5tQ1BRpSYM4CAtCKszIkb1uDdIhVGGbgrqgSseNOFFsyJVXEMPTNn8eZorSQZ/30TuJnJbml8C/Sks+FAzOQ28Zz+dBEbqFHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532668; c=relaxed/simple; bh=oZAG7gLYq384QCCbsCiXEvlN5OdbnZCMysDT4myrQag=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gT62Yzg2/jxRVQYPf5HrdCC56/dzh0DVqowcbjQtcqL0QhLqr9ib30GZ4iXHPZZ60nU8uEPuEEFp/CJYfbdM8WG63NN3WqlbIMPvqdYaajWxkON5TPZM9cUnzRFdjFWyGodL8+kmYt4xU2o87Zn9VZx6zP3HKqqTObkWlKjzbZM= 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=PlaJ5kEq; arc=none smtp.client-ip=209.85.161.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="PlaJ5kEq" Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-58e256505f7so4695740eaf.3 for ; Wed, 21 Feb 2024 08:24:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708532666; x=1709137466; 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=q6Yl1bcNNjiOrUrf96Cq3A7M9yPt8gATRmnTHmXaEWU=; b=PlaJ5kEqIRN1NjIpPZV3qWj0C57kSQqGx61ikTCXP15Z2aUp0OzEX0Sl3wcByy93PG V2iq6SsaOjbBeQdXPCA2BYZVloqGo8fwYaEGdZ0QV5jJ2TeydHC+YbDN8wgvVLBAWLWk kbaNlEPsmyJVjoePZgMG6Yh3paGigNEf8W7Fo/E3WvVxjh7DZEFYvXDPSqwAMHvwaC+3 JHWKJ7ssle3rvL3VGZOxYjMmb92xPvVPaZyTK2DdsJrOmR1VR9AEZ7nyJ5DvT7WpypiP mkRJ6UODL38n3tKoeEAa/lQyc+ovsW5ToFjuLraNBJtGq1PLisBl51+N12Y2QiBXPvgq gYTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708532666; x=1709137466; 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=q6Yl1bcNNjiOrUrf96Cq3A7M9yPt8gATRmnTHmXaEWU=; b=WQ3r8BB9arczbFodZ0kHEyNIYZqJsg9KIVF1OzaYjQgUuFODbS4ZVllurRMcf6TT2c sE0HHVJU3LHyeU8lkZxLle71lCMFUvTEMW5c0ThWGipxTqd/dufZY8/ixMP88xZeRFAL vT8Nll5O33cpbrso64NZ/3NrJLEfNSbKELuu4XvPQl65y1wwj08uQVTHtrChgsga+91b zK/SzjwdQZg8tK4YxMCsqoauWRDbDEq4ge4PiQZqYGKJbN/J0nMbMLfn+KeH1sOMsjxr rzgOayYVz3sFHh1Pf+am1562hI9l6LWsU5hVluoMNIQ9C+KMhlDBxVi4hRRX62J9RoB2 bfNg== X-Gm-Message-State: AOJu0Ywb+dLxpV16iqnmTifsxAbEqQgOw2+Z9ZdxshY/NbOMa1cRZ5hy F2s83D+gs7TraM6W+QuEDdk4h6TQg9VQA3U+Ii38Tiy8fNcnlVjFGycQJWNE X-Google-Smtp-Source: AGHT+IG3tjamJH6AYUQrxTplQaqxCsrEh8rhA7YObU7K0+sHhF9APj80I1sqxwBZM5TEgbKgkuHBZg== X-Received: by 2002:a4a:9c46:0:b0:59f:fc2d:8179 with SMTP id c6-20020a4a9c46000000b0059ffc2d8179mr5509278ook.9.1708532665930; Wed, 21 Feb 2024 08:24: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 j25-20020a4a92d9000000b00594ee4b4339sm1905405ooh.28.2024.02.21.08.24.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 08:24:25 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 6/7] qmi: Introduce shutdown operation Date: Wed, 21 Feb 2024 10:23:19 -0600 Message-ID: <20240221162335.1258315-6-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221162335.1258315-1-denkenz@gmail.com> References: <20240221162335.1258315-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 59a10c8b8f8a..23229865183d 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; struct l_hashmap *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 { @@ -971,6 +974,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) @@ -994,9 +1003,6 @@ void qmi_device_unref(struct qmi_device *device) close(device->fd); - if (device->shutdown_source) - g_source_remove(device->shutdown_source); - l_hashmap_destroy(device->service_list, service_destroy); l_free(device->version_list); @@ -1331,58 +1337,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) - l_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, @@ -1581,16 +1545,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 Wed Feb 21 16:23: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: 13565929 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.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 A1F6681741 for ; Wed, 21 Feb 2024 16:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532669; cv=none; b=h7wCHqSdbqbkBIDD20nSPvYDsas1SLNGfFyuAzJinzUZPUsdxkbZrLJbB3XyV57V8J5SokGpzB+UwVuHAWfvoS/Aj7L8Uxr7ikYirG/JEZLTHcNO26WsCbdlAtyh5bBsNELAFlPWyh+iQ4ZBQ3oIBxb+QTMi6VKf1NIxjbF5uvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708532669; c=relaxed/simple; bh=i7tvfcKFmnVh78d8KtLw3QfEElFRS6FPwMN02y3MjuY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SJ952RPsRhVReTLndYx9IJ8EtFjAG1Y3zHZ5DTfdV4hNcESG5jdF0qUzvC7QN3NDNgWjwXc/OMIY+WKX5LtNPg6KuY7lw7aIozVh9Wyh1xtZD9vJt+CrOTzre5ZS5kVruURMqrS1vw9wXaTSGSJFU197OEzbwhDa1YKek+JxObs= 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=Q6YboZzG; arc=none smtp.client-ip=209.85.161.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="Q6YboZzG" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-59fd69bab3bso1064587eaf.2 for ; Wed, 21 Feb 2024 08:24:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708532666; x=1709137466; 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=Q6YboZzGjdJgOCl7GJfUeM51h03G8q43v9kMGYcrDMLJF174Ozz2p3r53sXnxLnRiU 3j8suZUK+dSzeEpd3tTK+Hzdpq6/IpxwYqhDBoHETAvJ/dJ2WkP2KvkxBH7MgqSrS+oA EN0oGWBFxwfXSVmuba4HT4fiwPMpLFqKy4O69EG0ZkC6FgWFOUXyLkC6er2JOx46Kn14 lrlRkFjELjew8WdqT5RqgHrUvdMM+Po9Tx0e/nRCtwFkEAWS4op2DZUJTsVfVeQ5pEIx SqG4ZRZ9auR9iDZIvud0MvOf398Vaf2GVMUX1WVN25gFx9zEjvZhhmkiKidmARgYQ+0c aQRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708532666; x=1709137466; 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=JK2kUUSMfUpU0Q7tptwA5oH2AfQ70xZGRVuwAVBlF/OtwioSmUNIb2mvHEAdzCFDDd 0wMPBGNRGYsjK8Tcvjf+IhD6GkMy56KGD/LlonGU8sVU1/ImvCRJ8olhFOBH3GQYJFVw cLlEWY5aTKnPApK9S2Zjyj537ZSW5rZlCAIdDCEvHGyfu5Q0uQRqwAaDEn+ETrbcSMeC IXn0Q7pjNHGDM7PwzPDd1CjrjAD+M9r3pQnOidVJlzu9LN4ECNXM6e9zVzBERfAY/nhf 6EzM2aTZuSp/g5xGJ9NMcKdJ1OWNDsQIf7ii1hUtCRy/EVSt0GhsG6CmflG0WzcfsG6H jDgg== X-Gm-Message-State: AOJu0YzztPsciA2ak9SkZFNCXpxqAJWyr6eB/mhWV5me3By8CK8WomL7 PVsGHJOLA1tViW0XTFpgbWiavCOwrFxCx0/zh+X+7e6SNOgw1aXsEBEUarG/ X-Google-Smtp-Source: AGHT+IGH//ey2u+AO701tYtJXfQw2bVLBIRDH2tB+MHZrvcBVKX5Ul3I9qgKrcBPSkhfWwDCv2Fi/w== X-Received: by 2002:a4a:dfac:0:b0:59f:e26f:fb1a with SMTP id k12-20020a4adfac000000b0059fe26ffb1amr8446002ook.3.1708532666554; Wed, 21 Feb 2024 08:24: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 j25-20020a4a92d9000000b00594ee4b4339sm1905405ooh.28.2024.02.21.08.24.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 08:24:26 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 7/7] gobi: Fail if device could not be created Date: Wed, 21 Feb 2024 10:23:20 -0600 Message-ID: <20240221162335.1258315-7-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240221162335.1258315-1-denkenz@gmail.com> References: <20240221162335.1258315-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: ");