From patchwork Tue Jun 25 14:54:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 13711303 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 9903CC2BBCA for ; Tue, 25 Jun 2024 14:55:16 +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=Cd2X10zVjMn+EpTL9h3lm0rs/LnmaQV9sjYCW3W4aNs=; b=0TECDB3jvHJdJr7NTErVgJIwKF RVo+BXY+S6FyQqL5PaVIU5Y7CFXK/Hk6EjXeB7cHgjg8WKEr0iWPwYeNQG4w5399lZPsUhA4u6CvP G+xm8Mr2oR0N0JybByCzdnHBoMbKVHTJjD6ZKhSiPbHptsbIfpDXvDISjhiCep+H541fEDHoKz0Yh EsA2EFV7wGf9WH1K7KQOVySLM2Vnq6G9eLvBeAjzkiP9L7nRx6hxFtngm/IG/nT72SCHSUui46/o5 PeJNv8Evx3JI0lZrga4uqCLrCACV8SALaCyvmBQtbn7s+rOqdwp0kpYMV+ceaXnuCJ7d3J8geZ/2m j4Aom2hQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM7ZX-00000003HDW-1RK9; Tue, 25 Jun 2024 14:55:03 +0000 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sM7Z6-00000003GxS-1ubN for linux-arm-kernel@lists.infradead.org; Tue, 25 Jun 2024 14:54:38 +0000 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-52cd628f21cso4817287e87.3 for ; Tue, 25 Jun 2024 07:54:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719327274; x=1719932074; 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=Cd2X10zVjMn+EpTL9h3lm0rs/LnmaQV9sjYCW3W4aNs=; b=WOyPKZc+VITF8v4fujdzys4GzXudp9w2WWoynqNuYnIQrdrsPXkfC+8TvP8kmaZRUt TLzTJUImMaXDP6jUWkYGZRQQxJZs3sxhK2OWZXNOZiHosHhxvKBJ2zkVXt7aWNi48HGg Wt1vgUC5UEJiLqwUwAeyudd7GMtBdQDgFOlhkpiX0gl1ty269xHpSb+P1c74MUZxuO8b O47VA8ZpalrjOwOmKY1YqP2X+xhr3uA689s8+rCOvb26jufdqZ/TIl1UyZ5Bv6LwIjvo aOxIg5en76QJyYoSMjTBqd0t59NOX3coNlQeyO9/34wigqFIdWHpsItKUr85O8CTSG8L JT9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719327274; x=1719932074; 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=Cd2X10zVjMn+EpTL9h3lm0rs/LnmaQV9sjYCW3W4aNs=; b=n7z9YvyTgmYhZWjNOMZt08K4+mndRUcoxLVvjM1i/S3NvKgOevNOE4JWiR4mTGtbuJ FDVEiBPPPQ1wR+5CQY2AtaZvUzmk23HegNM2PE8O2HvYroHA/9SH/b54Ih2+Mja/uh+B pUEMsNUcUOcAXOrLxwWHrlq+DucWxOAyPk+tQsNqkJ2YfkNwm7Goc3KjhJe8EMLTfiDY EAXhDetXI/7EIml4QJ4SzZjPCOFeKADms1ARbsqXPJbOnyADrDKxelHktFLAqj1Rss9X 4zu88a8vfcPSXb5PgN0GykmUDNbddhF5AWkLoc+X/I02sKh6vuGLviJuQDYjR9xgsDx7 5wYQ== X-Forwarded-Encrypted: i=1; AJvYcCWk1SqMdupZN8gEY/xFowpClLe7C/kLsr4q+NdkQIlZfqgYPQumL7kH37DSByA0Aj45pS4wFri3XcnWznIJ3ztQwQAozBjozlnb8tCS2NFhvAy0JxY= X-Gm-Message-State: AOJu0YwQRqH2sIlmZIDeDwlVe4eQ2c8pOWYHEEW6I4ZrX9cAJ0DN/j7D ZdECCPn98JefhabGuckwj6oBf0NzhYgVp3Q4eaOJ9qGYrBBm+KyZYO87WwBtpuc= X-Google-Smtp-Source: AGHT+IFBU/FqlV1rlHFm7VcDP7TI1En+d6tYg9faOguYFxQeaenBL0P/drueNcNZbM5bdmNqJCDT6w== X-Received: by 2002:a05:6512:2394:b0:52c:d84c:1182 with SMTP id 2adb3069b0e04-52ce1862c12mr5311099e87.64.1719327274126; Tue, 25 Jun 2024 07:54:34 -0700 (PDT) Received: from umbar.lan ([192.130.178.91]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52cd64328b7sm1251877e87.221.2024.06.25.07.54.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jun 2024 07:54:33 -0700 (PDT) From: Dmitry Baryshkov Date: Tue, 25 Jun 2024 17:54:30 +0300 Subject: [PATCH v3 5/7] usb: typec: ucsi: inline ucsi_read_message_in MIME-Version: 1.0 Message-Id: <20240625-ucsi-rework-interface-v3-5-7a6c8e17be3a@linaro.org> References: <20240625-ucsi-rework-interface-v3-0-7a6c8e17be3a@linaro.org> In-Reply-To: <20240625-ucsi-rework-interface-v3-0-7a6c8e17be3a@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=mI5j32lGmh9mGgx/qR0lTHll3MYLBaGs+ozW531l430=; b=owEBbQGS/pANAwAKAYs8ij4CKSjVAcsmYgBmetojhmAknU4eETQ/0OVEnR93dwpzXwqv4zv11 DBDhLbs1XGJATMEAAEKAB0WIQRMcISVXLJjVvC4lX+LPIo+Aiko1QUCZnraIwAKCRCLPIo+Aiko 1Zv3B/9UujGkolgkJQLF8DrUxTo7LuRVr+QOZJVWx5Y+Qqj2Vrktn20TdD10r17dEMR4lI7w1VC UMrX64IlrvWdR72wijPKPH6uafW5wUnCh3PNSBQgh+/03iBS8LwLJHaACH8JzISR8VnV8dh6Cya Xn2x+c9iwslIG6VPuSj+cxfyP1RPp+XY24Um3N7VOqS9MpeuJ54FtBQ9SwcEq/lf33MRf/+Vxv+ WwdlSitm/UoP2YJG99Fmg4nhaSNFDyyuKOvwrwC8TVZlSnhgehx4ekDRPW/4pQEtyC2R6/PNpN5 9FXIu8GWZ1DIn1Pb30kNSGbmuqxjMWkVwcYgoe6MFIjYwGMf 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-20240625_075436_539502_2C7BB442 X-CRM114-Status: GOOD ( 13.17 ) 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 5f8e5ed9e0f9..e14366e20cd5 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; }