Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp670680rdh; Wed, 14 Feb 2024 08:06:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLP8RSrfmkLMZqTX7kEPxJc+/bsYIBtXm44HIk/w5sCSwiHNrtpgKgeiH3naeDrjspsWUm5up2iyJsM/1piJAlA3DT8Qp35Q8hwxTsLQ== X-Google-Smtp-Source: AGHT+IE/imqSHVZmWViz4SwG2Uu0Oai1F0R3ZLBmnuG5HLuXnkhi/TxdD4NQtBkHUHmbxp+m0PSB X-Received: by 2002:a17:902:9698:b0:1d9:f8a8:3bc6 with SMTP id n24-20020a170902969800b001d9f8a83bc6mr3018157plp.30.1707926816246; Wed, 14 Feb 2024 08:06:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707926816; cv=pass; d=google.com; s=arc-20160816; b=xh8Q5+vEJ4GiHduAU50nhmtMOflhljQ+u5kMb6wqbyIR95xawu2AVKB8bjibdHSxla 5LIok/rh4Gkzth7r4zE8FIVEPijcXguwJXRhIzafzsRP2I/ERq/QjKew9q/qJt2YhTAT KgukkF/KceCnFyX2iNlln1Txmq0AbVJ+ogcJU6OdaMX+jg0wIHNf6UMt9egIqFdkxbn0 8zL8eHHTJs3/nUtx54Z34mRc2Kf0B3pCVQ1SRq11+SiW0mZr6QE0yHDEprK9Y119fYMA Rch9RbBzWzjfRJF9X59h3pqShQ4W1+T8J/3LCPDl5JmHbvpZzSUfoel+Uveo+oBCo/xn lWNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=heK/ksu6sNCKite4AScx0Vhw/nGEJjdYGdJhCwWHcMA=; fh=C97mEmz1nCGXAsCq03tRtBKPY03whoZBR3KZWJ4chnI=; b=QoORBJ9Zq3/kUMgbhzfSrKwB6fisZF1bT2tI1CjZHLcGHn5tJVzmsXKLWPLz0s4+Kt 0Cl5rkqbQaWBCxHL2jsC0HYSsbWeWOrOPAsW84aX8RvKNn9q3scZYqjvm/eBqKu4rzlR OlKWtn6a7Rw44CBs0Q2b5YaJ/P/KciHsDGe/qmSi8QgPCWcEtPj3mDDU0stpONCCMLCe fXs85A9H2OheVKDU5QvcT1flVdMH0bImw31FJQojEYIuX1GXf5R5HDh4zmQRRv2CgnW1 ApZPvjQbVjZFlfUBSwr/wKZu1myRy07wMXoXMfI9KwpfgpvNPAawIwfwiGdeCBwiU831 AGUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ePB/i5iO"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-65463-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65463-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCWObIgGH6W1qjl7ly1QqJH5zlnR5A6U15OhauhPa5VduA2DyYCo9SI0dhRtFhnRT61xPnE633YCA43PUf5k6MyhOPG0+tasXAMMeJW0oA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f1-20020a170902684100b001db29e4bbd5si3683959pln.281.2024.02.14.08.06.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 08:06:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65463-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="ePB/i5iO"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-65463-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65463-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9D76728B1B2 for ; Wed, 14 Feb 2024 15:54:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B57EA5D912; Wed, 14 Feb 2024 15:54:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ePB/i5iO" 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 127295CDC9 for ; Wed, 14 Feb 2024 15:54:35 +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=1707926077; cv=none; b=hOzWuKXN8wcacffbM6cIIl3KJKxBQTPaQhuBEvuV+kOTqrQyPClxYlPKwKlCp5sb21qYxd4e+vJ0QU3v0QGorV9jQU9dztm79d3FDMjDUQ10kd7fzfmbuIArWSqU+b6L3vC7X1Hog6yNutWRedtUzMJqyWuKrx2E03S5WvqA9z0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707926077; c=relaxed/simple; bh=VujCBmuxbzMp+KdK6LlDdgxP+TebDwZSMVtNMdB+1dk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Moztk4SuppTvN6yDPi/WvmK77+khyvGlQh+g697MKYhpjGERqZ/wInIc2v3FDRjvFLFQezwZa4TM7800PLsotqpiyjFSC7p8I6a+/ApoAHWAeHiv3ERzKjBSv8ukkmuiZbOFq/DZWOpjCzB5LcjEAZHU08f5JMVXoWnitDFJ73Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=ePB/i5iO; arc=none smtp.client-ip=198.175.65.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707926076; x=1739462076; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=VujCBmuxbzMp+KdK6LlDdgxP+TebDwZSMVtNMdB+1dk=; b=ePB/i5iOgRqR+TKngGnIwkiCkZdXhOx4k4PQNoTEsM4JtRbRasWS4QCc hToqIfHjC7FH5A956rsf4kjKMpK1SbEYWie2dDFxGueuLl4NM9UiIt1WZ VZC3kxyvbs2tQsby3VnUe9CMOoYOkgB3GoGXpy/XeUo/YzJhuv0hjt3sA 3MpbQJzuEZFmapGVFytheltGkCBiigdxQvKEERYsSAPSTP+ptQNCkIplE Pa2in3PC6ikIs5W3kZQJUeZqwPhJHs8/DjqviNMsHKDuSIH1s6U5DcEi6 c4Hk1DsESa9Yy2MVy6ThIADHHOnjch6LttdI57rFQch1W6EzQOar6gqVO w==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="13071861" X-IronPort-AV: E=Sophos;i="6.06,159,1705392000"; d="scan'208";a="13071861" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 07:54:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,159,1705392000"; d="scan'208";a="7893650" Received: from mwajdecz-mobl.ger.corp.intel.com ([10.249.138.241]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Feb 2024 07:54:34 -0800 From: Michal Wajdeczko To: linux-kernel@vger.kernel.org Cc: Michal Wajdeczko , Andy Shevchenko , Rodrigo Vivi , Jani Nikula Subject: [RFC] include/linux/make_type.h: Helpers for making u16/u32/u64 values Date: Wed, 14 Feb 2024 16:54:08 +0100 Message-Id: <20240214155408.1569-1-michal.wajdeczko@intel.com> X-Mailer: git-send-email 2.21.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit It is quite common practice to make u16, u32 or u64 values from smaller words. Add simple helpers for that. Signed-off-by: Michal Wajdeczko Cc: Andy Shevchenko Cc: Rodrigo Vivi Cc: Jani Nikula --- include/linux/make_type.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 include/linux/make_type.h diff --git a/include/linux/make_type.h b/include/linux/make_type.h new file mode 100644 index 000000000000..60e2e091ea3c --- /dev/null +++ b/include/linux/make_type.h @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LINUX_MAKE_TYPE_H +#define _LINUX_MAKE_TYPE_H + +#include + +/** + * make_u16 - make u16 value from two u8 values + * @hi__: value representing upper 8 bits + * @lo__: value representing lower 8 bits + */ +#define make_u16(hi__, lo__) ((u16)(u8)(hi__) << 8 | (u8)(lo__)) + +/** + * make_u32 - make u32 value from two u16 values + * @hi__: value representing upper 16 bits + * @lo__: value representing lower 16 bits + */ +#define make_u32(hi__, lo__) ((u32)(u16)(hi__) << 16 | (u16)(lo__)) + +/** + * make_u64 - make u64 value from two u32 values + * @hi__: value representing upper 32 bits + * @lo__: value representing lower 32 bits + */ +#define make_u64(hi__, lo__) ((u64)(hi__) << 32 | (u32)(lo__)) + +#endif -- 2.43.0