Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753808AbdLMRqF (ORCPT ); Wed, 13 Dec 2017 12:46:05 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:38592 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753771AbdLMRp5 (ORCPT ); Wed, 13 Dec 2017 12:45:57 -0500 Date: Wed, 13 Dec 2017 17:45:54 +0000 From: Al Viro To: Jakub Kicinski Cc: Linus Torvalds , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC][PATCH] new byteorder primitives - ..._{replace,get}_bits() Message-ID: <20171213174554.GE21978@ZenIV.linux.org.uk> References: <20171212120409.64b6362e@cakuba.netronome.com> <20171212234856.GZ21978@ZenIV.linux.org.uk> <20171212155933.03c88eab@cakuba.netronome.com> <20171213003659.GA21978@ZenIV.linux.org.uk> <20171212170437.4b129e50@cakuba.netronome.com> <20171213013056.GB21978@ZenIV.linux.org.uk> <20171212173528.340cd002@cakuba.netronome.com> <20171213015125.GC21978@ZenIV.linux.org.uk> <20171212184400.13b27cf8@cakuba.netronome.com> <20171213142212.GD21978@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171213142212.GD21978@ZenIV.linux.org.uk> User-Agent: Mutt/1.9.0 (2017-09-02) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 934 Lines: 22 On Wed, Dec 13, 2017 at 02:22:12PM +0000, Al Viro wrote: > Next question: where do we put that bunch? I've put it into > linux/byteorder/generic.h, so that anything picking fixed-endian primitives > would pick those as well; I hadn't thought of linux/bitfield.h at the time. > We certainly could put it there instead - it's never pulled by other headers, > so adding #include into linux/bitfield.h is not going to > cause header order problems. Not sure... > > Linus, do you have any preferences in that area? After looking at some of the callers of bitfield.h stuff: it might be useful to add static inline void le64p_replace_bits(__le64 *p, u64 v, u64 mask) { __le64 m = cpu_to_le64(mask); *p = (*p & ~m) | (cpu_to_le64(v * mask_to_multiplier(mask)) & m); } and similar for other types. Not sure what would be a good name for host-endian variants - u64p_replace_bits() sounds a bit clumsy. Suggestions?