From patchwork Wed Mar 5 10:55:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 14002446 X-Patchwork-Delegate: kuba@kernel.org Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 D5AA420C497; Wed, 5 Mar 2025 10:57:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741172225; cv=none; b=kSQIs+kfJC43cjLH2DYfjwB8iKfnlJ0ZQIhXm0ufOy2PDI3nHIYek8LY+VllsK1YjoBut+zqKgUwjR3ZNxK+yyic2ocLTBvNANY/Goe98Yfx3ukFzN3noz4ioHqLP0xj6V+UARhmr1un6bNY+Zna1OcR8mq5NCq252G3B2ZbeZ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741172225; c=relaxed/simple; bh=RSx3iAtB8qEjTFC1vJZKBwt/OD98kvw3pGfE1JEQ6Kc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OCicHEn1gnCI93lO1sXk1JS8yCO6XZxUllFxO07F9hNPWp7czzm0cvB/b+PFTpM+5GtgXKznLWDl4amRx2qEa/cDUwOOh8wX3qitEU87kc9bnw75e+QgxsUZARSxB0NOi3MduCIoKlaXPMDvdtITPdzc+tleQNZSYhDbO7bollc= 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=jU/U3HHl; arc=none smtp.client-ip=192.198.163.7 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="jU/U3HHl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1741172224; x=1772708224; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RSx3iAtB8qEjTFC1vJZKBwt/OD98kvw3pGfE1JEQ6Kc=; b=jU/U3HHlKkraeFK8fvl+lvYHi+l9CoZRilGQ7l1/aTgP1yjUUDfvGAqN naCtO2qTpFIjk+FWlIGKfIQjv+ReszphOjDB4kvpZAqaBrmx1MFyEpzRK GqU4XIx/St2cUZYzmtZLgX0r5DpolGSnMHCsvGKbD+1jXnFK/w8rGkYaV 7HtOB4KybCss4Hxrkin3j4Ao+I4TOBurg6OEoQkVnSOb3LGFrCTLN+uOd vsdtzYL4F+VZHzega16BklyBsjdzeytxkEwE/9Nf9RldsjYXyQJ0hF2JY b9t/n9DKmQ2Gf32lhfKzvN7CAy7NsU96VXnGQk/BP/egozXQNisr8mmgN Q==; X-CSE-ConnectionGUID: V7FdItoKQ7ytFBbyBEb1UA== X-CSE-MsgGUID: /YB2AByNTMqsVbBI7pBA2w== X-IronPort-AV: E=McAfee;i="6700,10204,11363"; a="67497627" X-IronPort-AV: E=Sophos;i="6.14,222,1736841600"; d="scan'208";a="67497627" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2025 02:57:02 -0800 X-CSE-ConnectionGUID: ib2IBscjQoqkM/xZqFXrDA== X-CSE-MsgGUID: blUSDORYTqe4xLO375bbGQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.14,222,1736841600"; d="scan'208";a="118483427" Received: from black.fi.intel.com ([10.237.72.28]) by fmviesa006.fm.intel.com with ESMTP; 05 Mar 2025 02:56:58 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 884D21FD; Wed, 05 Mar 2025 12:56:57 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Miquel Raynal , Linus Walleij , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org Cc: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bartosz Golaszewski , Alexander Aring , Stefan Schmidt Subject: [PATCH net-next v4 1/4] ieee802154: ca8210: Use proper setters and getters for bitwise types Date: Wed, 5 Mar 2025 12:55:34 +0200 Message-ID: <20250305105656.2133487-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250305105656.2133487-1-andriy.shevchenko@linux.intel.com> References: <20250305105656.2133487-1-andriy.shevchenko@linux.intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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 setters 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 Reviewed-by: Linus Walleij 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],