From patchwork Thu Jun 20 22:55:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13706467 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 8ED37C2BA18 for ; Thu, 20 Jun 2024 22:55:46 +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=EQohNPpaTb5KYVE0BZu3/ef4lat3R4WjEfszMMJQNKU=; b=EsIRho2kjnw75fNofCC3EQdjiU OGtCECh436I37eHGaq0886od0LutNdhLUCg1n2+V88WrpcrwQ7jzII/KtJ9o5C7EQ6ZIyeQHTh4f/ dt+2TPnf7DaYBdvSjO3RyMLeykCIz5PbRjljiz7Q/kYma8RWikn4+YZnzdTg+um3zD9Mvqofg2VFW Wz6FQYMvLkG9TDr7wGdAqY11UpChoDi70sYoFsYRm4xY/K+SSplz00xTENzhIMw8/7bWykAAYtQq4 LyUksW4L3vVYmUZXM1Js+KY1INUNxzBilLTsDgh7XaA+laLoxA5Zv4bBx31ljygQsb5x77KMO8arD Jb53nI0w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKQgp-000000070pM-0iWk; Thu, 20 Jun 2024 22:55:35 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sKQgi-000000070j8-3kxV for linux-arm-kernel@lists.infradead.org; Thu, 20 Jun 2024 22:55:30 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2ebe40673e8so14239601fa.3 for ; Thu, 20 Jun 2024 15:55:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718924126; x=1719528926; 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=EQohNPpaTb5KYVE0BZu3/ef4lat3R4WjEfszMMJQNKU=; b=O9xcIxMyw7oCI6yt1IYf7n1zEmle15nKtIApZabUtsEP8LRz2fqEyTNUjlfBQJ75Cr 9LcZ3AoN1vaWzcvd6AyCR93oVX/u/oF3O+OhiyN8Ns5XX4kdaC1eXFW7P+UbRPpEw6fW oBEHoZAuYgCAdXaW2ZQLrsYZVPG2kirFNm627RVi0ULe+u3RkoNDx3m/jOzmLohwVXp+ p4a5MytBmjbnXTHFoaOenjcGz2/8yBa9ftt7oIm+QsOzM0YvFDZY+RhH7g0NH5rLpCFw M8GnRA+ZJx3qifGFbbWNH77CU8XJ+0UfKI06hLMbPekaHXSQTq7R0556Pwccy1r6mZjs hftA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718924126; x=1719528926; 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=EQohNPpaTb5KYVE0BZu3/ef4lat3R4WjEfszMMJQNKU=; b=geLx2m72cxqGBbMzHGm3lPmUY84f5e4u5Z9jrN3WrUhaQlfpnf/N4zeuuFw4yAd7Lw 6kJ0uF4xP2DZafmcN0tLP5TJYaIUxikjZfB13VDKItc0fpR/pGKr/yh5YjzFOsuPuOie z6x3cnY85I9YK1iG7Igt/fjQT/xjfx9hcKDqC2lGg57PR7m2Xtbm+IyV9Szd5c46Z2MK 6mtQWrxWEuHMuo9Jmo+oTVKK1VqXl8lwzK98dXEquaQQcmQgh+u5OK6ckdBJBaLDqSEz ByDTGAO30Om+XL3D669tOb0cnqHftOKoYXNwgwZU7zR2IaSle84qgDk+prR4wMRLmaG1 5SFQ== X-Forwarded-Encrypted: i=1; AJvYcCWKWUPi1MA8CS1afDcCc75Na5HceYZuQDoLUg+/obrO3100CnPgDiZ7qkkDy6xpv4yRFYq8OgNOAtKA/5tUI00M3jLx2vsCWqhvXXvZDW8OMISLlOg= X-Gm-Message-State: AOJu0YxcBshoRJQrKIsKwF/Mkjr0wQRRxESG8LF7rVqXl3EUORg+Pjbp 4f1Szva1Czmo+MKMLaD17CohZ/3dZRFuCNxvF8x9bleQaB/15ZEdqKfbfE9Moek= X-Google-Smtp-Source: AGHT+IHiX4zKNBalbolTrJjjqJsWAjc1/tOmVInlXcwDg2oe43Um4+0q1bXe0brVi/wRnLVylxIuGA== X-Received: by 2002:a2e:9e16:0:b0:2ea:e98e:4399 with SMTP id 38308e7fff4ca-2ec3cfd74b1mr42903741fa.36.1718924126551; Thu, 20 Jun 2024 15:55:26 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2ec4d60126fsm510461fa.20.2024.06.20.15.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 15:55:26 -0700 (PDT) From: Dmitry Baryshkov Date: Fri, 21 Jun 2024 01:55:24 +0300 Subject: [PATCH v2 5/7] usb: typec: ucsi: inline ucsi_read_message_in MIME-Version: 1.0 Message-Id: <20240621-ucsi-rework-interface-v2-5-a399ff96bf88@linaro.org> References: <20240621-ucsi-rework-interface-v2-0-a399ff96bf88@linaro.org> In-Reply-To: <20240621-ucsi-rework-interface-v2-0-a399ff96bf88@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=1606; i=dmitry.baryshkov@linaro.org; h=from:subject:message-id; bh=5JJ0FuTmJ51m3GFnw66fokeLW92y7ep22LnE63sLqV4=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmdLNaDofb3amsRcu0qvjDc9UZGAvmIhod3B7mD g3oylyO/0iJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZnSzWgAKCRCLPIo+Aiko 1QtNCACdBMXW0rp0duCVy1o696WTIt9Z8/8Fok4J2crdv8mHpLp/GVcEY0Ukoxe3RlnwPD/5UVu kxoogwkMVQAh4Dr1qvYAFY/Kte2dVgLzhY1tvMt+mBGza88/7dXk0fuXBKuqQooTBylLFIV/j3l LOozQbRYT9JrdTJ7epm7qs1OjKBfmG9qrKZ5hIf2Y6mhXA43e40xiBqBY+fwfjpWaJn+uUQTcpe jMIL3J/BU7/NkWKmtt9ADgm+4sxLJaPHfAwIAJQA5sMmD0kssmK79YxPf6lZNt3mI8OYZUkNC67 Luoqk+ml0bImb8JxFgJ+JbQXLrTnXwVtQgWJD25MA+/Nbgkv 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-20240620_155529_207532_07AC2B52 X-CRM114-Status: GOOD ( 12.73 ) 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(). 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 58d9602bd752..4ba22323dbf9 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; }