From patchwork Fri Nov 20 21:34:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lars Povlsen X-Patchwork-Id: 330218 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44B4FC2D0E4 for ; Fri, 20 Nov 2020 21:35:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6C0B2237B for ; Fri, 20 Nov 2020 21:35:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="UO5ugB4o" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728136AbgKTVej (ORCPT ); Fri, 20 Nov 2020 16:34:39 -0500 Received: from esa1.microchip.iphmx.com ([68.232.147.91]:56967 "EHLO esa1.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727665AbgKTVej (ORCPT ); Fri, 20 Nov 2020 16:34:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1605908078; x=1637444078; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=BVeI0aooSO+qLNmmszrCacN2qEtNqOqvzmyg0r6BJYI=; b=UO5ugB4ohC4p2dI/2+sgkDYZou3A8uZs9jWpldfZZzzWKD47WEqumQkv y1kQdKLi5ld1ZQV7Fu8oSkkdUYhJR16L8bj0EJu/6uNPGaDfyVki8o1Hk pP0vwFfEw0Y0HbQD1u4lDaRbktivY3EKHODQ2RtW0DpkU+YaNFXOmiMi1 kgqOTDdJjiQjuncnCLu940iHGhcm3cwtdmovvYpcNWGl2pV+eUboxYuji R9n8SuvxfU9Qiz8HWADDjzjUZ91xEw96ZZQmENJkSey8tbcdSNtACwAU4 iS54Gba4zQfA3JAOjQqPldeXI9QPfZUvVO83h3TBpq7I0jKg5JtuePzyE g==; IronPort-SDR: OFnJbqeRoB8ZQ7usWXLaVbnt8OYMK6gpLBHnVeu4bpTiARpCsm5IkiRSjDC9sQjcT8b6OqiKOG 8iET1vkgUyEtr1OurjBoQcvpmkdm08yvxD5z8LlCdHsaIkSKQBM5s4mOTdNFxtPb+V+YmfJmZJ rTVc5+JYQrGJGKq9SZowJY4FCnxXGMCQEMlmG1jDdMpFUMxfOrq60Ld/9eZBAVJsxTdZByMRbl wjfStueYc6toZ2K+Ns54/OmTr/TaOQfTsPSHaW2Nned8QOr7JLI1sXU/K4ErJqUkehd9YVPHf2 jfs= X-IronPort-AV: E=Sophos;i="5.78,357,1599548400"; d="scan'208";a="104498487" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Nov 2020 14:34:38 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 20 Nov 2020 14:34:38 -0700 Received: from soft-dev10.microsemi.net (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 20 Nov 2020 14:34:37 -0700 From: Lars Povlsen To: Serge Semin , Mark Brown , CC: Lars Povlsen , Subject: [PATCH] spi: dw: Fix spi registration for controllers overriding CS Date: Fri, 20 Nov 2020 22:34:14 +0100 Message-ID: <20201120213414.339701-1-lars.povlsen@microchip.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org When SPI DW memory ops support was introduced, there was a check for excluding controllers which supplied their own CS function. Even so, the mem_ops pointer is *always* presented to the SPI core. This causes the SPI core sanity check in spi_controller_check_ops() to refuse registration, since a mem_ops pointer is being supplied without an exec_op member function. The end result is failure of the SPI DW driver on sparx5 and similar platforms. The fix in the core SPI DW driver is to avoid presenting the mem_ops pointer if the exec_op function is not set. Fixes: 6423207e57ea (spi: dw: Add memory operations support) Signed-off-by: Lars Povlsen Acked-by: Serge Semin --- drivers/spi/spi-dw-core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.25.1 diff --git a/drivers/spi/spi-dw-core.c b/drivers/spi/spi-dw-core.c index 2e50cc0a9291..a0794eac2094 100644 --- a/drivers/spi/spi-dw-core.c +++ b/drivers/spi/spi-dw-core.c @@ -875,7 +875,8 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws) master->set_cs = dw_spi_set_cs; master->transfer_one = dw_spi_transfer_one; master->handle_err = dw_spi_handle_err; - master->mem_ops = &dws->mem_ops; + if (dws->mem_ops.exec_op) + master->mem_ops = &dws->mem_ops; master->max_speed_hz = dws->max_freq; master->dev.of_node = dev->of_node; master->dev.fwnode = dev->fwnode;