From patchwork Sun Jun 2 23:24:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13683133 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 7ADF4C27C44 for ; Sun, 2 Jun 2024 23:25:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :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=EEPxZiMEFGRAgMMrTT93BvhD6EuxiyJJX+or4fgq7x0=; b=NSf1UycZ5hMAg5 SiGCMo5itsKAO1mIxMKCHdMYEoboLwPIOjxUFly+tSF6Pl56wFgC+Y04TqrpxQwPvx9y/q0+05Chs UpZXOuM4Dd5uKnCh3yErvHsw5PV9gw7H66u9/4YUdzCRmSUrNcekfC7IGIWaUQnxx8gCHX8yM6AUr 5uPm6i2Wt4y64h5N/0qqTV/NufiIwr+XB5PMM6meLzhH9GBvsnCOWlKKvYwG3gL88T9t8+d02TkNF PB9cNmHlYptAUT5uF/pbksykEct/nNkafQYFWVrTq2aqVxOFtOpGPZg3vJY+NWt6cQsHxQtHaifI5 tkQt7IOn5dDIW3PA7HXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDuZb-0000000F691-0v6r; Sun, 02 Jun 2024 23:25:11 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sDuZS-0000000F63n-24Cr for linux-arm-kernel@lists.infradead.org; Sun, 02 Jun 2024 23:25:05 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52b7ffd9f6eso3446564e87.3 for ; Sun, 02 Jun 2024 16:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717370700; x=1717975500; 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=uMHRLla4ILsm5OyTHPffYpll4rFbwg7rZ0xiqfrtlAk=; b=R+Pe/aiNNhwmT7VtXRTFwhS0Yv+CKGR3g85RtJ+eDth/cAF2EzYwuvY2W384MjtFAX iGP6uu/fE51NaADuCjyb5uQA24NKCKZ5bCtAyUj9sUlaKJiRw3Hn5xr+A2xJTfDdenEi KAIVzaykQTGmYSiZa8ok7e3CjYIS++Z7p6tHlWnb98WmJlaVwp2u+qQabbkPFOxnpWZF vTjveXY40eSz3VHya7me6WMEXiJjyLwAmtUDgq1OPo7wEbIGaqpbeEwtTiEGJy5HakU8 VBKCQeA+xodQl5sVJbxeDZwnV9I4rat64FS7I0NtM41CQkdxXqikbw4/CPS0NG3Sjpy8 3qhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717370700; x=1717975500; 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=uMHRLla4ILsm5OyTHPffYpll4rFbwg7rZ0xiqfrtlAk=; b=LqEkVywk0D+DuQOiGB2bOIekIoQiAz+rhjBA+LeI7y8bgGN+P5ijrqPLBYCrF/6TEw O8XJ5rDNHuuPlgQjkXWsn+xvFgWHGRSYnTZc3THnIbWOpuMOSiuppzA4t7mnAFS9wS/r OfzdMrI6A1O4x2QZVbMZI4QH9neG4+jmgQF4ddsAZF7bfEnPL9NZvQ2aRoVsWFMf113Z nJ3edvEo4ep/YgKX6WVhl9iYgtbydQRIBUeDcsIYytUd7ik6R249CCyAFq39XrNamvoV QSWR9Yq3OO9S009mD94PRmot95ZHTyPEMphtKSwdKSf1PUf9h0zFhI8rLxRcx+lyI2rv BXoA== X-Forwarded-Encrypted: i=1; AJvYcCUK6UtN0nYJ0Y4mX8LIf6uEtMxvoMicskVHeaJjoGkqIUdl7uLLI8/obtpSfIfaaCka2SV5tjC/KglOJIRROv5POGzZbywwzFJ2Bl+5o7VT8IfqIYU= X-Gm-Message-State: AOJu0Ywlhv3fyAAwcCEiMf+IY+tme4e+miajT9uxfqOexYWt1PW/AwPm qtaDvOh8QDptV3AmUM6HJuWjFq0z1iDeEEZR0Z2E/Pk51KbjWv/Z2DqGfMtZYlQ= X-Google-Smtp-Source: AGHT+IEinySEY+8mUF5JebFptkGUEBHH1p6v8JTLm5BkjmrOYM/dSR6lKjEU8RJ2VRVXxIay7X04zA== X-Received: by 2002:ac2:5927:0:b0:523:b19a:2602 with SMTP id 2adb3069b0e04-52b896c1583mr4583720e87.54.1717370700174; Sun, 02 Jun 2024 16:25:00 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52b959008aasm392369e87.269.2024.06.02.16.24.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 16:24:59 -0700 (PDT) From: Dmitry Baryshkov Date: Mon, 03 Jun 2024 02:24:58 +0300 Subject: [PATCH RFC 5/7] usb: typec: ucsi: inline ucsi_read_message_in MIME-Version: 1.0 Message-Id: <20240603-ucsi-rework-interface-v1-5-99a6d544cec8@linaro.org> References: <20240603-ucsi-rework-interface-v1-0-99a6d544cec8@linaro.org> In-Reply-To: <20240603-ucsi-rework-interface-v1-0-99a6d544cec8@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=mrPf66+/PzNa3/0SVv6o28YNwb3VM608GVeFzUihyTU=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmXP9HAufR5oVjQ0LWVWAxSmYfDH5vS6wJiYuZ1 dHGzcQ447iJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZlz/RwAKCRCLPIo+Aiko 1WYeB/9JZcDHr+OF40i0unPYw6KFSmRQ5469nPCT2YTGknUhZXQSaNZ5MjbUZg7XLCeUYccokgJ y5EPZdDTaWFO+eXLDilcoFpoNzbs4Kowo86yEfvPVm2YzydiXpGCkvHSnQcEskFxHbUnI0wEQSt zspOCM051maHPSZLoGtbJ6mt/sZ8KJiTBfc0iQi+XER2c5/lwFA0rcfEXQXEfqECNWB8tn7HF52 W23c3lkftFGNTtNSGwh46VWLlcJQ00eVChhByC4oPoyqS+taGwm4IM5ROUGdRbI8RhVxx7BcVF7 mLr41IHkns9dAUC5Ut/0i3z9vQBkNOX6Jz1pOI6DlKLYaPg3 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-20240602_162502_723872_04D306D9 X-CRM114-Status: GOOD ( 12.72 ) 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 54a2c505442f..ac4bd86b3fae 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; }