From patchwork Mon Mar 3 16:49:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 869923 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D233253F22; Mon, 3 Mar 2025 16:49:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741020577; cv=none; b=t0rrKwbsye8aOCX1+RjMDZLN2MGMgf7Regz1XJfT2p9qWwYunOlwVZ0uVFx1R+DTQsUIeQ94vGfZfurwxOzKy4FohmSJrJMVo5yCRuVxHpQ07Dtev192tMoblJNVueIhc9ZgfogEwG9DThVb6VShqrIy5yDoD/dHdXJPdugTiQk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741020577; c=relaxed/simple; bh=66qhaQBgr0QtdaPsd5LfhInRqDNLNDX1iLGRWakulAo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EUgNwcdTYA2t5cVmRfUBopFgc5+Bcack1CXgmWsdEYRlxskeTO6YKFOx1Uy1Hii9ANKBkXlnam5hHt4mZyMDCxZyIx82gcXM7bU6zQAdK1en+b1AH2OC0MmbIZ3umwxRwcPZSKWth7QjJcns2QYQRQd2E97Nrr/gby9gttU2PGg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=FWwRahVT; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="FWwRahVT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741020576; x=1772556576; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=66qhaQBgr0QtdaPsd5LfhInRqDNLNDX1iLGRWakulAo=; b=FWwRahVTj/gula0qmotim9hoBXRG9MsxQgjknZqHndIfYhhtsZcS1TCZ ay+WQ8fiIEIdEr6FQdAhA4NBSjakgcOh1W0lalg4mQEvmlpjk307xpmjP 8xjfLWDH+Rllb2HDCeKwOgYaA33Xe8WaUFCIylIK4IHpoLrFUrVcMpEG3 KLlHz2dSoH5Gk06cvAA1H2DpU7uME41TavVS4BoCF3//bl+cPiJhIixFA /ZFXVCQbmOIQEM97g/PTsZwE37owAIaF/bBG57ZqPMea3MhjWQKjBXoBI q7wjHWnt9kuJjttL17jG974lXtUfwiSR/gbA4LsOzw2Xohsv7jEaHvvGO w==; X-CSE-ConnectionGUID: Dye6RS+pQ7yG2FsxC6HyrQ== X-CSE-MsgGUID: H1yCQRdPSe6gW6dEyeo+gA== X-IronPort-AV: E=McAfee;i="6700,10204,11362"; a="52883759" X-IronPort-AV: E=Sophos;i="6.13,330,1732608000"; d="scan'208";a="52883759" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2025 08:49:35 -0800 X-CSE-ConnectionGUID: zI2mBBkDRXSd5pA79K5hOQ== X-CSE-MsgGUID: RaCdYLjzQfmur4btK2HR6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="123324425" Received: from black.fi.intel.com ([10.237.72.28]) by orviesa005.jf.intel.com with ESMTP; 03 Mar 2025 08:49:31 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 8D5BCDC; Mon, 03 Mar 2025 18:49:29 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Alexander Aring , Stefan Schmidt , Miquel Raynal , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Linus Walleij , Bartosz Golaszewski Subject: [PATCH net-next v2 1/3] ieee802154: ca8210: Use proper setter and getters for bitwise types Date: Mon, 3 Mar 2025 18:49:08 +0200 Message-ID: <20250303164928.1466246-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250303164928.1466246-1-andriy.shevchenko@linux.intel.com> References: <20250303164928.1466246-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sparse complains that the driver doesn't respect the bitwise types: drivers/net/ieee802154/ca8210.c:1796:27: warning: incorrect type in assignment (different base types) drivers/net/ieee802154/ca8210.c:1796:27: expected restricted __le16 [addressable] [assigned] [usertype] pan_id drivers/net/ieee802154/ca8210.c:1796:27: got unsigned short [usertype] drivers/net/ieee802154/ca8210.c:1801:25: warning: incorrect type in assignment (different base types) drivers/net/ieee802154/ca8210.c:1801:25: expected restricted __le16 [addressable] [assigned] [usertype] pan_id drivers/net/ieee802154/ca8210.c:1801:25: got unsigned short [usertype] drivers/net/ieee802154/ca8210.c:1928:28: warning: incorrect type in argument 3 (different base types) drivers/net/ieee802154/ca8210.c:1928:28: expected unsigned short [usertype] dst_pan_id drivers/net/ieee802154/ca8210.c:1928:28: got restricted __le16 [addressable] [usertype] pan_id Use proper setter and getters for bitwise types. Note, in accordance with [1] the protocol is little endian. Link: https://www.cascoda.com/wp-content/uploads/2018/11/CA-8210_datasheet_0418.pdf [1] Reviewed-by: Miquel Raynal Signed-off-by: Andy Shevchenko --- drivers/net/ieee802154/ca8210.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ieee802154/ca8210.c b/drivers/net/ieee802154/ca8210.c index 753215ebc67c..a036910f6082 100644 --- a/drivers/net/ieee802154/ca8210.c +++ b/drivers/net/ieee802154/ca8210.c @@ -1446,8 +1446,7 @@ static u8 mcps_data_request( command.pdata.data_req.src_addr_mode = src_addr_mode; command.pdata.data_req.dst.mode = dst_address_mode; if (dst_address_mode != MAC_MODE_NO_ADDR) { - command.pdata.data_req.dst.pan_id[0] = LS_BYTE(dst_pan_id); - command.pdata.data_req.dst.pan_id[1] = MS_BYTE(dst_pan_id); + put_unaligned_le16(dst_pan_id, command.pdata.data_req.dst.pan_id); if (dst_address_mode == MAC_MODE_SHORT_ADDR) { command.pdata.data_req.dst.address[0] = LS_BYTE( dst_addr->short_address @@ -1795,12 +1794,12 @@ static int ca8210_skb_rx( } hdr.source.mode = data_ind[0]; dev_dbg(&priv->spi->dev, "srcAddrMode: %#03x\n", hdr.source.mode); - hdr.source.pan_id = *(u16 *)&data_ind[1]; + hdr.source.pan_id = cpu_to_le16(get_unaligned_le16(&data_ind[1])); dev_dbg(&priv->spi->dev, "srcPanId: %#06x\n", hdr.source.pan_id); memcpy(&hdr.source.extended_addr, &data_ind[3], 8); hdr.dest.mode = data_ind[11]; dev_dbg(&priv->spi->dev, "dstAddrMode: %#03x\n", hdr.dest.mode); - hdr.dest.pan_id = *(u16 *)&data_ind[12]; + hdr.dest.pan_id = cpu_to_le16(get_unaligned_le16(&data_ind[12])); dev_dbg(&priv->spi->dev, "dstPanId: %#06x\n", hdr.dest.pan_id); memcpy(&hdr.dest.extended_addr, &data_ind[14], 8); @@ -1927,7 +1926,7 @@ static int ca8210_skb_tx( status = mcps_data_request( header.source.mode, header.dest.mode, - header.dest.pan_id, + le16_to_cpu(header.dest.pan_id), (union macaddr *)&header.dest.extended_addr, skb->len - mac_len, &skb->data[mac_len],