Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3747955pxb; Fri, 11 Feb 2022 06:59:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcCKdgfNXAR1v+O2jnlC7mZT1JiwyhtaBd+R62iANbs9sR/ZFgt9nDtnXosis4Mwr60vax X-Received: by 2002:a17:90b:4d12:: with SMTP id mw18mr759380pjb.71.1644591582556; Fri, 11 Feb 2022 06:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644591582; cv=none; d=google.com; s=arc-20160816; b=CaPHOaAtlegACGc8wMLB+/P8X32CrIHl0D78GXNIN8ACe5dfV7lMd+ikzP6mxKApa8 5t9owa/N0rJILQEguHeOj0EDYEoLI3rxsi0w88M7tQdj9CM+SRi2dTSEs2unMHlPC6Je XFuL/CmkJKV2NLCvWFvb5jo8tkEizkd+ZGG/kVyIqwMVB7/BrrsCL3j20KBKutL8FcKP 2gvknRLYWIZGr4as+E9oi5oaQn8Z7m3F91lJHfxHvEylW6eA8BQUwFLzPqTjns1MJJvG Oor0a7uwvvMCcBQHKYbpiEkwWqtQl3/aEY5Sm2BAAeysgU7tlqz0EzxycJJY3LJkaW47 NQBA== 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=i10oTXJRcxxYaSiDQuyv5xjzf7gowf5iGdfAWAPAWUM=; b=BKT85ft/UF8hy23IspDEPxLof4VLU2wZPcWjEE3P+oAIzjTw3QC4jk+qHB2pT7nENo OQG5lA9IpH8liIxYEZkpKsev48HS4fCmrWT3Zzj/SI6wTyFcq2Y8J+6TuRc6B4aYY6QK zOzNyGMdLPS1vN9PJuS2N7xhGAJv+oWoVEDr3T0whSj5eUMlDW1tSh6NZ7U/ZdeKugWG w6HhAgwh8mbhPurEYet6EanFs0ILo53cpPbsENGBbzRqBGtz//T8Ipn85cyq7FAXQeDu 5F/pjXeo+zkcyxhRlJRXpUfLUnL0SwAgZ+aXerXTjGt/dotOew98rwEkSPDbYn5FTrSv oiDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="OVN/tu7d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q1si4929940pln.67.2022.02.11.06.59.28; Fri, 11 Feb 2022 06:59:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="OVN/tu7d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241350AbiBKL5h (ORCPT + 99 others); Fri, 11 Feb 2022 06:57:37 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:45722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349775AbiBKL5f (ORCPT ); Fri, 11 Feb 2022 06:57:35 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 629BEF59; Fri, 11 Feb 2022 03:57:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F27FB619D7; Fri, 11 Feb 2022 11:57:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C8AFC340E9; Fri, 11 Feb 2022 11:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1644580640; bh=Ldm8EIHYQkasgOKAyJYfBnfhmYzcyDdgCKPot/eIAKE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OVN/tu7d46VUpGsP/aB2HlzKRep/f4FLtWEiS4B8ITy+aVMgZUSYPr3Zeox/LWTeE 1LBl195xbe/y0SHR6KPmmhUh/Q1H5R8VH5kzdy82My44bWuE4dSayeShRL3L/ALyZE OTZ1Isj2Cjg/zIZWbBh20CaUrCpK7nlK5NNsx5mIJl3n6KXgF+WLVTQVwz5aVbdqD2 Cz8Vw52wkCDUY2wbSsU63O7Gu3X4rYaCdkbBxD9Dishad9a1uXl3iDTvLztNZTj5SB WspQPTbKt9OH60RC6Xifx7S+uHZcgLjrzE/X6xF+icNjz5v+cMMirR7D4vp6bQae27 J1QiwLBJdYDCw== Date: Fri, 11 Feb 2022 11:57:15 +0000 From: Mark Brown To: Lh Kuo =?utf-8?B?6YOt5Yqb6LGq?= Cc: Tom Rix , Li-hao Kuo , "linux-spi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Wells Lu =?utf-8?B?5ZGC6Iqz6aiw?= Subject: Re: [PATCH] spi: Fix warning for Clang build Message-ID: References: <691d52b72f978f562136c587319852f5c65f08fe.1644460444.git.lhjeff911@gmail.com> <99ab624e2af4414bb2a785f64f35bd95@sphcmbx02.sunplus.com.tw> <0b71842ec1b946729e74d73cbd354162@sphcmbx02.sunplus.com.tw> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="NvE0JsC/dVXmBGff" Content-Disposition: inline In-Reply-To: <0b71842ec1b946729e74d73cbd354162@sphcmbx02.sunplus.com.tw> X-Cookie: do { X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --NvE0JsC/dVXmBGff Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 11, 2022 at 04:59:00AM +0000, Lh Kuo =E9=83=AD=E5=8A=9B=E8=B1= =AA wrote: > Yes. I think the function can be simplified as follows > static int sp7021_spi_slave_transfer_one(struct spi_controller *ctlr, str= uct spi_device *spi, > struct spi_transfer *xfer) > { > struct sp7021_spi_ctlr *pspim =3D spi_master_get_devdata(ctlr); > struct device *dev =3D pspim->dev; > int ret; >=20 > mode =3D SP7021_SPI_IDLE; > if (xfer->tx_buf && xfer->rx_buf) { > dev_dbg(&ctlr->dev, "%s() wrong command\n", __func__); > return -EINVAL; Since only unidirectional transfers are supported... > } else if (xfer->tx_buf) { > xfer->tx_dma =3D dma_map_single(dev, (void *)xfer->tx_buf, > xfer->len, DMA_TO_DEVICE); > if (dma_mapping_error(dev, xfer->tx_dma)) > return -ENOMEM; > ret =3D sp7021_spi_slave_tx(spi, xfer); > } else if (xfer->rx_buf) { > xfer->rx_dma =3D dma_map_single(dev, xfer->rx_buf, xfer->len, > DMA_FROM_DEVICE); > if (dma_mapping_error(dev, xfer->rx_dma)) > return -ENOMEM; > ret =3D sp7021_spi_slave_rx(spi, xfer); > } >=20 > if (xfer->tx_buf) > dma_unmap_single(dev, xfer->tx_dma, xfer->len, DMA_TO_DEVICE); > if (xfer->rx_buf) > dma_unmap_single(dev, xfer->rx_dma, xfer->len, DMA_FROM_DEVICE); =2E..you could even fold the unmapping into the if/else tree above. Otherwise this looks good to me, please send a patch. --NvE0JsC/dVXmBGff Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmIGTxsACgkQJNaLcl1U h9B+TAf/YCtAIAmkCrNTybdoi5JUfqSpnQIzE8Q9UGKolsOIQLunISnaeNXtPFCu K7h1RDK3bMlFZghiE7dtitnI2QhbCJXTaH7mmqhYD224nq/41RNvrvFoy++Cn3H5 jeGrWoVrwXqDmRbCrrXXKI2nzSMWienupaPT2gXVjSmJWRCne2YP3sa79DRGhV8F 5ZeBGh5ZLj6EEOrVJ2lx1OLd5bDhLOq1AZ+ZSBsMEvYXHYT0QDQ7xHdtmx6zSnZb YyXNrzFWb+GRgub6eVxDec5ki9uWwbsaRcVTcbBbDAiHX6MHMwmrLutXouYiOmcp XRkcoDiQlzVuaYIfpWbC8PW3KjiFyg== =0iSE -----END PGP SIGNATURE----- --NvE0JsC/dVXmBGff--