Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2532311pxb; Tue, 9 Mar 2021 05:07:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5MAG/HfcuyD/qPMaQ0iOJ1mhoos9m47EogO6GmlKtrVk0EuaXpS+gQrrcjY3maV3tSkbd X-Received: by 2002:a05:6402:1004:: with SMTP id c4mr4039656edu.364.1615295224188; Tue, 09 Mar 2021 05:07:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615295224; cv=none; d=google.com; s=arc-20160816; b=UKq7hM+kyaJZqlOMsjwYIqElG652Iu6BMFy3Iz/6n3l3MrlVE8uOvAonnD4rk6rv6P f+aLrJw7+7mCLHauvDsBrbLNsn1IOVt/JyaDRhJit2UcsXFLPC5DOMlc/cM7tRNypRdC R1CsCYtqfwVZvnt4V9RnHsj4yT3XdndNo5N8Jfbfn/u7eB7J0FzuD2A3UVdrjMDM0XF2 7z2T19J8iGUKTq8J2LJNviB6jug42U7qk4L6QaSltpohKTDQluKQLJLIjM7689w4Ir2o qLVYQ/vEp0ECsVytvk4NOM7oV7I9hh6VpJYSQyYYTxb1pw8WAArAOhhFoAnL5V+IwqJY ZJiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gxiGmQiVGKebLQlJ6WSCV/8AQx+C5uUXod4pu8uxAOQ=; b=GmCBZ3zYFvJR5jhmvQ8rzZhFpr/7FhyprB+t3EjhtaH8nwj25u/Me31HYHVGE3c7BZ r/X9Wb0wmbZjEhIaxQGwnclx7GZYlc6KwJlwk2tnOHrpm9N3iNMuQDftomky0JcRHNbp tbrYhgL/F6Tj5ciAWimVn6MaodDG0qr+4ESpJh+KGtECcasHSlGmus68+xy8aCIE+P+m BhNEa0i+2h5+lOf4ZgK6aFNt560leEzN1qPa+ZepZbA6VB8H1Ff2wiqNpbwtmnzwcgki bOHI8iDvVArEBLDXdNXyggXpK95fQMaravObCLHDHY17abtPdyguHg5EuAVj4k1F286Q uw8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wJBItVNZ; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t12si9281072eds.41.2021.03.09.05.06.40; Tue, 09 Mar 2021 05:07:04 -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=@linuxfoundation.org header.s=korg header.b=wJBItVNZ; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230512AbhCINFn (ORCPT + 99 others); Tue, 9 Mar 2021 08:05:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:41200 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbhCINFN (ORCPT ); Tue, 9 Mar 2021 08:05:13 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 809C765272; Tue, 9 Mar 2021 13:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615295113; bh=BJBJpVVoiY6gCZUtVubIMzNfBlkVauLEWMwsKwElL1w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wJBItVNZ/Rf6BYqvp1pv4sAaOBG4icG+Nv+1x6/ql225wtv8ohchgyPJN4ynowY3o CbW9B8MKlE/kTa5LY89OlfLifaAqEw7k3iGQzFpUqyBCSO9dID2k2qXYTrsYyDEOG5 i5qlF1Ivyl+rJIiDa9hCmmiUbcm7+AScmVMmAHU4= Date: Tue, 9 Mar 2021 14:05:10 +0100 From: Greg KH To: Alexandru Ardelean Cc: 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, thierry.reding@gmail.com, elder@kernel.org, johan@kernel.org, jonathanh@nvidia.com, broonie@kernel.org, ldewangan@nvidia.com, vireshk@kernel.org, f.fainelli@gmail.com, linux@deviqon.com Subject: Re: [PATCH 06/10] staging: greybus: spilib: use 'spi_delay_to_ns' for getting xfer delay Message-ID: References: <20210308145502.1075689-1-aardelean@deviqon.com> <20210308145502.1075689-7-aardelean@deviqon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210308145502.1075689-7-aardelean@deviqon.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 08, 2021 at 04:54:58PM +0200, Alexandru Ardelean wrote: > 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; > Acked-by: Greg Kroah-Hartman