From patchwork Wed Jun 15 17:41:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 12882830 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84A42C43334 for ; Wed, 15 Jun 2022 18:03:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345270AbiFOSDG (ORCPT ); Wed, 15 Jun 2022 14:03:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46238 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349342AbiFOSDC (ORCPT ); Wed, 15 Jun 2022 14:03:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C6202496A for ; Wed, 15 Jun 2022 11:03:02 -0700 (PDT) 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 5F24661BD9 for ; Wed, 15 Jun 2022 18:03:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A21BC34115; Wed, 15 Jun 2022 18:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655316180; bh=wgJbnm7UeIp8mXUcr2VlmVixaSMm2UdMBK/arXqGHTg=; h=From:To:Cc:Subject:Date:From; b=uU+VGi+ypdOBw+U6DLiX0JYfsSLZwpgSKUQ/7Swo5iavqJsKiXrXrdmeiw4oRMq7Y QyXY5FeOUS3tzym9gYskdgoEX4gYtNMGo0bP42RCj0CXjWKVnYgHhl0d/6i5D/Sopi P47Xx/g6pwR2ACSMonzqLWNJWZVXuJAUxLaKnmp5QjT+cpkRnyTFbH0toNSTwGUxiD xyhQMpp2tUOtNFsK3NkTiacaK9iGU+DhLe/DzITFEVM38UozlDfB5PrU8ln5glFi7t 9KA5KgpdXlq+OzbU8Xgng85fxsdyWRyYDJho2I0mPmvRWUVBCW6p0PE8PX4i17mSYq 26V14qKeDQuog== From: Mark Brown To: Tomoya MORINAGA , Masayuki Ohtake , Tomoya MORINAGA Cc: linux-spi@vger.kernel.org, Mark Brown Subject: [PATCH] spi: topcliff-pch: Use core message validation Date: Wed, 15 Jun 2022 18:41:38 +0100 Message-Id: <20220615174138.4060912-1-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2048; h=from:subject; bh=wgJbnm7UeIp8mXUcr2VlmVixaSMm2UdMBK/arXqGHTg=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBiqhl/Q0KxFdyNG8uSnfc1wQR0Nl6l4UAcp+pJkjUP 0ye1T3GJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYqoZfwAKCRAk1otyXVSH0MCZCA CB/k5LH6emX5wkWcmM1LUtC/qBC2X8xkLWUBQoTkSsxFz8L5S/2gnb4uCBv5hkXS0lSU4lvu8ytaTM Rr2fl/UNWNmXvfnVqqyv5oFmGaHzlmbke+flt+A81VeyS48mkaRGV8XWxEaWbpvXYXYJ5lNGtgSekt xSelMehdwGtz4hdm7zJC/CdvsLxC37pThej9Gw98SwnqC+O7JloAG3N+qxiItt0cYV9W32bGKhOiBG a5shbDJ+Qg/+sffYFZ9pBe4tOHJyD5iRPPA4hpPkeliSiPBtGgHkkqYeh+O78IzELRl4Qp7xzcgKgV xw6aYGRILdHKTK/9DpYKFc02dDmENA X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The topcliff-pch driver requires TX and RX buffers on all transfers, open coding checks for this. Remove those open coded checks and instead rely on the core functionality, which has the added bonus that it will fix up any transfers submitted by drivers as needed rather than erroring out. Signed-off-by: Mark Brown --- drivers/spi/spi-topcliff-pch.c | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c index dfaa1d79a78b..fe4bbd928c6c 100644 --- a/drivers/spi/spi-topcliff-pch.c +++ b/drivers/spi/spi-topcliff-pch.c @@ -461,29 +461,6 @@ static int pch_spi_transfer(struct spi_device *pspi, struct spi_message *pmsg) int retval; unsigned long flags; - spin_lock_irqsave(&data->lock, flags); - /* validate Tx/Rx buffers and Transfer length */ - list_for_each_entry(transfer, &pmsg->transfers, transfer_list) { - if (!transfer->tx_buf && !transfer->rx_buf) { - dev_err(&pspi->dev, - "%s Tx and Rx buffer NULL\n", __func__); - retval = -EINVAL; - goto err_return_spinlock; - } - - if (!transfer->len) { - dev_err(&pspi->dev, "%s Transfer length invalid\n", - __func__); - retval = -EINVAL; - goto err_return_spinlock; - } - - dev_dbg(&pspi->dev, - "%s Tx/Rx buffer valid. Transfer length valid\n", - __func__); - } - spin_unlock_irqrestore(&data->lock, flags); - /* We won't process any messages if we have been asked to terminate */ if (data->status == STATUS_EXITING) { dev_err(&pspi->dev, "%s status = STATUS_EXITING.\n", __func__); @@ -1365,6 +1342,7 @@ static int pch_spi_pd_probe(struct platform_device *plat_dev) master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_LSB_FIRST; master->bits_per_word_mask = SPI_BPW_MASK(8) | SPI_BPW_MASK(16); master->max_speed_hz = PCH_MAX_BAUDRATE; + master->flags = SPI_CONTROLLER_MUST_RX | SPI_CONTROLLER_MUST_TX; data->board_dat = board_dat; data->plat_dev = plat_dev;