From patchwork Tue May 12 15:04:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= X-Patchwork-Id: 219415 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=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MSGID_FROM_MTA_HEADER, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 AFBD2C54E8F for ; Tue, 12 May 2020 15:05:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 84944206D6 for ; Tue, 12 May 2020 15:05:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=silabs.onmicrosoft.com header.i=@silabs.onmicrosoft.com header.b="INYK03WZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730779AbgELPFI (ORCPT ); Tue, 12 May 2020 11:05:08 -0400 Received: from mail-eopbgr770072.outbound.protection.outlook.com ([40.107.77.72]:30085 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730725AbgELPFG (ORCPT ); Tue, 12 May 2020 11:05:06 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uh48uiQrLbQZ1Fzr8J4YPUoyiEPdS8ZpSbdmYmLiF8rqdp8EUs8Lw2O3ZQjT9C1HHgL7O2EGmlq8V7ntbOLYyHjc9/Puzu/KitJ70g2Q/hj6UBsqDZUfslczLspYAHoY+NUTtaqcqErUXeIHUQ0QWC6g4zI2dmTBb2Nh+26lMUBe0OE3z1aFb/qqiCgufcbTfhU1kUc2X+lAtnfA/QSr1SRufZioi5C6VMK2YLZDYydfUwKVGOKyVhuDK/PdQMLRxogoPCK6f0XdRzw/RobuwIc4tvn+mkKzr78DULwN3A7hHeQNNHCpORkTx0wonWyo5ueBCTu0FaVkUhxNS9k5jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JQUEM5ca7coakQv72bsNt+k61HBZZbFyi6u61Mxubf8=; b=OgPCU+I2uUL8q+EcnZFGnxhrdcqVJUaDfowLVV0SLgjNacYGpyogwcDJBTWRZPySDrWxaQBG3sJrAiFZDKBH5OcPFuS2f/caRM/tg9H0ZwJdL2AhgFHVGqAn24WupXOpPPVmZn9ieEoTgQPtVjZFJunz0OdWL1wXKN2+4kBUV533Bg1mn1p65mM5RLud/oGPDB6uklUF4h1FX3nlgrMiCHnyuRcKyCE5b/iJVlAGcpuISWO+jXeCSNUkjInfkbM1wGAXstCaBSZHjZ62Rva3iPep8h+O//g/wn8qiegHG16xRg9A+fRExNbHNsOmlasJrZRdVnP+ln8GEp7+fc7pSA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=silabs.com; dmarc=pass action=none header.from=silabs.com; dkim=pass header.d=silabs.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silabs.onmicrosoft.com; s=selector2-silabs-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JQUEM5ca7coakQv72bsNt+k61HBZZbFyi6u61Mxubf8=; b=INYK03WZcAy0/bM4cwu3LY6dtMQ+Pw97UY6bEDhGauoXzadCE1cMJ0fLcgTeHpOE/0DS9+zDLmOMW6wHlxXmFu4NOQdvpWXUC+aHKcTu0mMQ4QiiBjJMbBC+jxuFdOQAtVK4ehdz8zodXdNZ5Py0/vPnqrMB8bkjiUJ1W0dSPXk= Authentication-Results: driverdev.osuosl.org; dkim=none (message not signed) header.d=none; driverdev.osuosl.org; dmarc=none action=none header.from=silabs.com; Received: from MWHPR11MB1775.namprd11.prod.outlook.com (2603:10b6:300:10e::14) by MWHPR11MB1741.namprd11.prod.outlook.com (2603:10b6:300:10d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.34; Tue, 12 May 2020 15:04:54 +0000 Received: from MWHPR11MB1775.namprd11.prod.outlook.com ([fe80::e055:3e6d:ff4:56da]) by MWHPR11MB1775.namprd11.prod.outlook.com ([fe80::e055:3e6d:ff4:56da%5]) with mapi id 15.20.2979.033; Tue, 12 May 2020 15:04:53 +0000 From: Jerome Pouiller To: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Kalle Valo , "David S . Miller" , =?utf-8?b?SsOpcsO0bWUgUG91aWxsZXI=?= Subject: [PATCH v2 12/17] staging: wfx: fix endianness of the struct hif_ind_startup Date: Tue, 12 May 2020 17:04:09 +0200 Message-Id: <20200512150414.267198-13-Jerome.Pouiller@silabs.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200512150414.267198-1-Jerome.Pouiller@silabs.com> References: <20200512150414.267198-1-Jerome.Pouiller@silabs.com> X-ClientProxiedBy: DM5PR1101CA0003.namprd11.prod.outlook.com (2603:10b6:4:4c::13) To MWHPR11MB1775.namprd11.prod.outlook.com (2603:10b6:300:10e::14) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from pc-42.silabs.com (82.67.86.106) by DM5PR1101CA0003.namprd11.prod.outlook.com (2603:10b6:4:4c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20 via Frontend Transport; Tue, 12 May 2020 15:04:52 +0000 X-Mailer: git-send-email 2.26.2 X-Originating-IP: [82.67.86.106] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: edef80a4-18ea-4bb9-081d-08d7f685d383 X-MS-TrafficTypeDiagnostic: MWHPR11MB1741: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:248; X-Forefront-PRVS: 0401647B7F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9eydh+TMdDIk4hfoUZvbZ+hM+2X7BxRvBsxF6jCSY5+OsD8gVfg+o3+42XfS32SyyQ6fd1Xq8oy1XNre6BRs4R7nGWrYE1TpqSpxQydaNRFS9sYG3T1442pRTJMvYYhytm9OpOsOL6+OGOrtX1qYUD9ChzCqTo1krdj+3dep/sl+oZ2kuX+Sk5prp7jwpn2AkIjzYDK1SE3zKRqBuLA4vyTiFTrM5uxMPdme4JCC+VpKKUEdCto8wb6/3mGh3TF5wC6aW5B8EzX2JsssLkoCmDXwQELhoAekytesfgSGwbrnVV2wC1EANu54mahTbihkd9AoDvBadHNMngvOtwhA4O+vECozWzxhwg/3hBEnYia2zjiQYMIArCoGQ8GRqlBpAFD7YWr252yv4a7vyDeIbPiHBkHiEd0uEnr+sDtvFFYCAQ+5ZTn3kWavYN7rTzKTDNeaPEGrnPwJMKDSvFN+rOPNKwikjtDUtlgULu3FdzTC2plHlFatLxxvxuUHu1N+Pg6Lez3J4ASlhsRj+hEEJQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MWHPR11MB1775.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(396003)(366004)(376002)(39860400002)(346002)(136003)(33430700001)(54906003)(107886003)(478600001)(8676002)(5660300002)(316002)(1076003)(956004)(8936002)(2616005)(186003)(2906002)(7696005)(86362001)(4326008)(52116002)(6666004)(6486002)(66476007)(66574014)(26005)(66946007)(66556008)(33440700001)(16526019)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: hB3EAaOvqNDraKH1AeGN6pJwba3Hlk5EvGt9fNrtBh9xNIrXlupDyuVrsQW126slTqFC/kpiX3vzZJ1txhVDGHJE3fhJqxtCSNaxAYShjyPOAvnDIARgSxREtCgl1GpmkMG/2GWa5DE+lD1RrYa4y7knBdB4ijReS9BCN3+D3qjywzzsxSsDBVBlwykQPlE+n4PWoHC6MbNyeWRgMA0DiU/xj4q3V4iNb7v5FifOkcPOyWj5c+i+OzfeKCM1KmsjU3g1zN3bx8v5zXOzrzT0eyT3E8IHvjR18KsRx2LkFxaZvMjASSJW2qMGEPvULMkVQc/Z6hH5D9RxxwaqJhHU98TktUVAKkgqjcFLO5K+fs2bCRcZBGl6qxXibYtWYCmtK5oNT1A46KlRPkwd7nZRtMKOvZZTDIHVjQtLdgdPMgC4E+elGpFIr/pEyqc/Qmo+8GeV9d+6fG5lj975453xyC6Bu6a2VwI2PhBQdWeg0MU= X-OriginatorOrg: silabs.com X-MS-Exchange-CrossTenant-Network-Message-Id: edef80a4-18ea-4bb9-081d-08d7f685d383 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2020 15:04:53.8066 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 54dbd822-5231-4b20-944d-6f4abcd541fb X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Mz5ey4WyEtTSpxQbmGeh370mE8CjwNKfvyvwwImNB6oDmR3GpN4LA0I/v+gh4pSyOhNWuTexag+ePr/Z4a2Acw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1741 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jérôme Pouiller The struct hif_ind_startup is received from the hardware. So it is declared as little endian. However, it is also stored in the main driver structure and used on different places in the driver. Sparse complains about that: drivers/staging/wfx/data_tx.c:388:43: warning: restricted __le16 degrades to integer drivers/staging/wfx/bh.c:199:9: warning: restricted __le16 degrades to integer drivers/staging/wfx/bh.c:221:62: warning: restricted __le16 degrades to integer In order to make Sparse happy and to keep access from the driver easy, this patch declare hif_ind_startup with native endianness. On reception of this struct, this patch takes care to do byte-swap and keep Sparse happy. Signed-off-by: Jérôme Pouiller --- drivers/staging/wfx/hif_api_general.h | 11 +++++++---- drivers/staging/wfx/hif_rx.c | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/staging/wfx/hif_api_general.h b/drivers/staging/wfx/hif_api_general.h index f0135d27120c..995752b9f168 100644 --- a/drivers/staging/wfx/hif_api_general.h +++ b/drivers/staging/wfx/hif_api_general.h @@ -136,12 +136,15 @@ struct hif_otp_phy_info { } __packed; struct hif_ind_startup { + // As the others, this struct is interpreted as little endian by the + // device. However, this struct is also used by the driver. We prefer to + // declare it in native order and doing byte swap on reception. __le32 status; - __le16 hardware_id; + u16 hardware_id; u8 opn[14]; u8 uid[8]; - __le16 num_inp_ch_bufs; - __le16 size_inp_ch_buf; + u16 num_inp_ch_bufs; + u16 size_inp_ch_buf; u8 num_links_ap; u8 num_interfaces; u8 mac_addr[2][ETH_ALEN]; @@ -155,7 +158,7 @@ struct hif_ind_startup { u8 disabled_channel_list[2]; struct hif_otp_regul_sel_mode_info regul_sel_mode_info; struct hif_otp_phy_info otp_phy_info; - __le32 supported_rate_mask; + u32 supported_rate_mask; u8 firmware_label[128]; } __packed; diff --git a/drivers/staging/wfx/hif_rx.c b/drivers/staging/wfx/hif_rx.c index fca9df620ad9..9b4f0c4ba745 100644 --- a/drivers/staging/wfx/hif_rx.c +++ b/drivers/staging/wfx/hif_rx.c @@ -100,10 +100,10 @@ static int hif_startup_indication(struct wfx_dev *wdev, return -EINVAL; } memcpy(&wdev->hw_caps, body, sizeof(struct hif_ind_startup)); - le32_to_cpus(&wdev->hw_caps.status); - le16_to_cpus(&wdev->hw_caps.hardware_id); - le16_to_cpus(&wdev->hw_caps.num_inp_ch_bufs); - le16_to_cpus(&wdev->hw_caps.size_inp_ch_buf); + le16_to_cpus((__le16 *)&wdev->hw_caps.hardware_id); + le16_to_cpus((__le16 *)&wdev->hw_caps.num_inp_ch_bufs); + le16_to_cpus((__le16 *)&wdev->hw_caps.size_inp_ch_buf); + le32_to_cpus((__le32 *)&wdev->hw_caps.supported_rate_mask); complete(&wdev->firmware_ready); return 0;