From patchwork Fri Feb 26 14:00:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 387670 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp1221551jap; Fri, 26 Feb 2021 06:02:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0THeFjdEJIVWcpdIUXGKSlkw5mbWiIEKOGYltU7172KAquNFpY2VRLot1SNf+8/qbEaCN X-Received: by 2002:a17:906:32d1:: with SMTP id k17mr3560640ejk.141.1614348155864; Fri, 26 Feb 2021 06:02:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614348155; cv=none; d=google.com; s=arc-20160816; b=vHUl+dSoXkXHEoCiARbcnKlAkESu5j3ipjqer67mvm6IHGmk0y37SiTNio02oLAdIA 6IqyK8pgTaEq1DuyrRUXLrFGjS8iORpn7UukN+/vwa+cYAZy+vRtXiJm/VovP9p/SKxW pX00tgJV+4l4IKcvT9m+bP0ZF4WG71dtjYX0EwxMVXRIu8xmbYi9o+6qomWKzCKdpcnR foAv0oO1zTNO1TAi5wmOT7jMN8SYDC6gy7L7/3rsAhsu/Yq7kqb1ctb/OENZyjUAnNDQ fL5DvsS2Wa8XmsDs75cla8M3AZ4Cexk7loKSn9Mw650ZjNt0x7iui8PTLY/F2R2hHFCP De+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=35iLr8UiZIo3uKL/2s/6fJ6d4oUX3UptE50Nn546Z6U=; b=xNY5310DLWm0uJZcc0QLJJkaqZWXRygNB7XqjZ1Yf56UZ3UFkoQfj1aNF39QHeiJAb Kwz4bE1byADJfwYEpPIftxGBW81Y9ubAA6d9KsSSEOpVqOVvvteVJ7hN28oMAFnsnTTt tMONwwKQs/egKKlHUpw3fBgAPWBOPwV4glZnWgZvufzZMNpFA16nn4uba7Kzjm1qjTAv qQi10y90Ogu4Ed0SCV8O5reXbiwp5GNLBY6xCwGTxInUX3RYtplT8QM3OZVle2RWG5jj bNSVJZR/Ij+hQiPh1WN8/tVR9JXcxV3Lyj+6y9FDMBR3/373KCN3ArFZZSWJ9JwqcbTK 31vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Y/RQ4yiS"; spf=pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-spi-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h28si6277191edj.387.2021.02.26.06.02.35; Fri, 26 Feb 2021 06:02:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-spi-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=@kernel.org header.s=k20201202 header.b="Y/RQ4yiS"; spf=pass (google.com: domain of linux-spi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-spi-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 S229845AbhBZOCd (ORCPT + 1 other); Fri, 26 Feb 2021 09:02:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:59178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbhBZOCb (ORCPT ); Fri, 26 Feb 2021 09:02:31 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7876F64EC4; Fri, 26 Feb 2021 14:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614348110; bh=CdhaZ+gptekojCnIxLj0qCtsG+fp7Fb4kfokZslzO18=; h=From:To:Cc:Subject:Date:From; b=Y/RQ4yiSx6y29mXvp33Syj0RSBQSQKaKZLHBl1BqaEbrt/5kkBNk/5nA7Sz5LXBrY arQflDHpYOqTDzKYXaPebQzC/0lizbDvMu8EL85u1BGC7Wg+3G9/BcLSSPhecejCiK al67NyEoo3NfX6w9YsDi6zDO8zCsFIo+2bpuVfwM29Sx0vOjAZxuuQ3uybkTJ/lNMO Z+8U1VqG7S81of9bZRldYAxYSGrJfmhEHF4VaOAF9sOd2CqU8HgTGn9QQG1WH+Rdp8 XeLcsKQn+7W1vLVqmr/eDI7ay9S2dzvM/2Wzn0qouKaqsjgu07ySjTc+rmVsvlZnyg mt17okwc0rdUA== From: Arnd Bergmann To: Mark Brown , Heiko Stuebner Cc: Pratyush Yadav , Arnd Bergmann , Nathan Chancellor , Nick Desaulniers , Emil Renner Berthing , Jon Lin , Johan Jonker , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH] [v2] spi: rockchip: avoid objtool warning Date: Fri, 26 Feb 2021 15:00:48 +0100 Message-Id: <20210226140109.3477093-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org From: Arnd Bergmann Building this file with clang leads to a an unreachable code path causing a warning from objtool: drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame Change the unreachable() into an error return that can be handled if it ever happens, rather than silently crashing the kernel. Fixes: 65498c6ae241 ("spi: rockchip: support 4bit words") Signed-off-by: Arnd Bergmann --- v2: use 'return' instead of 'BUG()' --- drivers/spi/spi-rockchip.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) -- 2.29.2 Acked-by: Pratyush Yadav Reviewed-by: Nick Desaulniers diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c index 936ef54e0903..0d75080da648 100644 --- a/drivers/spi/spi-rockchip.c +++ b/drivers/spi/spi-rockchip.c @@ -476,7 +476,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs, return 1; } -static void rockchip_spi_config(struct rockchip_spi *rs, +static int rockchip_spi_config(struct rockchip_spi *rs, struct spi_device *spi, struct spi_transfer *xfer, bool use_dma, bool slave_mode) { @@ -521,7 +521,9 @@ static void rockchip_spi_config(struct rockchip_spi *rs, * ctlr->bits_per_word_mask, so this shouldn't * happen */ - unreachable(); + dev_err(rs->dev, "unknown bits per word: %d\n", + xfer->bits_per_word); + return -EINVAL; } if (use_dma) { @@ -554,6 +556,8 @@ static void rockchip_spi_config(struct rockchip_spi *rs, */ writel_relaxed(2 * DIV_ROUND_UP(rs->freq, 2 * xfer->speed_hz), rs->regs + ROCKCHIP_SPI_BAUDR); + + return 0; } static size_t rockchip_spi_max_transfer_size(struct spi_device *spi) @@ -577,6 +581,7 @@ static int rockchip_spi_transfer_one( struct spi_transfer *xfer) { struct rockchip_spi *rs = spi_controller_get_devdata(ctlr); + int ret; bool use_dma; WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) && @@ -596,7 +601,9 @@ static int rockchip_spi_transfer_one( use_dma = ctlr->can_dma ? ctlr->can_dma(ctlr, spi, xfer) : false; - rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave); + ret = rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave); + if (ret) + return ret; if (use_dma) return rockchip_spi_prepare_dma(rs, ctlr, xfer);