From patchwork Wed Jul 21 12:15:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 12390775 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=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 4C38AC636CA for ; Wed, 21 Jul 2021 12:16:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08E086120E for ; Wed, 21 Jul 2021 12:16:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08E086120E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=0jNoWSoil2BJFzBrxsnDjZz9miIwuy2y5XJu6X1VpCs=; b=Ss07IxgUMUfiWI JTG0+wjW5AVckO7r2eRD3jzSPpVlVtuOm7x6sKlhbnItydl2QZ4Sssqw9f31K3t+1h1ShM7VzcfWd mGgg5dWLtWJk5G0+Tq7Z2qeif/GPM8D+E8VySPS55BqA7y6raA4yTIwt25MnHRqJZUIo83jOoJ/DX IR2M/EdMJv+NluBmuVd6DGUbzP1m7axxJKGU1TJ8PBpOa8T2wknSRfVQAf+p/BPHyhjSijehDplCP HYpENfWmVXouvsS6OLshLu5TBVyXpRnkoqTAt1KuS4e9UaOPgB7jUk3/Q4mMbxjuLXYfFKa0M32e9 EMN2kTNoS5Uk9bFePA6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6B7v-00FcJP-Kt; Wed, 21 Jul 2021 12:15:03 +0000 Received: from mga02.intel.com ([134.134.136.20]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m6B7r-00FcIL-9D for linux-arm-kernel@lists.infradead.org; Wed, 21 Jul 2021 12:15:00 +0000 X-IronPort-AV: E=McAfee;i="6200,9189,10051"; a="198627096" X-IronPort-AV: E=Sophos;i="5.84,258,1620716400"; d="scan'208";a="198627096" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2021 05:14:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,258,1620716400"; d="scan'208";a="576673333" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 21 Jul 2021 05:14:55 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 197EE103; Wed, 21 Jul 2021 15:15:22 +0300 (EEST) From: Andy Shevchenko To: Mark Brown , Andy Shevchenko , linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Daniel Mack , Haojian Zhuang , Robert Jarzmik , Dan Carpenter Subject: [PATCH v1 1/1] spi: pxa2xx: Adapt reset_sccr1() to the case when no message available Date: Wed, 21 Jul 2021 15:15:20 +0300 Message-Id: <20210721121520.62605-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210721_051459_412579_832DE3B0 X-CRM114-Status: GOOD ( 16.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In some cases reset_sccr1() can be called when no message available. This means that there is no associated chip to receive that message and hence no threshold needs to be set. Adapt the function to such cases. Fixes: 3bbdc083262d ("spi: pxa2xx: Reuse int_stop_and_reset() in couple of places") Reported-by: Dan Carpenter Signed-off-by: Andy Shevchenko --- drivers/spi/spi-pxa2xx.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 793cb80f92c7..2b4d633dd9df 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c @@ -594,8 +594,15 @@ static int u32_reader(struct driver_data *drv_data) static void reset_sccr1(struct driver_data *drv_data) { - struct chip_data *chip = spi_get_ctldata(drv_data->controller->cur_msg->spi); - u32 mask = drv_data->int_cr1 | drv_data->dma_cr1; + u32 mask = drv_data->int_cr1 | drv_data->dma_cr1, threshold; + struct chip_data *chip; + + if (drv_data->controller->cur_msg) { + chip = spi_get_ctldata(drv_data->controller->cur_msg->spi); + threshold = chip->threshold; + } else { + threshold = 0; + } switch (drv_data->ssp_type) { case QUARK_X1000_SSP: @@ -609,7 +616,7 @@ static void reset_sccr1(struct driver_data *drv_data) break; } - pxa2xx_spi_update(drv_data, SSCR1, mask, chip->threshold); + pxa2xx_spi_update(drv_data, SSCR1, mask, threshold); } static void int_stop_and_reset(struct driver_data *drv_data)