Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1807858pxb; Mon, 8 Mar 2021 06:57:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1LUASVYeImscYjVLGGiZYOyOYTp2uHM49MkFi0W6g5Ncsql/l0HpsSOA7LYJxJZd2ag/e X-Received: by 2002:aa7:d94c:: with SMTP id l12mr21584741eds.311.1615215431721; Mon, 08 Mar 2021 06:57:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615215431; cv=none; d=google.com; s=arc-20160816; b=FxSnubj/tkIEoENXksGvdX1e2IdevLqhph6m9PPY8F4ed2RhYaUz63jIrTtI3pIM2t OLaryzdkLaKaC9LXW1uOGgnivQ8Pty6hT0AVU8ZDAFCOYnX7fntT/5wm45bsS1FWVF/l v3ur9+IGze+AMobcHfTYuD2eEHHHWRkDs335/GG+VAVfhQ/FvrXg1y/DBphM1bKLRWFx Hm5f3/vk2K1Kn9cB1spCjXVvidwGrFTiQ9KnwcvNyIA5rsO/KL/t3RCOuLmUobngYTnx 72teyZTwvN2RLNWjte+nXjtMQJ+lx4HHyMarPJvNpDk1r+TF4N+90+t+iMEp1ndzj55i 12Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Io9v2GBIlHI+Tmp+Muo2ozOuxnB5JlN/m/peVkSOoQk=; b=AgafGnIRs+fFhnxfj7QUCWrDkQpgf6AMoutBCFf1MjUSPqWs2VGYLUv7zQc/awiTsK 52CFz42SpAXdUR9W0IRIM+5fbWnh4a40Ji0KJayDncSXxXYP2q8309aoRD9QjzzK31ln QWcNfBko4dfEdu2gHTaXpmnbZiX3ReatZ0x5BfsKWeJ6hikwWYjPuWHX8GacdLK+2Cim U+SZxsG0QLrd4RykoMwryT2JRG0lipolIIU2Xujfdxi0+x2I1Ef1yedSPgdM7pJAqtFJ ip9uNEN805wMYpMxZorhJO5XVcQUZp7dq1blk25VTu3x8UBhlYGtLc+yhKuSl527iLJ8 BiYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=KN8oqTz0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p14si1189066ejc.493.2021.03.08.06.56.48; Mon, 08 Mar 2021 06:57:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@deviqon.com header.s=google header.b=KN8oqTz0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=deviqon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231520AbhCHOzr (ORCPT + 99 others); Mon, 8 Mar 2021 09:55:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230511AbhCHOzf (ORCPT ); Mon, 8 Mar 2021 09:55:35 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09CC1C06174A for ; Mon, 8 Mar 2021 06:55:35 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id w9so15066346edt.13 for ; Mon, 08 Mar 2021 06:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=deviqon.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Io9v2GBIlHI+Tmp+Muo2ozOuxnB5JlN/m/peVkSOoQk=; b=KN8oqTz03n4iXKtuJ5qi9J7eiFCSjzNROABDY6Gb/MplICzu3i5V03YptgmpTTumx9 qzHGrgq8fs8JGet9Odv3isiqA2BAEwaSruGVQmS9a+mZpNXFpeE4VcGYKpq2SjITIXEr iZu8cMKqFXc0GNaf9S/tP3IfDJqMyEWVlwbxUYbisZoe8tFawpRpLzcdVzwhbtNF+qfh oh5qVIsYJBFymQreVC72K8pfrXlBDUp9vpAjjD5DhQNe9vKsYc0LarvZp9YPPAvTNQ6k bUkDxp4231M2aHh4lz1mTKmik9470JWb/d4AGTx8NT+lMZyzE4h4Q/QHCx3Q8heZ+6Wu Pn4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Io9v2GBIlHI+Tmp+Muo2ozOuxnB5JlN/m/peVkSOoQk=; b=TKZptO9o9Dkx62IXzim91fUlfXF/g7Ev1mIOZp+4yyoZZrhZXU3v39tmnhUl+F86XJ cpP5AV+3g8ixxXjn2NrvE7Kvyu543tKbRpMA+/Fr9iowG0C7U+pV8eaNhnAJhODfiU+Y XrKfoQzHNV/9cWTevuJE/Okodq6lIryTr9/cF3knwJXGO+wStgxGVNxylEm5OzgZDbnr YLJrJYjRLS0xmXmJg6nc92D7njaH+TG9z8E8JjrE8bevOE3B4JGDnq5DUatxNzn0xPAO u7YWLF7AqaK+iiikC2PHsjmvJPpTW5PwXtGnVMgLOkJBCuqHgosaM1BCHsTBGE/nkFxM isaw== X-Gm-Message-State: AOAM531pC4e+pY46HHGpuHmwsFTMWsI+YVIRkrrwblx9iozWkKgr9ogT j3ocOrbOOFH2tzjI8APUOIIcgAVV8aAQyyuZ X-Received: by 2002:a05:6402:2076:: with SMTP id bd22mr22161922edb.378.1615215333831; Mon, 08 Mar 2021 06:55:33 -0800 (PST) Received: from localhost.localdomain ([5.2.193.191]) by smtp.gmail.com with ESMTPSA id bt14sm7411234edb.92.2021.03.08.06.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Mar 2021 06:55:33 -0800 (PST) From: Alexandru Ardelean To: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, greybus-dev@lists.linaro.org, devel@driverdev.osuosl.org, linux-tegra@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com Cc: broonie@kernel.org, gregkh@linuxfoundation.org, elder@kernel.org, johan@kernel.org, vireshk@kernel.org, rmfrfs@gmail.com, f.fainelli@gmail.com, ldewangan@nvidia.com, thierry.reding@gmail.com, jonathanh@nvidia.com, linux@deviqon.com, Alexandru Ardelean Subject: [PATCH 06/10] staging: greybus: spilib: use 'spi_delay_to_ns' for getting xfer delay Date: Mon, 8 Mar 2021 16:54:58 +0200 Message-Id: <20210308145502.1075689-7-aardelean@deviqon.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210308145502.1075689-1-aardelean@deviqon.com> References: <20210308145502.1075689-1-aardelean@deviqon.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The intent is the removal of the 'delay_usecs' field from the spi_transfer struct, as there is a 'delay' field that does the same thing. The spi_delay_to_ns() can be used to get the transfer delay. It works by using the 'delay_usecs' field first (if it is non-zero), and finally uses the 'delay' field. Since the 'delay_usecs' field is going away, this change makes use of the spi_delay_to_ns() function. This also means dividing the return value of the function by 1000, to convert it to microseconds. To prevent any potential faults when converting to microseconds and since the result of spi_delay_to_ns() is int, the delay is being computed in 32 bits and then clamped between 0 & U16_MAX. Signed-off-by: Alexandru Ardelean --- drivers/staging/greybus/spilib.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/greybus/spilib.c b/drivers/staging/greybus/spilib.c index 672d540d3365..30655153df6a 100644 --- a/drivers/staging/greybus/spilib.c +++ b/drivers/staging/greybus/spilib.c @@ -245,6 +245,7 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi, /* Fill in the transfers array */ xfer = spi->first_xfer; while (msg->state != GB_SPI_STATE_OP_DONE) { + int xfer_delay; if (xfer == spi->last_xfer) xfer_len = spi->last_xfer_size; else @@ -259,7 +260,9 @@ static struct gb_operation *gb_spi_operation_create(struct gb_spilib *spi, gb_xfer->speed_hz = cpu_to_le32(xfer->speed_hz); gb_xfer->len = cpu_to_le32(xfer_len); - gb_xfer->delay_usecs = cpu_to_le16(xfer->delay_usecs); + xfer_delay = spi_delay_to_ns(&xfer->delay, xfer) / 1000; + xfer_delay = clamp_t(u16, xfer_delay, 0, U16_MAX); + gb_xfer->delay_usecs = cpu_to_le16(xfer_delay); gb_xfer->cs_change = xfer->cs_change; gb_xfer->bits_per_word = xfer->bits_per_word; -- 2.29.2