From patchwork Wed Feb 14 15:54:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Wajdeczko X-Patchwork-Id: 200999 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:bc8a:b0:106:860b:bbdd with SMTP id dn10csp1313271dyb; Wed, 14 Feb 2024 08:02:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+VQwtYZP2JPpzB5lolxYQNf5BSq+MdQjXi5tH8ts74aUAe4XMOFS6ggCmCJGc+8gGn4bL1UHgJN3VMlXKfiHBILFOzw== X-Google-Smtp-Source: AGHT+IGHUikHaRdGcgWJ4vefM0xOvBXCGvos7P6PYrt+omnEAXBk4gDi804CuhicNoR+RrP+8IHZ X-Received: by 2002:a17:906:c950:b0:a3c:d965:8c4c with SMTP id fw16-20020a170906c95000b00a3cd9658c4cmr2074407ejb.72.1707926534739; Wed, 14 Feb 2024 08:02:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707926534; cv=pass; d=google.com; s=arc-20160816; b=U26RU5PUoohQbRy6RjdX5HCWOaQVYBwZBdBPXFe5Vk65ht+tuPprG8NfTaIYeNbD+b g8Bi/D4qZXZMGyMey5Dm/jcmbSAwGPhaRcuYwGpZ9r8XvxYl2m8h0c9BMvEScvbNG0dY HXmt2U7RKvfm2Etyis24GsGy6rX1j4fKSgBczMLL3e+D7Sz0bXC7CwaqtqWOtK1JvWvR OUB7Zgjh6IAFQ9b/0dbSQOIBFIcyzcEehSVtOsA3vFVHpGPdZ+ziem7BFxuSUjfUushV O7IyDl6ytzH9/vw8nRd2YZQR1wbA0X07IF/hjFzK1SBWTM8o7doRlB87viDrhYtjNI1I lyKA== 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=j8gdzCFL5LObGfpDLVmFr1WXUxId0AkzrTQMEcRpeyI=; b=a9+cztvsQ6+jjVWgsk3QcOPNJc4kXeWLLiFEEF+aqwHSEUW1JuIyHvba7hyEmq/edw LyXasp60CwEZd/DKi7jMIdxAXE+Wrr0GDkIQfLDrXSQ5D6qhVeR1jfYOXquN9Addm+Pc 59RvpoFCU6KxB6M3o3h7MiUTGIBE+dwKAQi/F/BFn5UkaMkX2bPMWqQ9UWVztlobPmzs GjWtFuhD0AknDs1JkwiFxKCSMpLkYXs2bbPajqAdKcDizw+Jn5vTa81nigBwL3BsWROU k7rZ6uflWdlZFlCOkVCuQiC1KIZvUnOI3u0IBIoSCawNPD4+xbYrH8rXHUjbjQDAmu8P +5ew==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65463-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCWNySQ7JRyYVj2lJW2MNDJXGizwzhSBRWVFh2ygc9WpxNvTBO9guDz96528CS7Q6ILLQGN8nouGmZZg/OM9h9wk60qLwQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x22-20020a170906135600b00a3c7789a356si2343911ejb.1039.2024.02.14.08.02.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 08:02:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65463-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65463-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 72F4D1F2B3F4 for ; Wed, 14 Feb 2024 15:54:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 838AD5EE90; Wed, 14 Feb 2024 15:54:40 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790890774384084502 X-GMAIL-MSGID: 1790890774384084502 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