From patchwork Sat Feb 11 03:27:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Zhang X-Patchwork-Id: 13136873 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DC7F7C61DA4 for ; Sat, 11 Feb 2023 03:37:04 +0000 (UTC) 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=c3Ho2VcHgimQdM0cbUhKGNrylbti944HLyL374WCl9Q=; b=YXhjEVG0dbUQ0V ahRfyjwvRTGw/Mk3Mc0Q8IL1RP21pNbvUZFkp/FUv30gtZWvZr4Xe7zGmnM1OaEOmZoAAjMSala8I xb01bI7IlKMuH6RONqygKpqULLfORK1bvGYb40L/nJLu5YGHo8yGSF2fcyo//fOUdmPewf7KMo25x qv9ZJ7mSHGAUFT3Mlw7d86eIn09YV8NH6+WXReX2oeplxIKi3hw9pGPQmCxelStIURE4oL6SrLM0J RTaGQRQx5U40PUSWOk5LtQIQASRzPTkY6JAkmVT/qNdhQUQijivwnFkh3qm11uB2GoNEspdSSQi5V fimRCPi95D90Y6DU1lcw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQggB-008ZVh-B2; Sat, 11 Feb 2023 03:36:00 +0000 Received: from saphodev.broadcom.com ([192.19.144.205] helo=relay.smtp-ext.broadcom.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQgYt-008W6R-QD for linux-arm-kernel@lists.infradead.org; Sat, 11 Feb 2023 03:28:30 +0000 Received: from mail-lvn-it-01.lvn.broadcom.net (mail-lvn-it-01.lvn.broadcom.net [10.75.146.107]) by relay.smtp-ext.broadcom.com (Postfix) with ESMTP id A5C63C0000F6; Fri, 10 Feb 2023 19:28:23 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com A5C63C0000F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1676086103; bh=FOS/o6Bd4XVI+urrzvmsMM/X8nx8Xd6gYweRl6pibQk=; h=From:To:Cc:Subject:Date:From; b=BupMRpOFs1kxHZCDv52lqnGDanN6N2ckliKVlCmMEL3NFXaM9dPR8SgfprjsCHJ1l P7NPdWEHMn6UIonNXn0jEstR0oCcEeatPjIK3HdmgdqNkPhbOVogbSS6/IeUqEXvh3 RBI5f90CsX2LHjfGiocpPn4W0yAH43fOXVJuPTgo= Received: from bcacpedev-irv-3.lvn.broadcom.net (bcacpedev-irv-3.lvn.broadcom.net [10.75.138.105]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail-lvn-it-01.lvn.broadcom.net (Postfix) with ESMTPS id 635A518041CAC6; Fri, 10 Feb 2023 19:28:23 -0800 (PST) Received: by bcacpedev-irv-3.lvn.broadcom.net (Postfix, from userid 28376) id 8359C101B62; Fri, 10 Feb 2023 19:28:13 -0800 (PST) From: William Zhang To: Linux SPI List , Broadcom Kernel List Cc: dan.beygelman@broadcom.com, f.fainelli@gmail.com, tomer.yacoby@broadcom.com, kursad.oney@broadcom.com, dregan@mail.com, anand.gore@broadcom.com, jonas.gorski@gmail.com, joel.peshkin@broadcom.com, William Zhang , kernel test robot , Mark Brown , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: bcm63xx-hsspi: bcmbca-hsspi: fix _be16 type usage Date: Fri, 10 Feb 2023 19:27:59 -0800 Message-Id: <20230211032759.72967-1-william.zhang@broadcom.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230210_192828_289018_6B31E604 X-CRM114-Status: GOOD ( 13.00 ) 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 sparse tool report warnings: drivers/spi/spi-bcm63xx-hsspi.c:197:31: sparse: sparse: cast from restricted __be16. The controller requires big endian 16 bit data. Define an intermediate u16 value and use __be16 piointer dereferncing for the data to avoid directly casting to u16 and sparse warning. Fixes: 85a84a616999 ("spi: bcm63xx-hsspi: Endianness fix for ARM based SoC") Reported-by: kernel test robot Link: https://lore.kernel.org/oe-kbuild-all/202302110438.sQwQnU54-lkp@intel.com/ Signed-off-by: William Zhang --- drivers/spi/spi-bcm63xx-hsspi.c | 10 ++++++---- drivers/spi/spi-bcmbca-hsspi.c | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hsspi.c index 1e9e906d297c..68093c045e0b 100644 --- a/drivers/spi/spi-bcm63xx-hsspi.c +++ b/drivers/spi/spi-bcm63xx-hsspi.c @@ -350,7 +350,7 @@ static int bcm63xx_hsspi_do_prepend_txrx(struct spi_device *spi, { struct bcm63xx_hsspi *bs = spi_master_get_devdata(spi->master); unsigned int chip_select = spi->chip_select; - u16 opcode = 0; + u16 opcode = 0, val; const u8 *tx = t->tx_buf; u8 *rx = t->rx_buf; u32 reg = 0; @@ -401,7 +401,8 @@ static int bcm63xx_hsspi_do_prepend_txrx(struct spi_device *spi, memcpy_toio(bs->fifo + HSSPI_OPCODE_LEN + bs->prepend_cnt, tx, t->len); - __raw_writew((u16)cpu_to_be16(opcode | t->len), bs->fifo); + *(__be16 *)(&val) = cpu_to_be16(opcode | t->len); + __raw_writew(val, bs->fifo); /* enable interrupt */ if (bs->wait_mode == HSSPI_WAIT_MODE_INTR) __raw_writel(HSSPI_PINGx_CMD_DONE(0), bs->regs + HSSPI_INT_MASK_REG); @@ -468,7 +469,7 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t) { struct bcm63xx_hsspi *bs = spi_master_get_devdata(spi->master); unsigned int chip_select = spi->chip_select; - u16 opcode = 0; + u16 opcode = 0, val; int pending = t->len; int step_size = HSSPI_BUFFER_LEN; const u8 *tx = t->tx_buf; @@ -511,7 +512,8 @@ static int bcm63xx_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t) tx += curr_step; } - __raw_writew((u16)cpu_to_be16(opcode | curr_step), bs->fifo); + *(__be16 *)(&val) = cpu_to_be16(opcode | curr_step); + __raw_writew(val, bs->fifo); /* enable interrupt */ if (bs->wait_mode == HSSPI_WAIT_MODE_INTR) diff --git a/drivers/spi/spi-bcmbca-hsspi.c b/drivers/spi/spi-bcmbca-hsspi.c index d58033251c02..e255241319ab 100644 --- a/drivers/spi/spi-bcmbca-hsspi.c +++ b/drivers/spi/spi-bcmbca-hsspi.c @@ -252,7 +252,7 @@ static int bcmbca_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t, { struct bcmbca_hsspi *bs = spi_master_get_devdata(spi->master); unsigned int chip_select = spi->chip_select; - u16 opcode = 0; + u16 opcode = 0, val; int pending = t->len; int step_size = HSSPI_BUFFER_LEN; const u8 *tx = t->tx_buf; @@ -292,7 +292,9 @@ static int bcmbca_hsspi_do_txrx(struct spi_device *spi, struct spi_transfer *t, memcpy_toio(bs->fifo + HSSPI_OPCODE_LEN, tx, curr_step); tx += curr_step; } - __raw_writew((u16)cpu_to_be16(opcode | curr_step), bs->fifo); + + *(__be16 *)(&val) = cpu_to_be16(opcode | curr_step); + __raw_writew(val, bs->fifo); /* enable interrupt */ if (bs->wait_mode == HSSPI_WAIT_MODE_INTR)