From patchwork Thu Jun 27 14:44:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13714507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5CB45C2BD09 for ; Thu, 27 Jun 2024 14:45:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=efQFGr6jGBKjwmMdwj9cOaioErJGFDxQ/6GTKiEu6I8=; b=1xE2/GGcK8oXQcjODA/B4idDRO 0+nA9tckKPYCI647JVbhP5l/bMHTrrNs4x7+4WBcWhq5bvw88d67mnnQu58zO0Cm2xs60k/iRftKF frSdAvSMXsjCGvtsCh43FfcUdp4l+/c+El8bm6J82NF/Xm4FKqsxkwKwkdEmCjG017rYxx7pJAbN9 9515uzLqDFGoMEKRPUQWksa2QvKgRAqrIr/j6LwZZYTWlqwnlOSkq7e9vbi1mdKgl/yf3ArpccOSZ /CckPo788xEWJGBaHSpoABZgjIXJ2M5ZQ+Y3cj6SSJkWBri/oUr7ylL9zM86fsSAXvctOzUT838ml Vw0w4SrQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMqN8-0000000AgUF-1MAL; Thu, 27 Jun 2024 14:45:14 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMqMo-0000000AgLs-2y4o for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 14:44:57 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2ec4eefbaf1so73419821fa.1 for ; Thu, 27 Jun 2024 07:44:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719499487; x=1720104287; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=efQFGr6jGBKjwmMdwj9cOaioErJGFDxQ/6GTKiEu6I8=; b=LjJ2Yto5cdZX6tEGLzTmPHV9do1IHytzTrV2IOe5TlgPdZPvkVQVuJ6jP9yqseCPmB iOrI9sfE1DD+U7NPRorq1sGZd1go7lwBO/a1FotSl3tzSIZIB53iJZsLF8VauXRWovI1 965GVzRyy8gMKqhduRR4GBZrD/HFI4zmATdYqI1nkHoZFSQm9hepQT8SAsJLwCXC1XLZ tnK9qOwV0X0BgonMM6Soj7S1OK4700UJe17Xv2hG33hfzVsz1DVxULdGsCdnZ5N/s+UE 5JILhoexxqvAIhkKJQmjgTCezo/J2/OPVoa+C2aQ6Z8OVrc56Z+QxjQ1svRmfLMjYLrJ eoUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719499487; x=1720104287; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=efQFGr6jGBKjwmMdwj9cOaioErJGFDxQ/6GTKiEu6I8=; b=AL9l5rY61zgMOxUJouy7IX5tYoQSkE9P7at2c4U02CpqHC19vm0zJg+ggb0WvMjfXe T/ptMmldsex8/6i0qfS0jLj0bNg8grKnph5FxWVUM/yg683XmZ4urw144/RYkaLRpaiX Rq/lR3HUKNAjJN/9eG3Kfsq13Yl2EZFzuQkIOJl3HWzMP7mdCT1pplNT2y0bz87s9ysv qTvlSILeznk7NGlca9rIl44wwEnZYR3I7yIUCflKKbWwJ66oSpsyfAnrOURBJxXLaLbZ M6YeoghbGMjngtBWjX/tkr5Uu5TpvD+DQow5QBaRCrDFCunWrUUO0bWJapYjViSRQt3m 5XAg== X-Forwarded-Encrypted: i=1; AJvYcCV+oegXTjLXCjGofDLYNKpMTYHGTfKYjRSMmbfSd7UF2qPAotm4GSuF2WzRL87PIt495AJ3M0d+ncDbTK6Bi2Knilj6hZeLxUb/8gdkf7JfSV7PuR0= X-Gm-Message-State: AOJu0Yy2wBMJXXBgi6BaBtxW5QnDxAlbXUVJslXzOuvIzNJybT+8IeIe HP0qaMbuB20kOLtr1uq+PpAMyYJo670p2Wi5enzZYp+qE0u4VCD23hZjAk0hEdM= X-Google-Smtp-Source: AGHT+IEEpm4AxqCI4MvWw10l4nicg9YGmxodxCLh1opitXtQr+B6jBW4EVR2xxnMzOMkHx2ZA4GduA== X-Received: by 2002:a2e:9e96:0:b0:2ec:588d:7eb8 with SMTP id 38308e7fff4ca-2ec5b37a303mr79821721fa.21.1719499487664; Thu, 27 Jun 2024 07:44:47 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ee4a34447fsm2775911fa.11.2024.06.27.07.44.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 07:44:47 -0700 (PDT) From: Dmitry Baryshkov Date: Thu, 27 Jun 2024 17:44:44 +0300 Subject: [PATCH v4 5/7] usb: typec: ucsi: inline ucsi_read_message_in MIME-Version: 1.0 Message-Id: <20240627-ucsi-rework-interface-v4-5-289ddc6874c7@linaro.org> References: <20240627-ucsi-rework-interface-v4-0-289ddc6874c7@linaro.org> In-Reply-To: <20240627-ucsi-rework-interface-v4-0-289ddc6874c7@linaro.org> To: Heikki Krogerus , Greg Kroah-Hartman , Maxime Coquelin , Alexandre Torgue Cc: Nikita Travkin , Neil Armstrong , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1732; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=SvL4pINrFSRfen69Stj/4WrpwjGf+jKWJ5TFSri6EH8=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmfXrZIK3sNxYmewLsvSN+DxSJY8UC0w0Xoamap /iSt4ILkayJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZn162QAKCRCLPIo+Aiko 1TewB/0eEGE2cnF0wQ2wiEEsma6QExZ1Yav41XkW8NpVgs9JLW96sutdqzAxS5BpJsP1PoyaRCD lVRCv4c2T2eHdMrZRGrTExG691TNA1w2rDx/gDgFf7lEdxtOwgxSmsxk+CZrGAP00z9k5kHoWNY Vl0IFKa8sP3qSpbB0wkrpjQtK2vRBUgU4B8WqycBSdLOhQ+exl7xVKHjc0No1McFtSOU7arST9a zqlmROo8rQ3p1nZ3ASP///xGQKpo21+K1ATF8ekM5/kHEdhrW88lVnMrvqP88SBLbPnauJG13pH e5DyIzX3Lb9EIQqQgnWEHAhv8mFDrOhGm+yKzc1znzn2VMcp X-Developer-Key: i=dmitry.baryshkov@linaro.org; a=openpgp; fpr=8F88381DD5C873E4AE487DA5199BF1243632046A X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_074454_790404_FA63FF73 X-CRM114-Status: GOOD ( 12.58 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is no need to have a separate wrapper for reading MESSAGE_IN data, inline it to ucsi_run_command(). Tested-by: Heikki Krogerus Reviewed-by: Heikki Krogerus Signed-off-by: Dmitry Baryshkov --- drivers/usb/typec/ucsi/ucsi.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 10a8fe893333..2d87fe277c62 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -36,19 +36,6 @@ */ #define UCSI_SWAP_TIMEOUT_MS 5000 -static int ucsi_read_message_in(struct ucsi *ucsi, void *buf, - size_t buf_size) -{ - /* - * Below UCSI 2.0, MESSAGE_IN was limited to 16 bytes. Truncate the - * reads here. - */ - if (ucsi->version <= UCSI_VERSION_1_2) - buf_size = clamp(buf_size, 0, 16); - - return ucsi->ops->read_message_in(ucsi, buf, buf_size); -} - static int ucsi_acknowledge(struct ucsi *ucsi, bool conn_ack) { u64 ctrl; @@ -70,6 +57,13 @@ static int ucsi_run_command(struct ucsi *ucsi, u64 command, u32 *cci, *cci = 0; + /* + * Below UCSI 2.0, MESSAGE_IN was limited to 16 bytes. Truncate the + * reads here. + */ + if (ucsi->version <= UCSI_VERSION_1_2) + size = clamp(size, 0, 16); + ret = ucsi->ops->sync_control(ucsi, command); if (ret) return ret; @@ -98,7 +92,7 @@ static int ucsi_run_command(struct ucsi *ucsi, u64 command, u32 *cci, } if (data) { - ret = ucsi_read_message_in(ucsi, data, size); + ret = ucsi->ops->read_message_in(ucsi, data, size); if (ret) return ret; }