From patchwork Wed Feb 21 22:17:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13566554 Received: from mx0b-003ede02.pphosted.com (mx0b-003ede02.pphosted.com [205.220.181.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE6B6128802 for ; Wed, 21 Feb 2024 22:18:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.181.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553923; cv=none; b=SSc2MSu3PwXIUsgDCOM6knis/aaTExI//tsonZRM3IilrbcBuTANAwhW0WmxkWYSZu80JE01l92mztLU0zniunyJjBhiuAGEtKZ4h+2v6TQsOgEKaJqJvBY0vrjmg3q5sy/XIMZaj1jGf/a6pmmu+B+eM8f03ghnSZP/V8oJKAI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553923; c=relaxed/simple; bh=qYtF0+IosNPOvoPqI2SorHakXCCvrp24hoOnYoaxGUw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type; b=JPsJAt8tiMDGAi2dKKVs1/RfmkKonbfKSx3VsFeDIn2VFfFT25FEG5sgi9MtVo7klpfj+7lIu4AJck7MaxaH2EPXOiqT4r/sXBVOQccsMOQ6RUuiPYm2Sj6DGUOZMnDFTJkqIfeLxPpWICJ59lp/KhiZV8Jqk+BGb7oUjalM0gc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=GzLw3htZ; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=I6+BPPFb; arc=none smtp.client-ip=205.220.181.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="GzLw3htZ"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="I6+BPPFb" Received: from pps.filterd (m0286621.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41LExnJJ025791 for ; Wed, 21 Feb 2024 14:18:40 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:mime-version:content-type; s=ppemail; bh=5XJqQ9AJQ+tf5XeyCQVo1hDFkBJCXmQFNo+r5XxF3fo=; b=G zLw3htZBwC+uNgTUc0GgDcDSjcq6pr2R0TvSXK41lX1Ana7sLRKn00O5F6Z+cV3A gm7HsaFPR//US/3NyqVZcBJectojjZQ5xL1kzbMmSPTTDr3vXXuJXpNexx3wuIRH 0LCJ0UWtUHh0n0JEdq3RFnKJWtCAX5A1ggVBk9+/usAsdXwzDqpnYVvvRqlONHni KM6JvR1OY6/htHW3kBfXsmSU4aeitfIo0g/8F2at7vJZQSjqkMC8IRIBDURyRtHA 1gDpPKSXeEgqafLaVN4Ht8cglvbABGqPAOuDUOVUdezcUp0pdRwDR90oUSxihH7O 18JzYuyM5DjJMWm4a3tDA== Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3wd563h2tc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 21 Feb 2024 14:18:40 -0800 (PST) Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-68f75cca6aaso37657506d6.1 for ; Wed, 21 Feb 2024 14:18:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1708553919; x=1709158719; darn=lists.linux.dev; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=5XJqQ9AJQ+tf5XeyCQVo1hDFkBJCXmQFNo+r5XxF3fo=; b=I6+BPPFbLUbWXArdqOqzXArtIV85MPUORmOWQAm/YRQMPEQkNakwB8XMWtemzVvkwc 0ICoU/4VUC/82SviE9DiRd3WJm16yDSrcH8ZgvhSAGjxuTpNoNrYhdoFRcHe1/zDHlog d6eHmXuuRzD85pIm4bQZ7O2OVqK+OfGUHHXIqK001RcJQhMxpXnYl41haC4vQw9LB7+W KUTu+V00t8VHBqHT1ChX7dATfoxOJMQDFYHFh/N2hwCnoNaDbvR+0/UOr2W0u9dJ/+I0 KssnBQc/MwlYpyIkWBa5H/mdyGgcdTDtW0Ufr8pTtHsZDVh/TnOTzXSktyAYnrSxEl9R gs2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708553919; x=1709158719; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=5XJqQ9AJQ+tf5XeyCQVo1hDFkBJCXmQFNo+r5XxF3fo=; b=wn2XS+9QUOeoRSsf5UuyGsv8Ftyd6R5MFRIf4Y37+lYkMOws68vMv6dOKL/Tll2i9o dD03kTfpt5WK9UAoo4ovOwgccjxjTPozpOMHrgrBDSKesSqjTTqKTF3IwpvYMh54Avdq dhPxh2rkeT0tK6O2KVSVs4Uayn13MmteG04MvAnQzN8yhWeSN9O9m8HBGKFD0aBX++/A SuvcR+1ioVcGTFATKzZPAtd2upA8y0fuVq0mUrgGC6gHGKrt7VIfm3QoYP1BNrgBFf98 9RfNzpgSwuSQZrp0QRL6pn8vVQYzGuiuMr2Cm52G389DPeQqdo2pNYGCcVcEmDR33aGJ hcRA== X-Gm-Message-State: AOJu0Yz40rU2BXk7bUkPDldtlPJvXPeRmrZIq0M4/k4z3/uoR5X7mKkK o/jL2Mmq4+Vbirk9oqsHGglY1ibARHYAsGvI3j+Yaw7lvGwyx7wPtUZYfW5rI3m7Ru22B5hOi+y QHKG2eHNfCeWkqxs6iGim6XObGwzgGYerq5/2fY/1R3CnfAhy9rNUuubkILy9DYiPQ4ia8cU9CI U3h4xOpt5mnylau9u+/MVCYGYr1QNyCixh0a+7CKv8AMorPvc= X-Received: by 2002:a0c:aa1e:0:b0:68f:a76c:1e0c with SMTP id d30-20020a0caa1e000000b0068fa76c1e0cmr2654983qvb.48.1708553919666; Wed, 21 Feb 2024 14:18:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IGl96xBm1+e5XT5cVkLvehu8k3NfR0o57H+Yf3YI1f3OjN2WS2Kg32tAMvfaelqzgddLkMfAw== X-Received: by 2002:a0c:aa1e:0:b0:68f:a76c:1e0c with SMTP id d30-20020a0caa1e000000b0068fa76c1e0cmr2654964qvb.48.1708553919312; Wed, 21 Feb 2024 14:18:39 -0800 (PST) Received: from localhost.localdomain ([140.177.180.84]) by smtp.gmail.com with ESMTPSA id pf2-20020a056214498200b0068f719ed978sm3841446qvb.33.2024.02.21.14.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 14:18:38 -0800 (PST) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH v2 1/6] qmimodem: Use l_queue_remove_if to eliminate double lookup Date: Wed, 21 Feb 2024 22:17:20 +0000 Message-Id: <20240221221725.185480-1-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 1R8kSIVYD2SBCNCieCaNTpJp7gzojGdj X-Proofpoint-GUID: 1R8kSIVYD2SBCNCieCaNTpJp7gzojGdj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-21_09,2024-02-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 mlxlogscore=938 suspectscore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 phishscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402210175 --- drivers/qmimodem/qmi.c | 50 ++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 31 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index a2f5902f..d2d4eefa 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -793,12 +793,9 @@ static void handle_packet(struct qmi_device *device, return; } - req = l_queue_find(device->control_queue, __request_compare, - GUINT_TO_POINTER(tid)); - if (!req) - return; - - l_queue_remove(device->control_queue, req); + req = l_queue_remove_if(device->control_queue, + __request_compare, + GUINT_TO_POINTER(tid)); } else { const struct qmi_service_hdr *service = buf; const struct qmi_message_hdr *msg; @@ -819,14 +816,14 @@ static void handle_packet(struct qmi_device *device, return; } - req = l_queue_find(device->service_queue, __request_compare, - GUINT_TO_POINTER(tid)); - if (!req) - return; - - l_queue_remove(device->service_queue, req); + req = l_queue_remove_if(device->service_queue, + __request_compare, + GUINT_TO_POINTER(tid)); } + if (!req) + return; + if (req->callback) req->callback(message, length, data, req->user_data); @@ -1244,19 +1241,13 @@ static struct qmi_request *find_control_request(struct qmi_device *device, unsigned int _tid = tid; if (_tid != 0) { - req = l_queue_find(device->req_queue, __request_compare, - GUINT_TO_POINTER(_tid)); - - if (req) - l_queue_remove(device->req_queue, req); - else { - req = l_queue_find(device->control_queue, - __request_compare, + req = l_queue_remove_if(device->req_queue, __request_compare, GUINT_TO_POINTER(_tid)); - if (req) - l_queue_remove(device->control_queue, req); - } + if (!req) + req = l_queue_remove_if(device->control_queue, + __request_compare, + GUINT_TO_POINTER(_tid)); } return req; @@ -2375,17 +2366,14 @@ bool qmi_service_cancel(struct qmi_service *service, uint16_t id) if (!device) return false; - req = l_queue_find(device->req_queue, __request_compare, - GUINT_TO_POINTER(tid)); - if (req) - l_queue_remove(device->req_queue, req); - else { - req = l_queue_find(device->service_queue, __request_compare, + req = l_queue_remove_if(device->req_queue, __request_compare, GUINT_TO_POINTER(tid)); + if (!req) { + req = l_queue_remove_if(device->service_queue, + __request_compare, + GUINT_TO_POINTER(tid)); if (!req) return false; - - l_queue_remove(device->service_queue, req); } service_send_free(req->user_data); From patchwork Wed Feb 21 22:17:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13566555 Received: from mx0b-003ede02.pphosted.com (mx0b-003ede02.pphosted.com [205.220.181.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6335F12880E for ; Wed, 21 Feb 2024 22:18:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.181.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553923; cv=none; b=NEE3pBI1oDG0L6/raK5mj2YxfQI/yvK6LiijD10XohOBCbShXbjiUYGu7n8NGtMYRifweFLsoIXC3PMPWsQsbgCd3O+TmMmAmG5hLoieV0sgMXayXm7rwS4fSBjNEzpJ+WKb8LhPQLf73wQkJegGtKbnX/zMPZoC7WZGlfVjTBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553923; c=relaxed/simple; bh=35xLVs3zJ+JNeJx0FDJyLA4CUaxVkmhU8KrSdwycpPo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=cKBssclbrA//fXGt1vbcWp4AGCXsVC51pqn1FFLl1eOhNd1/Mo9oyix4nKIotnE1louzpfkJNIQRyQuEvpfNvubQ1Hu/HNXCAO40RE4ay46/L4cJogMr/3w0pL2alftM7UjMIOB2fcKtAD7liZejjUCWVq8zIM1gCI1OqmeJMVM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=McXRf6Yn; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=iAUTGFkl; arc=none smtp.client-ip=205.220.181.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="McXRf6Yn"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="iAUTGFkl" Received: from pps.filterd (m0286621.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41LDA1Vq027307 for ; Wed, 21 Feb 2024 14:18:41 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=ppemail; bh=KiOLlf0FI6bAWwarlXS1fi 8A/EMgkRkenG107RD8O5w=; b=McXRf6YnC1XzssIqwXf6C7XKvipJbZpTresFOW 1jHMg8Aa6fspRULxF8/IjgBC50zeDg4zmsY7gE/SkVnhZrLspKRWutyCPugrVy1A 1tkmT8ZJOvur6BSWsWXAXJnZY7JQXF+oRTU0JDc465EHf7h4nZtshsWY/W09dnUu mObkU61VhQf6hWjgj8ozt8IZEmoVdW2IS6nLrTFiAScOT3ABXAGAN3FYr7U1DwTW GPktZvdi2aDw3gShmBkMPwkD76yRDPCrO6XzEKz5ZTNcVP+00jhsDIwmtWNaCPpF 5atboQH2DKgWPqKoVR0fM6G/NE0WHp1lWfuCHYUlr6UtNLzQ== Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3wd563h2td-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 21 Feb 2024 14:18:41 -0800 (PST) Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-6800e52d47aso5259586d6.1 for ; Wed, 21 Feb 2024 14:18:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1708553920; x=1709158720; darn=lists.linux.dev; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=KiOLlf0FI6bAWwarlXS1fi8A/EMgkRkenG107RD8O5w=; b=iAUTGFklCIdHP6xWggAZvuYdVUaXqNNLToFalZxsZCRKOFGQ5IxqNNtePi+FwTxEpS 0DLzDr6nK9XNJkd4NfaGPvT5Y+0hH9qUieN3EtP9qVL2h9tHz/kWXX1SJ0s4JF6Qt7HP vuSrcbBM38Zhn0C21zpxELEi7Ds7Vd9p/YcvcROTcFI2dT32ZUcPuTcZEa9Qd/7FfMJQ IZUEZOxv2zxMIo+Ekik0jpQpsRz+2IaToccG1YlnnHPUWd/mzOxtBQmLJ1JqTENjT0p7 hAcstcx2BM+6Pi8J2Qinu/w88t4umfhLGXv8wt69se3UhdIKXVIiDqDHklNqQMFV4Hu1 CgGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708553920; x=1709158720; h=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=KiOLlf0FI6bAWwarlXS1fi8A/EMgkRkenG107RD8O5w=; b=lSe+YDToz8W+nN9cF0+c9gZPrCz1sKRBOCaS+AgFbzow92oRG1vYzoLzP3mgsgimb+ rjxF/s2hbEEtDMprxJg7kaRCh4vhsKZY908B/pi+GH5s3DcKVUUdjh27Jb7QLYufv6n9 M7EzfXAwD8jEbk3aQK4rqOFxwl0Tzv4pKTF5gtPP4Guzrcjp7MzjWueC51emBDO8hC9J hYO+O1pTQmnj1oROkEMzxBMTXKtkxc3tlD5IZ2qFZRYnpVCiygHwIOaa30F/vnKxmnzF xUg/VuDxl4o109oc2nxpbcjuG2y6Gn4ohLSt90cvAUWwiX49MZxLDts5/7ai90LnSZks JnzA== X-Gm-Message-State: AOJu0YxAzaViXyV5EaDgaQrNXsUs0kgKQFpoxWQMrTuS9A4ZBMCoAKrh hE0SxUC8zfiwGGzW5QTUwb+7kyinlrWFHTYqJVj+s3FfMhEt4Baz228Aw3opAPSOvr9vgoiocGF jp7RF8zwXto1gGUxcHCuSxyOfUXvDAvtu2+RNWe7UpaWeWQr9hBDI4wmkoyDI55xduw+bK2NAwe OrbKcTVCyNmRYzdMm2eHCRw+cbN5IP/yVnJcQD++sxWvLOvFc= X-Received: by 2002:a0c:8bc2:0:b0:68c:88fd:d314 with SMTP id a2-20020a0c8bc2000000b0068c88fdd314mr1234772qvc.14.1708553920139; Wed, 21 Feb 2024 14:18:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IGA5wTCxm+xxCOury1KOXzDsJuQSRK9qQ+fgbVerRZIILDwV1/QsXxz1Dz7fRMKHlG9ynw0Aw== X-Received: by 2002:a0c:8bc2:0:b0:68c:88fd:d314 with SMTP id a2-20020a0c8bc2000000b0068c88fdd314mr1234750qvc.14.1708553919755; Wed, 21 Feb 2024 14:18:39 -0800 (PST) Received: from localhost.localdomain ([140.177.180.84]) by smtp.gmail.com with ESMTPSA id pf2-20020a056214498200b0068f719ed978sm3841446qvb.33.2024.02.21.14.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 14:18:39 -0800 (PST) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH v2 2/6] qmimodem: Use l_timeout and l_idle for discovery Date: Wed, 21 Feb 2024 22:17:21 +0000 Message-Id: <20240221221725.185480-2-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240221221725.185480-1-steve.schrock@getcruise.com> References: <20240221221725.185480-1-steve.schrock@getcruise.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: h8OlZSwK9eFRgccL06qLR1zYKbE5yqOH X-Proofpoint-GUID: h8OlZSwK9eFRgccL06qLR1zYKbE5yqOH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-21_09,2024-02-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 spamscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 phishscore=0 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402210175 --- drivers/qmimodem/qmi.c | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index d2d4eefa..6880dc45 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1101,17 +1101,19 @@ struct discover_data { void *user_data; qmi_destroy_func_t destroy; uint16_t tid; - guint timeout; + struct l_timeout *timeout; + struct l_idle *idle; }; -static void discover_data_free(gpointer user_data) +static void discover_data_free(void *user_data) { struct discover_data *data = user_data; - if (data->timeout) { - g_source_remove(data->timeout); - data->timeout = 0; - } + if (data->timeout) + l_timeout_remove(data->timeout); + + if (data->idle) + l_idle_remove(data->idle); if (data->destroy) data->destroy(data->user_data); @@ -1253,17 +1255,33 @@ static struct qmi_request *find_control_request(struct qmi_device *device, return req; } -static gboolean discover_reply(gpointer user_data) + +static void discover_reply_idle(struct l_idle *idle, void *user_data) +{ + struct discover_data *data = user_data; + struct qmi_device *device = data->device; + + l_idle_remove(data->idle); + data->idle = NULL; + + if (data->func) + data->func(data->user_data); + + __qmi_device_discovery_complete(device, &data->super); +} + +static void discover_reply_timeout(struct l_timeout *timeout, void *user_data) { struct discover_data *data = user_data; struct qmi_device *device = data->device; struct qmi_request *req; + l_timeout_remove(data->timeout); + data->timeout = NULL; + /* remove request from queues */ req = find_control_request(device, data->tid); - data->timeout = 0; - if (data->func) data->func(data->user_data); @@ -1271,8 +1289,6 @@ static gboolean discover_reply(gpointer user_data) if (req) __request_free(req); - - return FALSE; } bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, @@ -1295,7 +1311,7 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, data->destroy = destroy; if (device->version_list) { - data->timeout = g_timeout_add_seconds(0, discover_reply, data); + data->idle = l_idle_create(discover_reply_idle, data, NULL); __qmi_device_discovery_started(device, &data->super); return true; } @@ -1305,7 +1321,7 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func, NULL, 0, discover_callback, data); data->tid = __request_submit(device, req); - data->timeout = g_timeout_add_seconds(5, discover_reply, data); + data->timeout = l_timeout_create(5, discover_reply_timeout, data, NULL); __qmi_device_discovery_started(device, &data->super); From patchwork Wed Feb 21 22:17:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13566556 Received: from mx0b-003ede02.pphosted.com (mx0b-003ede02.pphosted.com [205.220.181.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E30212880F for ; Wed, 21 Feb 2024 22:18:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.181.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553925; cv=none; b=Ykt9MsPOQAb7j/ZtZ5qAfdbm3It2ewBh2BZ/oIf430jW+hLH+ACK6g1m+y39YHx8FQvZJFSLwB29IwsqLdgdgKzVI1HLkd5fn7tSnaU9euX846yhyATOn4LywvrsVP4CAgVPvxzc4loEQf8v4hn+nWs3GjGC4F4cxx1tEqjaSi0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553925; c=relaxed/simple; bh=IPYn7tKZNBiKSvD3dVbg0eKSuqb8jx2973Qhp7/jG3w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=UuoPh1Wcp77MG/DPNJLREadA8En6p3szkcAHgInzhr7Ml2QgQ1HDlWJA71jCrQgPPZxV6KRtawzLMpH9Hjooz/f7DxC7q6+i4DMi6TecdicvhAWizcxK4XgxYfLx04SMqWcQnE1cGJf/U31HZp/GLFKW6kaWgHa1N5ecdE9vjMg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=GenciCs1; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=PoidFLPR; arc=none smtp.client-ip=205.220.181.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="GenciCs1"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="PoidFLPR" Received: from pps.filterd (m0286619.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41LEjNAb018898 for ; Wed, 21 Feb 2024 14:18:42 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=ppemail; bh=6uaf5HP/wTsxJA2qe3SmsV Px7DQ0neloAV4r1k0s10s=; b=GenciCs1KbpWfp9FEyZDBduUj1HLKhlg1ErQLl HPTMV3pc36G1bPARoRzgVBknke+h6HxUbkAR/eWsfJeOUz48wM91GeU3+kylBRhy WVUaZJJ8OKVFOX6gaPQ6NBXuQUuserPcwm6lgseVxb3AuKc2qN1A0/eC9i6gADji +mjzS0zvOryC9ZoJU15BtlaCnOTR+L7a7FUPdtlE5E43QTfBSW0jZpHv/zlodvh7 2ang1oKOvs/+m4mkmB7k0AuLi3ptvgf78MN889XfhWYRkjEjSiNFkA1fOfKvgtu8 pPJrp1xK/rEwkIAv0TCyvkwwseCRyIzsBdIV8yInnAasDjhw== Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3wd563s2pc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 21 Feb 2024 14:18:42 -0800 (PST) Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-68fb5db2c3cso4873666d6.3 for ; Wed, 21 Feb 2024 14:18:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1708553921; x=1709158721; darn=lists.linux.dev; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=6uaf5HP/wTsxJA2qe3SmsVPx7DQ0neloAV4r1k0s10s=; b=PoidFLPR2UJWueDTgnubAuthkci0bjeJ0ZUpEhN1BiPd5eRT2N+2q5khPpsmfg+TTm 0TisACm9bMfj0aZo00YLV6aanSR1r3/x+bOWNZH7yMjID3OG8elUo8tsgmyu1HosgaWF 71U0foWboKi6tTLFRGVjBbnfNNqnT2L0C2ZekKC2bKdorWJua4v8y4AJ/6PbMCjFU70e cVyqlwxdo2SoQ27J+gZirF+MlkqwnqlKX2OLafEtGAz1FMznOuKzmnW3VIdJR24zWljt 9a3vcIAqZ7cYPJYZGNtk+kNqxQH/k8v9y/JFMgtqsbfJMIcHzp76U1KHntKbR0wVPcFl fYaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708553921; x=1709158721; h=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=6uaf5HP/wTsxJA2qe3SmsVPx7DQ0neloAV4r1k0s10s=; b=SS4oA4fVnDcpDnjrtdyMHjHR+2k1xv/hsiuRqvjeLpNu5gKKLngp9J1jBFVPUqfkc7 jKP4CfYtt3/mJ0cbJWQ+lXG+6zDvdsTr4ymUEKLzizN8+xD7Rg6Y9tu2cxCs9K96Y93A G4NE1uhXv16POOI63NladsI86DtMQN0fMZSYQcqvitkFj4UH5l8CzM5WcR4iday9H/Ja uRn6Wb4HOvsEXErwGLiX1j2dU3W6pncpfIc+x0JnAEZTyxpjd6V10FfzW0v/9g6wOcVv KkWRibM6dpH0+NptEHsm0/ttYH83Ao/pRwG+WLz9d1VuV15fl69veOs3hT9xSF9UM/BG B+JQ== X-Gm-Message-State: AOJu0Yw2vI+ytc9R8TL3XWoWRdeFTB+iuwiD35WewjhtjJ5ewnJTiXjV 1mXydZcsSZJ7S5vjc/pvNvGAAMNHsxbLgU9yVRpqno4ctZXvC4XxrN/qr6mfMKYx4uGC1ej8aLQ D3rVAAYNC0CreMnnaox3S6ZW72nRQu0M0wMc4j+OQEsQDVRuFrZTNX9pgN68lP1OIZbdt+1IacB PYPNg5CV8WOBq3EeqfPnX1RUshFRX85waPyQWDvczGNhXBDAk= X-Received: by 2002:a0c:f54d:0:b0:68f:a73a:11ae with SMTP id p13-20020a0cf54d000000b0068fa73a11aemr2318976qvm.20.1708553921307; Wed, 21 Feb 2024 14:18:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEI8RnhfFeWMW2fB8edaHaKZzP3kWAGzcXs/S+wtv6YNHozMMnMlOjJ0w0Ecuago5p6bpPBUw== X-Received: by 2002:a0c:f54d:0:b0:68f:a73a:11ae with SMTP id p13-20020a0cf54d000000b0068fa73a11aemr2318964qvm.20.1708553920961; Wed, 21 Feb 2024 14:18:40 -0800 (PST) Received: from localhost.localdomain ([140.177.180.84]) by smtp.gmail.com with ESMTPSA id pf2-20020a056214498200b0068f719ed978sm3841446qvb.33.2024.02.21.14.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 14:18:40 -0800 (PST) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH v2 3/6] qmimodem: Use l_idle for shutdown instead of g_timeout Date: Wed, 21 Feb 2024 22:17:22 +0000 Message-Id: <20240221221725.185480-3-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240221221725.185480-1-steve.schrock@getcruise.com> References: <20240221221725.185480-1-steve.schrock@getcruise.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: PNSOXqypdZkbKjsFVMZNhFWBnuZFVOoL X-Proofpoint-GUID: PNSOXqypdZkbKjsFVMZNhFWBnuZFVOoL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-21_09,2024-02-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 phishscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402210175 --- drivers/qmimodem/qmi.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 6880dc45..1e127d60 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -93,7 +93,7 @@ struct qmi_device_qmux { qmi_shutdown_func_t shutdown_func; void *shutdown_user_data; qmi_destroy_func_t shutdown_destroy; - guint shutdown_source; + struct l_idle *shutdown_idle; }; struct qmi_service { @@ -1551,24 +1551,24 @@ done: return res; } -static void qmux_shutdown_destroy(gpointer user_data) +static void qmux_shutdown_destroy(void *user_data) { struct qmi_device_qmux *qmux = user_data; if (qmux->shutdown_destroy) qmux->shutdown_destroy(qmux->shutdown_user_data); - qmux->shutdown_source = 0; + qmux->shutdown_idle = NULL; __qmi_device_shutdown_finished(&qmux->super); } -static gboolean qmux_shutdown_callback(gpointer user_data) +static void qmux_shutdown_callback(struct l_idle *idle, void *user_data) { struct qmi_device_qmux *qmux = user_data; if (qmux->super.release_users > 0) - return TRUE; + return; qmux->super.shutting_down = true; @@ -1577,7 +1577,7 @@ static gboolean qmux_shutdown_callback(gpointer user_data) qmux->super.shutting_down = false; - return FALSE; + l_idle_remove(qmux->shutdown_idle); } static int qmi_device_qmux_shutdown(struct qmi_device *device, @@ -1588,15 +1588,15 @@ static int qmi_device_qmux_shutdown(struct qmi_device *device, struct qmi_device_qmux *qmux = l_container_of(device, struct qmi_device_qmux, super); - if (qmux->shutdown_source > 0) + if (qmux->shutdown_idle) 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) + qmux->shutdown_idle = l_idle_create(qmux_shutdown_callback, qmux, + qmux_shutdown_destroy); + + if (!qmux->shutdown_idle) return -EIO; qmux->shutdown_func = func; @@ -1611,8 +1611,8 @@ 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); + if (qmux->shutdown_idle) + l_idle_remove(qmux->shutdown_idle); l_free(qmux->version_str); l_free(qmux); From patchwork Wed Feb 21 22:17:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13566557 Received: from mx0b-003ede02.pphosted.com (mx0b-003ede02.pphosted.com [205.220.181.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 13B36128824 for ; Wed, 21 Feb 2024 22:18:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.181.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553925; cv=none; b=WX1SW/ASO5PXfUuGQbMZG1Y0mGVLSFd6DSw19P3wwcu14hgVgFH07/nttyk6lXWN0HFz+sz0leQZO4E6kt3J1kXh7Rl3dIVC0CgemYPMHg2oHmn3W6sOcLCMIeHALGMinkosEs2gLLtimgUEH+RZWScWaNytdU1EO6N5ctQWYFM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553925; c=relaxed/simple; bh=7rMupqbjZo2smrVp9Ieq2o2Ks9e7fK7Ras6JrlA35bM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=XUHw+w+rAdM3euPNe6rVk8B4QTz08Ax4LCxHB5cNKgXCLdIEFhwOlukrSvUEoxAX7bM56aOBx/6jRHMniFksUkWQt5M+pRr87Yz9jOEpNBS8B+MSXXJPhp9zozSb+gv/ojxGiEfCMC074M494BJ8ejmmIa1asc6kwNHlen6ZRDQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=s3jdxMz2; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=HgEPSyq9; arc=none smtp.client-ip=205.220.181.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="s3jdxMz2"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="HgEPSyq9" Received: from pps.filterd (m0286618.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41LDYESv012239 for ; Wed, 21 Feb 2024 14:18:43 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=ppemail; bh=Z+mNW3XGjgcu9JVNKyEBni VJePhCanYiC3UkKoT5Lyg=; b=s3jdxMz2k+zWnyGMmNI65YsGDGXyRomkqMslzF cJflMeRhLWrmudFFnX7qHdga4N4OfsySX7JefKMVmx/BP9Y9YeNtgbLzt7nC1OD7 3ITyUKK/Zs/p+W6hsRpnsAmr3OuyRwG2gH7j0fF/HI6F1XIfV8VjRgNA3RsiaJez kTrzGwjaRLtuhNXxU86KHGoYSlV7KJ+WqTMBoPTL8lxuibLACKML0xfYBYRKxbKq dSnm4tvz6Lur3RAxGONyfI9GqvNisFh5hdcmo2y13hMOQfVwGdhdut1NwdTO+vRI 165ifTlTEZH2Jw0NbrngaTllnzyFPWhpKARfYG7baNMpE59A== Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3wd56392tw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 21 Feb 2024 14:18:42 -0800 (PST) Received: by mail-qv1-f71.google.com with SMTP id 6a1803df08f44-68f9e713a1cso16096746d6.3 for ; Wed, 21 Feb 2024 14:18:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1708553922; x=1709158722; darn=lists.linux.dev; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Z+mNW3XGjgcu9JVNKyEBniVJePhCanYiC3UkKoT5Lyg=; b=HgEPSyq9Yxg3L1tJLj1XirzRBi44Q1kC3ccAdTO/Mhxy3mzh2wPzzK8UtyDubBkgXR JdwkXwsuNxSgaG3B90KvAl0otaGjd+55iJxtMSP77x5Ta2lqcyHMBJ+HE39V8MwskauM jD6JBSuGFnAZeo6OI3XDIlIhDHFMsTnQjOnnTryc8q9UuWO30XQtivLy1zWovINgiMO8 RLlf+jJaFd+EVf/L7JhXVtclSIA/5nTKC7L5TywckST0y2OotscnhZXPxkLN76r7IeoW b3dqk8XHI559pAPpUgPPAdmP3AZk0wV8407as5vFzYic8kbqUXdDtzYam6M9eK8R3TLt /XPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708553922; x=1709158722; h=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=Z+mNW3XGjgcu9JVNKyEBniVJePhCanYiC3UkKoT5Lyg=; b=OE3PChlVrNKn8qUeAJXME92KDCCk5KqxFibVvWmV/RdG2Ru36ZLIkyUJq9N2Zc9phN Ua/7sDR/PZDEW9OJm8NrmX3Sx4hOQX+5nuobH6SHLoO2fAj1ippZfaCe1X/4PRMYJ09p wn7VTivc//xoM3O3QmbFxW9UDLOJfb4ZITxkajqaDkCMwtffvylx4+zfv6zsMSvrdJ8b jfr0eLngHTrgWZ+KlPX/T+KSzD2/fN/w5WKbJgyjLZxt34hPw/RhDUR2YbZwpI9PoX5S oEIKYBkMp6vDSjlUXAx77BVuTvYy4XKvD2AID3AtwEXVEMSbWos6C8FeaHAEwx224A1e 0eOg== X-Gm-Message-State: AOJu0YxU/7Jy4ZBGqwNPOFGhR7fERKRsUgNERG04nZow6U5PxDvSKoUF E6APc5SvmioGa9OeGYKNcwgJR8pFkDXoQgYuVYNm8X181kC5nptnErvZAHO4POOkYkAlCelNqwx 0YWoymByQioENsz4uFOsvGBZr1F6PlhoCRiooKqnQqlqKl0rGaj6Bg0fPUrTQwPD4SVWydDxQoY EI9iu59H15ErwMM6zHB0W7Nz+BGgpWCGub/zHXQkAJDIjFzrs= X-Received: by 2002:ad4:5cae:0:b0:68f:501c:ea3e with SMTP id q14-20020ad45cae000000b0068f501cea3emr19988230qvh.28.1708553921897; Wed, 21 Feb 2024 14:18:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4y8L+7Kf+XZY7X+6QbCCEg8XNwDPd/NfRTobn4+AQRTFgzVWLYQHri5Noksppk2MbNks+ng== X-Received: by 2002:ad4:5cae:0:b0:68f:501c:ea3e with SMTP id q14-20020ad45cae000000b0068f501cea3emr19988213qvh.28.1708553921539; Wed, 21 Feb 2024 14:18:41 -0800 (PST) Received: from localhost.localdomain ([140.177.180.84]) by smtp.gmail.com with ESMTPSA id pf2-20020a056214498200b0068f719ed978sm3841446qvb.33.2024.02.21.14.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 14:18:41 -0800 (PST) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH v2 4/6] qmimodem: Use l_idle and l_timeout for service creation Date: Wed, 21 Feb 2024 22:17:23 +0000 Message-Id: <20240221221725.185480-4-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240221221725.185480-1-steve.schrock@getcruise.com> References: <20240221221725.185480-1-steve.schrock@getcruise.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: fmuM6u3s_17-FipbxPp-nZKN_R0EUTLI X-Proofpoint-GUID: fmuM6u3s_17-FipbxPp-nZKN_R0EUTLI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-21_09,2024-02-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 lowpriorityscore=0 spamscore=0 clxscore=1015 impostorscore=0 malwarescore=0 mlxscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=930 adultscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402210175 --- drivers/qmimodem/qmi.c | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 1e127d60..150fd343 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -1930,7 +1930,7 @@ struct service_create_data { qmi_create_func_t func; void *user_data; qmi_destroy_func_t destroy; - guint timeout; + struct l_timeout *timeout; uint16_t tid; }; @@ -1938,10 +1938,8 @@ static void service_create_data_free(gpointer user_data) { struct service_create_data *data = user_data; - if (data->timeout) { - g_source_remove(data->timeout); - data->timeout = 0; - } + if (data->timeout) + l_timeout_remove(data->timeout); if (data->destroy) data->destroy(data->user_data); @@ -1956,19 +1954,18 @@ struct service_create_shared_data { qmi_create_func_t func; void *user_data; qmi_destroy_func_t destroy; - guint timeout; + struct l_idle *idle; }; -static gboolean service_create_shared_reply(gpointer user_data) +static void service_create_shared_reply(struct l_idle *idle, void *user_data) { struct service_create_shared_data *data = user_data; - data->timeout = 0; + l_idle_remove(data->idle); + data->idle = NULL; data->func(data->service, data->user_data); __qmi_device_discovery_complete(data->device, &data->super); - - return FALSE; } static void service_create_shared_pending_reply(struct qmi_device *device, @@ -1983,26 +1980,29 @@ static void service_create_shared_pending_reply(struct qmi_device *device, struct service_create_shared_data *shared_data = l->data; shared_data->service = qmi_service_ref(service); - shared_data->timeout = g_timeout_add( - 0, service_create_shared_reply, shared_data); + shared_data->idle = l_idle_create(service_create_shared_reply, + shared_data, NULL); } g_list_free(*shared); l_free(shared); } -static gboolean service_create_reply(gpointer user_data) +static void service_create_reply(struct l_timeout *timeout, void *user_data) { struct service_create_data *data = user_data; struct qmi_device *device = data->device; struct qmi_request *req; + DBG(""); + service_create_shared_pending_reply(device, data->type, NULL); /* remove request from queues */ req = find_control_request(device, data->tid); - data->timeout = 0; + l_timeout_remove(data->timeout); + data->timeout = NULL; if (data->func) data->func(NULL, data->user_data); @@ -2011,8 +2011,6 @@ static gboolean service_create_reply(gpointer user_data) if (req) __request_free(req); - - return FALSE; } static void service_create_callback(uint16_t message, uint16_t length, @@ -2115,7 +2113,7 @@ static bool service_create(struct qmi_device *device, service_create_callback, data); data->tid = __request_submit(device, req); - data->timeout = g_timeout_add_seconds(8, service_create_reply, data); + data->timeout = l_timeout_create(8, service_create_reply, data, NULL); __qmi_device_discovery_started(device, &data->super); @@ -2130,10 +2128,8 @@ static void service_create_shared_data_free(gpointer user_data) { struct service_create_shared_data *data = user_data; - if (data->timeout) { - g_source_remove(data->timeout); - data->timeout = 0; - } + if (data->idle) + l_idle_remove(data->idle); qmi_service_unref(data->service); @@ -2190,8 +2186,8 @@ bool qmi_service_create_shared(struct qmi_device *device, uint16_t type, if (!(type_val & 0x80000000)) { data->service = qmi_service_ref(service); - data->timeout = g_timeout_add( - 0, service_create_shared_reply, data); + data->idle = l_idle_create(service_create_shared_reply, + data, NULL); } else *l = g_list_prepend(*l, data); From patchwork Wed Feb 21 22:17:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13566559 Received: from mx0b-003ede02.pphosted.com (mx0b-003ede02.pphosted.com [205.220.181.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A63284A1D for ; Wed, 21 Feb 2024 22:18:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.181.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553927; cv=none; b=ZiwWg7EqMQLfkK6M8adFjlJSVdodLdhw/0p5SPIVzxpblyAQc265aSAwsOA3ciZaeXOD7DrqIAZ83as1zsvN0YS7qV+uUFOfOhbPpmzj1otGEksesGRSyicfd1rlDeH0GjnjVme23SDD5Qq+RA86BNF0iCZogX0xb0l9mHpuUvo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553927; c=relaxed/simple; bh=44uUTdUYrFFhoo2p/+W3DjT5KxVPP3UerMDQquKt+0E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=UJMokxJX4X4Bfy7PDr5a5XuyFkYQ+e62ZzGMKvUvqFgg80znI7WobIqyvvPL1keQtDLvWjt+xFbFqHxqYvwvkbQyyBpiOJEalY1QBUQhwwaWkqbodmvtb++jlcZiPv3Z9WXtFQsO3NLSLE2zrdWB13TF/yAvgL2ebJQLLnRjw2o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=JpWBDI/a; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=pWFtn0fS; arc=none smtp.client-ip=205.220.181.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="JpWBDI/a"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="pWFtn0fS" Received: from pps.filterd (m0286619.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41LEjNAc018898 for ; Wed, 21 Feb 2024 14:18:44 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=ppemail; bh=CzASE58b3pdGttu0/4S1tA SkjVB2JL9ItqfqsLJBfNE=; b=JpWBDI/aTa7QmbVUg+YDD+M8A8HxYb79Qj1i3L eF6eyvoJJ0Iv6s3FIJsMO53BzF94jTHf+lp+rFVzi8AvqUp60yMVF2iKUG71KUFe YcHyV0cYFcvHrg/BuFtlKbsnEUaZ5vnQcmBmqrUX+yC5yXqXD84cydcSSR+4Mzwk kgIDefOU0hKj1ATriww0thQxdYlSOMtLgem3fmQEz1cw6VKoi3qvoF309z6sshf/ PVo8SRIqpjMUv2hPZBmYGTYm5zShyBZEYeA47xZMEuqnStvUADYWUbFfFF+aPNEy XwRm7AGFSZKtoTEPm5/tLLXe8iTvxbxEVCcHgjXY03zidu6w== Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3wd563s2pd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 21 Feb 2024 14:18:44 -0800 (PST) Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-68f75058f07so14247156d6.0 for ; Wed, 21 Feb 2024 14:18:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1708553923; x=1709158723; darn=lists.linux.dev; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=CzASE58b3pdGttu0/4S1tASkjVB2JL9ItqfqsLJBfNE=; b=pWFtn0fS79dsUponW+8E++niKj52XcyMXy9BkciJf94rICaKXkO4UC+Eo5+L8WUL5B j/xtoIu9vlneCAdJ93/gh/iz/ISGrNlZXFfWCUJu+en5PeWE1azX/6Wv9FE7zzlL0qh9 i41lZ4RGmXUFPTKzUAW4dRqJhz/YefAUNhUGd1prSTQViwIpgn4EFL1jQds/clC/5g/N KzehIV9Fo2KW3+1RVzYCs8ab2a46giUbRzTqp0LZTiWDag4AUT/7i4XYPsYRbZbBBuZj ZRgrsAC6y2IX1MuvJ7MTVFE6PPUBj1RodPgkc1cSOG0dK0Q63mG3L2KzAVEP9lIHCOQX 74tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708553923; x=1709158723; h=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=CzASE58b3pdGttu0/4S1tASkjVB2JL9ItqfqsLJBfNE=; b=woTL6yzVV67yj5cGN9Phzy5h5udLyHqF0LOhrcxdR+RUml725vbrTpM9WteNsG2GFf fjiLk3DCp6dbV9vwKOZ4r+l4oV0WHQiojVNldVC44aLuLnaFjyyylnEPVikS8KC9JhXV VrXGppojM/KzZ6VMuK/VpcVkz/gT+BYUPJ/9cwkHq9ce9wabStI4snRcpwwVqtOCQ0xs UG2GFj0eIBccMSCtnQmX7uoyirIbbOAmi8Y5J7vbNwezXJxupl/NOJtcnTTGw5hrImmK KKxWoYP+U41rgHoTpHpitmEO0bcx4hSq9dWFEXyduNX0Mksk8UWmn+xTaJZQbLMM4UeK 75pQ== X-Gm-Message-State: AOJu0YzjaIHpzryrskOLJ4oby6VGJ1hlOAfzAIr3SWCRs95JD2l0AAlQ MKrYhuD+fmab+TpMwk8qCsf2JC1htW9tFZdVG79woywQIzq9iPUXHpNFOOKp+/55Y7JW+80cjSs 4MoCim6mwzkDgNSnwA9i0+pRur5LanO7WWOGsOkpt5AqrRLmhM+eVjUxZdNOyB1smE8DewYAggU um8hThufv5+k01Y+vxKWJhNhukovzG3WajOPvlD0YBqsM9nlM= X-Received: by 2002:a0c:db8f:0:b0:68f:8cc5:a26a with SMTP id m15-20020a0cdb8f000000b0068f8cc5a26amr5578115qvk.21.1708553923028; Wed, 21 Feb 2024 14:18:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IESJ17+YHwFjFWd6UzcGgQI2nvhUlNuDCnYTGFJup4S9h/wQgNNNBYpC8QHnzBnChMsvaFfSg== X-Received: by 2002:a0c:db8f:0:b0:68f:8cc5:a26a with SMTP id m15-20020a0cdb8f000000b0068f8cc5a26amr5578097qvk.21.1708553922559; Wed, 21 Feb 2024 14:18:42 -0800 (PST) Received: from localhost.localdomain ([140.177.180.84]) by smtp.gmail.com with ESMTPSA id pf2-20020a056214498200b0068f719ed978sm3841446qvb.33.2024.02.21.14.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 14:18:41 -0800 (PST) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH v2 5/6] qmimodem: Eliminate glib macros Date: Wed, 21 Feb 2024 22:17:24 +0000 Message-Id: <20240221221725.185480-5-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240221221725.185480-1-steve.schrock@getcruise.com> References: <20240221221725.185480-1-steve.schrock@getcruise.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: 4PzoEbzzp0tW0P3a5nQwP_JhKEezppOn X-Proofpoint-GUID: 4PzoEbzzp0tW0P3a5nQwP_JhKEezppOn X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-21_09,2024-02-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 phishscore=0 priorityscore=1501 malwarescore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 adultscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402210175 --- drivers/qmimodem/qmi.c | 100 ++++++++++++++++++++--------------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index 150fd343..ba6ae0d2 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -204,15 +204,15 @@ static struct qmi_request *__request_alloc(uint8_t service, hdr = req->buf; hdr->frame = 0x01; - hdr->length = GUINT16_TO_LE(req->len - 1); + hdr->length = L_CPU_TO_LE16(req->len - 1); hdr->flags = 0x00; hdr->service = service; hdr->client = client; msg = req->buf + QMI_MUX_HDR_SIZE + headroom; - msg->message = GUINT16_TO_LE(message); - msg->length = GUINT16_TO_LE(length); + msg->message = L_CPU_TO_LE16(message); + msg->length = L_CPU_TO_LE16(length); if (data && length > 0) memcpy(req->buf + QMI_MUX_HDR_SIZE + headroom + @@ -235,7 +235,7 @@ static void __request_free(void *data) static bool __request_compare(const void *a, const void *b) { const struct qmi_request *req = a; - uint16_t tid = GPOINTER_TO_UINT(b); + uint16_t tid = L_PTR_TO_UINT(b); return req->tid == tid; } @@ -261,7 +261,7 @@ static void __notify_free(gpointer data, gpointer user_data) static gint __notify_compare(gconstpointer a, gconstpointer b) { const struct qmi_notify *notify = a; - uint16_t id = GPOINTER_TO_UINT(b); + uint16_t id = L_PTR_TO_UINT(b); return notify->id - id; } @@ -278,7 +278,7 @@ static void __service_find_by_type(const void *key, void *value, struct service_find_by_type_data *data = user_data; /* ignore those that are in process of creation */ - if (GPOINTER_TO_UINT(key) & 0x80000000) + if (L_PTR_TO_UINT(key) & 0x80000000) return; if (service->type == data->type) @@ -515,13 +515,13 @@ static void __debug_msg(const char dir, const void *buf, size_t len, } str += sprintf(str, "%s msg=%d len=%d", type, - GUINT16_FROM_LE(msg->message), - GUINT16_FROM_LE(msg->length)); + L_LE16_TO_CPU(msg->message), + L_LE16_TO_CPU(msg->length)); str += sprintf(str, " [client=%d,type=%d,tid=%d,len=%d]", hdr->client, ctl->type, ctl->transaction, - GUINT16_FROM_LE(hdr->length)); + L_LE16_TO_CPU(hdr->length)); } else { const struct qmi_service_hdr *srv; const char *type; @@ -547,13 +547,13 @@ static void __debug_msg(const char dir, const void *buf, size_t len, } str += sprintf(str, "%s msg=%d len=%d", type, - GUINT16_FROM_LE(msg->message), - GUINT16_FROM_LE(msg->length)); + L_LE16_TO_CPU(msg->message), + L_LE16_TO_CPU(msg->length)); str += sprintf(str, " [client=%d,type=%d,tid=%d,len=%d]", hdr->client, srv->type, - GUINT16_FROM_LE(srv->transaction), - GUINT16_FROM_LE(hdr->length)); + L_LE16_TO_CPU(srv->transaction), + L_LE16_TO_CPU(hdr->length)); } function(strbuf, user_data); @@ -565,14 +565,14 @@ static void __debug_msg(const char dir, const void *buf, size_t len, str += sprintf(str, " "); offset = 0; - while (offset + QMI_TLV_HDR_SIZE < GUINT16_FROM_LE(msg->length)) { + while (offset + QMI_TLV_HDR_SIZE < L_LE16_TO_CPU(msg->length)) { const struct qmi_tlv_hdr *tlv = ptr + offset; - uint16_t tlv_length = GUINT16_FROM_LE(tlv->length); + uint16_t tlv_length = L_LE16_TO_CPU(tlv->length); if (tlv->type == 0x02 && tlv_length == QMI_RESULT_CODE_SIZE) { const struct qmi_result_code *result = ptr + offset + QMI_TLV_HDR_SIZE; - uint16_t error = GUINT16_FROM_LE(result->error); + uint16_t error = L_LE16_TO_CPU(result->error); const char *error_str; error_str = __error_to_string(error); @@ -716,7 +716,7 @@ static void service_notify(const void *key, void *value, void *user_data) GList *list; /* ignore those that are in process of creation */ - if (GPOINTER_TO_UINT(key) & 0x80000000) + if (L_PTR_TO_UINT(key) & 0x80000000) return; for (list = g_list_first(service->notify_list); list; @@ -754,7 +754,7 @@ static void handle_indication(struct qmi_device *device, hash_id = service_type | (client_id << 8); service = l_hashmap_lookup(device->service_list, - GUINT_TO_POINTER(hash_id)); + L_UINT_TO_PTR(hash_id)); if (!service) return; @@ -780,8 +780,8 @@ static void handle_packet(struct qmi_device *device, msg = buf + QMI_CONTROL_HDR_SIZE; - message = GUINT16_FROM_LE(msg->message); - length = GUINT16_FROM_LE(msg->length); + message = L_LE16_TO_CPU(msg->message); + length = L_LE16_TO_CPU(msg->length); data = buf + QMI_CONTROL_HDR_SIZE + QMI_MESSAGE_HDR_SIZE; @@ -795,7 +795,7 @@ static void handle_packet(struct qmi_device *device, req = l_queue_remove_if(device->control_queue, __request_compare, - GUINT_TO_POINTER(tid)); + L_UINT_TO_PTR(tid)); } else { const struct qmi_service_hdr *service = buf; const struct qmi_message_hdr *msg; @@ -803,12 +803,12 @@ static void handle_packet(struct qmi_device *device, msg = buf + QMI_SERVICE_HDR_SIZE; - message = GUINT16_FROM_LE(msg->message); - length = GUINT16_FROM_LE(msg->length); + message = L_LE16_TO_CPU(msg->message); + length = L_LE16_TO_CPU(msg->length); data = buf + QMI_SERVICE_HDR_SIZE + QMI_MESSAGE_HDR_SIZE; - tid = GUINT16_FROM_LE(service->transaction); + tid = L_LE16_TO_CPU(service->transaction); if (service->type == 0x04) { handle_indication(device, hdr->service, hdr->client, @@ -818,7 +818,7 @@ static void handle_packet(struct qmi_device *device, req = l_queue_remove_if(device->service_queue, __request_compare, - GUINT_TO_POINTER(tid)); + L_UINT_TO_PTR(tid)); } if (!req) @@ -864,7 +864,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond, if (hdr->frame != 0x01 || hdr->flags != 0x80) break; - len = GUINT16_FROM_LE(hdr->length) + 1; + len = L_LE16_TO_CPU(hdr->length) + 1; /* Check that packet size matches frame size */ if (bytes_read - offset < len) @@ -1027,7 +1027,7 @@ void qmi_result_print_tlvs(struct qmi_result *result) while (len > QMI_TLV_HDR_SIZE) { const struct qmi_tlv_hdr *tlv = ptr; - uint16_t tlv_length = GUINT16_FROM_LE(tlv->length); + uint16_t tlv_length = L_LE16_TO_CPU(tlv->length); DBG("tlv: 0x%02x len 0x%04x", tlv->type, tlv->length); @@ -1044,7 +1044,7 @@ static const void *tlv_get(const void *data, uint16_t size, while (len > QMI_TLV_HDR_SIZE) { const struct qmi_tlv_hdr *tlv = ptr; - uint16_t tlv_length = GUINT16_FROM_LE(tlv->length); + uint16_t tlv_length = L_LE16_TO_CPU(tlv->length); if (tlv->type == type) { if (length) @@ -1185,9 +1185,9 @@ static void discover_callback(uint16_t message, uint16_t length, for (i = 0; i < service_list->count; i++) { uint16_t major = - GUINT16_FROM_LE(service_list->services[i].major); + L_LE16_TO_CPU(service_list->services[i].major); uint16_t minor = - GUINT16_FROM_LE(service_list->services[i].minor); + L_LE16_TO_CPU(service_list->services[i].minor); uint8_t type = service_list->services[i].type; const char *name = __service_type_to_string(type); @@ -1244,12 +1244,12 @@ static struct qmi_request *find_control_request(struct qmi_device *device, if (_tid != 0) { req = l_queue_remove_if(device->req_queue, __request_compare, - GUINT_TO_POINTER(_tid)); + L_UINT_TO_PTR(_tid)); if (!req) req = l_queue_remove_if(device->control_queue, __request_compare, - GUINT_TO_POINTER(_tid)); + L_UINT_TO_PTR(_tid)); } return req; @@ -1423,7 +1423,7 @@ static char *get_device_interface(struct qmi_device *device) file_name = basename(file_path); - for (i = 0; i < G_N_ELEMENTS(driver_names) && !interface; i++) { + for (i = 0; i < L_ARRAY_SIZE(driver_names) && !interface; i++) { gchar *sysfs_path; sysfs_path = l_strdup_printf("/sys/class/%s/%s/device/net/", @@ -1687,7 +1687,7 @@ bool qmi_param_append(struct qmi_param *param, uint8_t type, tlv = ptr + param->length; tlv->type = type; - tlv->length = GUINT16_TO_LE(length); + tlv->length = L_CPU_TO_LE16(length); memcpy(tlv->value, data, length); param->data = ptr; @@ -1851,7 +1851,7 @@ bool qmi_result_get_int16(struct qmi_result *result, uint8_t type, memcpy(&tmp, ptr, 2); if (value) - *value = GINT16_FROM_LE(tmp); + *value = L_LE16_TO_CPU(tmp); return true; } @@ -1872,7 +1872,7 @@ bool qmi_result_get_uint16(struct qmi_result *result, uint8_t type, memcpy(&tmp, ptr, 2); if (value) - *value = GUINT16_FROM_LE(tmp); + *value = L_LE16_TO_CPU(tmp); return true; } @@ -1894,7 +1894,7 @@ bool qmi_result_get_uint32(struct qmi_result *result, uint8_t type, memcpy(&tmp, ptr, 4); if (value) - *value = GUINT32_FROM_LE(tmp); + *value = L_LE32_TO_CPU(tmp); return true; } @@ -1916,7 +1916,7 @@ bool qmi_result_get_uint64(struct qmi_result *result, uint8_t type, memcpy(&tmp, ptr, 8); if (value) - *value = GUINT64_FROM_LE(tmp); + *value = L_LE64_TO_CPU(tmp); return true; } @@ -1972,7 +1972,7 @@ static void service_create_shared_pending_reply(struct qmi_device *device, unsigned int type, struct qmi_service *service) { - gpointer key = GUINT_TO_POINTER(type | 0x80000000); + gpointer key = L_UINT_TO_PTR(type | 0x80000000); GList **shared = l_hashmap_remove(device->service_list, key); GList *l; @@ -2058,7 +2058,7 @@ static void service_create_callback(uint16_t message, uint16_t length, hash_id = service->type | (service->client_id << 8); - l_hashmap_replace(device->service_list, GUINT_TO_POINTER(hash_id), + l_hashmap_replace(device->service_list, L_UINT_TO_PTR(hash_id), service, (void **) &old_service); if (old_service) @@ -2119,7 +2119,7 @@ static bool service_create(struct qmi_device *device, /* Mark service creation as pending */ l_hashmap_insert(device->service_list, - GUINT_TO_POINTER(type_val | 0x80000000), shared); + L_UINT_TO_PTR(type_val | 0x80000000), shared); return true; } @@ -2154,7 +2154,7 @@ bool qmi_service_create_shared(struct qmi_device *device, uint16_t type, return false; l = l_hashmap_lookup(device->service_list, - GUINT_TO_POINTER(type_val | 0x80000000)); + L_UINT_TO_PTR(type_val | 0x80000000)); if (!l) { /* @@ -2249,7 +2249,7 @@ void qmi_service_unref(struct qmi_service *service) hash_id = service->type | (service->client_id << 8); l_hashmap_remove(service->device->service_list, - GUINT_TO_POINTER(hash_id)); + L_UINT_TO_PTR(hash_id)); service->device->release_users++; @@ -2313,8 +2313,8 @@ static void service_send_callback(uint16_t message, uint16_t length, if (len != QMI_RESULT_CODE_SIZE) goto done; - result.result = GUINT16_FROM_LE(result_code->result); - result.error = GUINT16_FROM_LE(result_code->error); + result.result = L_LE16_TO_CPU(result_code->result); + result.error = L_LE16_TO_CPU(result_code->error); done: if (data->func) @@ -2379,11 +2379,11 @@ bool qmi_service_cancel(struct qmi_service *service, uint16_t id) return false; req = l_queue_remove_if(device->req_queue, __request_compare, - GUINT_TO_POINTER(tid)); + L_UINT_TO_PTR(tid)); if (!req) { req = l_queue_remove_if(device->service_queue, __request_compare, - GUINT_TO_POINTER(tid)); + L_UINT_TO_PTR(tid)); if (!req) return false; } @@ -2398,7 +2398,7 @@ bool qmi_service_cancel(struct qmi_service *service, uint16_t id) static bool remove_req_if_match(void *data, void *user_data) { struct qmi_request *req = data; - uint8_t client = GPOINTER_TO_UINT(user_data); + uint8_t client = L_PTR_TO_UINT(user_data); if (!req->client || req->client != client) return false; @@ -2412,7 +2412,7 @@ static bool remove_req_if_match(void *data, void *user_data) static void remove_client(struct l_queue *queue, uint8_t client) { l_queue_foreach_remove(queue, remove_req_if_match, - GUINT_TO_POINTER(client)); + L_UINT_TO_PTR(client)); } bool qmi_service_cancel_all(struct qmi_service *service) @@ -2470,7 +2470,7 @@ bool qmi_service_unregister(struct qmi_service *service, uint16_t id) return false; list = g_list_find_custom(service->notify_list, - GUINT_TO_POINTER(nid), __notify_compare); + L_UINT_TO_PTR(nid), __notify_compare); if (!list) return false; From patchwork Wed Feb 21 22:17:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Schrock X-Patchwork-Id: 13566558 Received: from mx0a-003ede02.pphosted.com (mx0a-003ede02.pphosted.com [205.220.169.153]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6E5EA12880F for ; Wed, 21 Feb 2024 22:18:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.169.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553926; cv=none; b=LCfsjXxW7x+d+3lY6hsJykHjLHlOCAVv/7M++CB6DScDq0KXR11d/zTEcBXKQg4FJJTLCyz23S9Q8QrNT04VGqN/92VPU7OmfId0k3PhCeieWkC9znz0SgUsG9FT7NBCQnnBtBoRKAclT/G0hDcFOAqO1pw4aRTSQSfD8pQL40s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708553926; c=relaxed/simple; bh=eaNxKsskYzRAojtR6WaTxgx7bBipa3Q3nIGXaWh482c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=TrZdoIGn62vRDbtADsXuiiEfqRmE0ULugGy8E2L/BITHPXa93NfogPycQMiw41LwZxslUVvpWuDXeKcYYTP6UP8QQM1CtDhVtUyF3tNyBTP9CSnjlEFGBT8AamDJh0fq+j/ys1quX3HWsfOu/JQq0YmWsRiHsmN9VgAqXK2qFoI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com; spf=pass smtp.mailfrom=getcruise.com; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=nTGJvu9v; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b=bo1Zn34M; arc=none smtp.client-ip=205.220.169.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=getcruise.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=getcruise.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="nTGJvu9v"; dkim=pass (2048-bit key) header.d=getcruise.com header.i=@getcruise.com header.b="bo1Zn34M" Received: from pps.filterd (m0286617.ppops.net [127.0.0.1]) by mx0b-003ede02.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41LFBwOB031935 for ; Wed, 21 Feb 2024 14:18:44 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=ppemail; bh=+jkFU4CPOL9gXqUUldK/2c sDbrDYut4XoKncxGKTOw8=; b=nTGJvu9vr17N6bDWG90gZcPGkwPHnK3Zqqm8Bx HG11fcTKvwdqXJ3dsFXbyk2vr4SnRd+s4PhZSTsxPej59vLJuFeMXXZDzFXlXqJj DSDwT66b0xEkTDYpuUYFNmJDNWDLPQr/R+65fxdAHax7karrA2qIZtqBDajV0FVX DBivWUDlB8g/tAIZskfS8s35or+WphM5I/D/vt59S+hpXjTuJSpIGJZCwV6tTa0C 3uQCTVh8TS45f/3+5v/0PgHVaLgSEJ8ybyuYAaH6FnTPYVyG64vHcmCHyLgGDSL6 alNaVoLbMtSFqkDN4tDrzlX7/syX+Nd/JgN2W//iRPmwf/+A== Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) by mx0b-003ede02.pphosted.com (PPS) with ESMTPS id 3wd56492hg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 21 Feb 2024 14:18:44 -0800 (PST) Received: by mail-oi1-f198.google.com with SMTP id 5614622812f47-3c13e65b3c1so1374931b6e.1 for ; Wed, 21 Feb 2024 14:18:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=getcruise.com; s=google; t=1708553923; x=1709158723; darn=lists.linux.dev; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=+jkFU4CPOL9gXqUUldK/2csDbrDYut4XoKncxGKTOw8=; b=bo1Zn34MhfZvuclaC0h+i419coYK76KeqcNJj5SLAZ4FcXlRONEFEomFZbHut6XKtv 3UtF1158/Nd1YGon0FK3woYADSuFtS94BByHgwMx1o4hC6lDHhdjRcsZSmoeqqQMJmuQ P42DVpto0qUd584YU4X/p6tQzlgehg+wmFLZNO21AEik/fB358YBO9EGjVjK6Z0n28us ktEJ9k3o4GosMjhDBlC8M28SXS+aL/xMLtIS4/vijcNLCilRR+AIW8ajnm/FxGGXDopk tu0ku8s2pwO9Mo2mllYumxJL5/QNLxuGVm37Vqt8lGyIwQxibkkGGlfuwGLIDNKtvde7 xhAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708553923; x=1709158723; h=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=+jkFU4CPOL9gXqUUldK/2csDbrDYut4XoKncxGKTOw8=; b=aWE6aJ3FFWSpnuPHznSlNzjJmqVHQv7LuTJe43UECkTxPAK0JRWYCNk5NFebBktsF/ 31bF67/+DfMIa7NmU1QN5dcjdsQC64f5Bc2+75Q8CDEsg8F2U4H8cazwr/Vp7DmAhy5P JOkY1RL+sJHtmClp/k5uAx9QT/Q6A2hPdVvPaU+xsqwzTQSBMULeL0cH/DTmMmj12M+e p5j737ROLBT3YCkCizeyn6G/2Gdh0ZLQkCtKEbl3YpK957vpvYpEoGWqtZBJECwQP2gH yRsVkK8n3UwI3qcx+FW3D7Oi5bm4zKxz/hSyDGFsr5pT2sfCiHZ003bpSoMiKbdAHpDN oo5w== X-Gm-Message-State: AOJu0Yy88b7QLYYLmCuYYiHghvE7FjAAZ00L/eTk6g5xc7B6XC4d9GeR RVBX5r9IQOVjSQgDmx7sJLejKvnS89CIJ8dJsjtXCGqmXdsXl7+O5mGfQADHWUKNoAW3dmdNrdZ 2ZjyZ6PPuEGcZZyr5oQsN2e03RRsR5tH8EtPZ0SFTAxapSrE/1FBmZM1sfbb3BAu/jJ7CmY8HT/ SqgSn8D68tJ8+ip3cAFkPlUZ5Ff/knvGzUmVbsAFM1b8Iqi90= X-Received: by 2002:a05:6808:144c:b0:3c1:5bf8:a66a with SMTP id x12-20020a056808144c00b003c15bf8a66amr10914747oiv.47.1708553923472; Wed, 21 Feb 2024 14:18:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5zSSw2m9dOvIaEJlIPHMW8lbEXYVFhGPKzDXByt3VRZyWVA4e63q+NdZR0lT6bIMhyXhqjQ== X-Received: by 2002:a05:6808:144c:b0:3c1:5bf8:a66a with SMTP id x12-20020a056808144c00b003c15bf8a66amr10914731oiv.47.1708553923033; Wed, 21 Feb 2024 14:18:43 -0800 (PST) Received: from localhost.localdomain ([140.177.180.84]) by smtp.gmail.com with ESMTPSA id pf2-20020a056214498200b0068f719ed978sm3841446qvb.33.2024.02.21.14.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 14:18:42 -0800 (PST) From: Steve Schrock To: ofono@lists.linux.dev Cc: Steve Schrock Subject: [PATCH v2 6/6] qmimodem: Use l_free in qmi_free for consistency Date: Wed, 21 Feb 2024 22:17:25 +0000 Message-Id: <20240221221725.185480-6-steve.schrock@getcruise.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240221221725.185480-1-steve.schrock@getcruise.com> References: <20240221221725.185480-1-steve.schrock@getcruise.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Proofpoint-GUID: OOASp4fy6UZORApApXDU1r1QkX3XjW8n X-Proofpoint-ORIG-GUID: OOASp4fy6UZORApApXDU1r1QkX3XjW8n X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-21_09,2024-02-21_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 bulkscore=0 adultscore=0 phishscore=0 malwarescore=0 mlxlogscore=878 spamscore=0 mlxscore=0 lowpriorityscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402210175 Eliminate the final gchar* as well. --- drivers/qmimodem/qmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/qmimodem/qmi.c b/drivers/qmimodem/qmi.c index ba6ae0d2..52a8e57c 100644 --- a/drivers/qmimodem/qmi.c +++ b/drivers/qmimodem/qmi.c @@ -174,7 +174,7 @@ struct qmi_tlv_hdr { void qmi_free(void *ptr) { - free(ptr); + l_free(ptr); } static struct qmi_request *__request_alloc(uint8_t service, @@ -1424,7 +1424,7 @@ static char *get_device_interface(struct qmi_device *device) file_name = basename(file_path); for (i = 0; i < L_ARRAY_SIZE(driver_names) && !interface; i++) { - gchar *sysfs_path; + char *sysfs_path; sysfs_path = l_strdup_printf("/sys/class/%s/%s/device/net/", driver_names[i], file_name); @@ -1813,7 +1813,7 @@ char *qmi_result_get_string(struct qmi_result *result, uint8_t type) if (!ptr) return NULL; - return strndup(ptr, len); + return l_strndup(ptr, len); } bool qmi_result_get_uint8(struct qmi_result *result, uint8_t type,