[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOd=kWY8ki-j-VZ7X4anypeuW5=4w2FPD=f39vK-zrAaWjQ@mail.gmail.com>
Date: Mon, 1 Mar 2021 09:15:44 -0800
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Arnd Bergmann <arnd@...nel.org>
Cc: Mark Brown <broonie@...nel.org>, Heiko Stuebner <heiko@...ech.de>,
Pratyush Yadav <p.yadav@...com>, Arnd Bergmann <arnd@...db.de>,
Nathan Chancellor <nathan@...nel.org>,
Emil Renner Berthing <kernel@...il.dk>,
Jon Lin <jon.lin@...k-chips.com>,
Johan Jonker <jbx6244@...il.com>, linux-spi@...r.kernel.org,
Linux ARM <linux-arm-kernel@...ts.infradead.org>,
linux-rockchip@...ts.infradead.org,
LKML <linux-kernel@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: [PATCH] [v2] spi: rockchip: avoid objtool warning
On Fri, Feb 26, 2021 at 6:01 AM Arnd Bergmann <arnd@...nel.org> wrote:
>
> From: Arnd Bergmann <arnd@...db.de>
>
> 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 <arnd@...db.de>
Thanks for the v2!
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>
> ---
> v2: use 'return' instead of 'BUG()'
> ---
> drivers/spi/spi-rockchip.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> 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);
> --
> 2.29.2
>
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists