Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp656686lqj; Sun, 2 Jun 2024 16:26:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUSGqf9TD7M13gEsf9nT/k3je1tPH6YxqHiCmwG2/QEQWEu37tqt0DOhInV6x1nQBoCT2j9PLjQTO4ELL9KjLYcgsHHFZivPlzXvBUWKQ== X-Google-Smtp-Source: AGHT+IGApyvf/l/pUooMD7cQ7iVKJoe6ccAsclxQfLLsjRe2Qm/zmuBjaEczhKlawoyGxOAERg6X X-Received: by 2002:a05:6402:2313:b0:56e:743:d4d9 with SMTP id 4fb4d7f45d1cf-57a364acf15mr3841541a12.42.1717370767934; Sun, 02 Jun 2024 16:26:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717370767; cv=pass; d=google.com; s=arc-20160816; b=0060jTFTgGTbmAMMsZRIq/LcSFjCxZ6zotm8JKyEPYYpMwivGvrj6gOgvNsKTjp+X3 3FPOs2ldSeb+jATcsKSYdJhrxiwt3Y59PwkFork8xJotwQ+Pcri83UOUHwxYe54a2qvF pYj70k0NK6NeAcLntTXib9TeiZFOWNtfnNAl1wTLCtO/OirjVkXMvO3T4EUIdtiqtW+g YyWCaVVU/zDwExuqms+Y4wwUxjUGJNZ/AMmfEjogNBbzvbObTiVax2Y8EWDLaO7lbstx VxafKmj3oTshoWXddTGLXqjcMWsMFiUQSJKuVs/FJ/TtveYjQrg9YgAysrMbCuUQ4nq3 fZfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=uMHRLla4ILsm5OyTHPffYpll4rFbwg7rZ0xiqfrtlAk=; fh=s8v5M51SUUxFIEgPXvx5TTtscoyjO3Su0JAPfGAENLo=; b=XrUvi8wMd+GI+2wt8LitJ7nAkflmiEdFnlgEiYzEbUG31lKeSbypKs+4lu9nhSD+5x bpMfttZ6s79QCDkgzHRoeN4NZWuAHZ25QKCTNOJQxmilPrNiKKds645XWg29pRY/9HIZ +zHNeNE9m6scU+3i+0rJWj5j5bioLB4GJsSU1q1ze6o6l+iP1kp3S2NR1eXyXY4Px16+ I4weZj928FAqugFiMsi3m32ukQcZJnzUXcy8z726ZRjV0widtvrJCHYAuF+ag2VfGCMu +7IpD2cUsERydbOW4/S2aY24h4chb9lQvsyxH7lv+VUhP2K2xo2LU84SIgwCZYAYDa9r RaVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HVHJWEv2; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-198479-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198479-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31c77799si3452284a12.451.2024.06.02.16.26.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jun 2024 16:26:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-198479-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HVHJWEv2; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-198479-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-198479-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A158F1F2170F for ; Sun, 2 Jun 2024 23:26:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2055982D8E; Sun, 2 Jun 2024 23:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="HVHJWEv2" Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5BD3C76EEA for ; Sun, 2 Jun 2024 23:25:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717370704; cv=none; b=GRGtvgAesUanAzRiJwtZonM5e8tYDRppsEzExq7ajqHkROHHxjgw9/13Wq80F0clCWBjkGdeiMSN++0WfZnX7idoMYHLfTV834QdLsnqAgk2eB3w/A88DqT1K/BGvPbgiOiks5gaqqNwJ7a381nsy70E7SmS7Ap44TKg9Y/w+Zg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717370704; c=relaxed/simple; bh=mrPf66+/PzNa3/0SVv6o28YNwb3VM608GVeFzUihyTU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j4PZgrZWpCDlwBnSLo8jk2cHcfhaV3dgOP/Fv8ubi2/LO24AuY6RJdehe5nUB8yjrPZWQDgZ/vHmWkiax8EPki15j3+VpD+T6KRAV0Eu23+JKPs0UdrnKp8Hhj+/o1HMinh0hm+HHwrmO2KfmZcrZ5HU/GfA4KhWFzRrggqEWI8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=HVHJWEv2; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-52b90038cf7so2059017e87.0 for ; Sun, 02 Jun 2024 16:25:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717370700; x=1717975500; darn=vger.kernel.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=HVHJWEv2axhMKd+BoNtPVeJxdLSDif/oNCAiZ5+mTslXnZFi2kOYzL4FTtPFDamuAc 7t3OqVYVe4cipdQFnOaJh7ZFDBGsa3EoKLpjw2V+xjErUDDfL1p1bs6OePhxCTzGtM46 w1iyKoDlOlyYMrTehTS+gosrCQPnq+6B7C/yRRsz/zRk2ywWPsk4/Aze+8Tm7hB+RkGw LK2hX0uPljt1rO03BflpZyT86E3RMBhBuTjnqz41oH6E+eR0FR8LhJRZCfGhh5yM5o+7 yxclsFUhSkFyriTQmzafQtJC2Bnq6EMAPYAgw7WljqgcCkCwHuqxti0FXrXBVvuktVI+ cbOg== 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=KMdFQhaCwGCt1xc4acJbCUkEKqEiyjwJ9HPlZUCDY5AFg6X56CTT5tbzouevB5XRkQ JT0j5GVwKxYQ06OB4KK2e4Tbm9UJeDwN+JAqVp2PmPOF0YxgLsQN57lwEMQKO+CWNbd9 Ip5Au99RJ0Xsgi+hP59UCdE7Dt0pl+lpxKttnvune4gwnK9jpFPqLBZJu5DRJiIddKwa aQuzXYZqs1Q7RfD1DBhDbNVxwCvtD6QNzd6JKJ3vMzimcCy6OBoXlAifNETEEHWorCbU +tqhqdCfL1C60elhtio4BLeZ+qnUykdGahQ1XQgq7U0ExFOfMxIukmUihwQGtWEwOXYn yq6g== X-Forwarded-Encrypted: i=1; AJvYcCXWJrVUpBulqs9mAKgG9aHLt788Qtm/bquEmkj5ZTjsLmSYC4fR/M7YwPJIaxyrotVvgMz0dBdBxrWiPhwctOVMi5HiYDnbLaZC6lm8 X-Gm-Message-State: AOJu0YwDJmKw0d+rxxcG8PIXlnNGjAfA2EICfQl4BAwB84gXCAboJQKs jsUYAOYmJDks0blOxs48+bIvWP8xQgdXV5pLCbo0tg116w6xPqgtyE07KcvVLAeYLJD2SsKCvKK j 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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; } -- 2.39.2