From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C79D1C433DB for ; Wed, 10 Mar 2021 08:14:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A410264FCE for ; Wed, 10 Mar 2021 08:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231183AbhCJIN6 (ORCPT ); Wed, 10 Mar 2021 03:13:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:49984 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231293AbhCJINf (ORCPT ); Wed, 10 Mar 2021 03:13:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B400F64FCE; Wed, 10 Mar 2021 08:13:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615364007; bh=7nUcNZr12utVPnw8WOSH71VwFcj/vspELHCKCeOftsY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kspCqylVJqSTeOBQQfYHRbJdcAXl4qzRD/UnCQx6mtsBwKVprHIAeDANgYgyUkttx ukHd/K4uPaf6wkLHwYnbl6SJYELWVo+MF4aGmWaY0Jc72GGX3ojg7CU61igoeTcVCT pAtidaaNazquN7C1EzCWk7MLHVg+JigQXNk0b8A8= Date: Wed, 10 Mar 2021 09:13:24 +0100 From: Greg KH To: "Chen, Mike Ximing" Cc: "netdev@vger.kernel.org" , "davem@davemloft.net" , "kuba@kernel.org" , "arnd@arndb.de" , "Williams, Dan J" , "pierre-louis.bossart@linux.intel.com" , Gage Eads Subject: Re: [PATCH v10 03/20] dlb: add resource and device initialization Message-ID: References: <20210210175423.1873-1-mike.ximing.chen@intel.com> <20210210175423.1873-4-mike.ximing.chen@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Mar 10, 2021 at 01:33:24AM +0000, Chen, Mike Ximing wrote: > > > -----Original Message----- > > From: Greg KH > > > > On Wed, Feb 10, 2021 at 11:54:06AM -0600, Mike Ximing Chen wrote: > > > + > > > +#include "dlb_bitmap.h" > > > + > > > +#define BITS_SET(x, val, mask) (x = ((x) & ~(mask)) \ > > > + | (((val) << (mask##_LOC)) & (mask))) > > > +#define BITS_GET(x, mask) (((x) & (mask)) >> (mask##_LOC)) > > > > Why not use the built-in kernel functions for this? Why are you > > creating your own? > > > FIELD_GET(_mask, _val) and FIELD_PREP(_mask, _val) in include/linux/bitfield.h > are similar to our BITS_GET() and BITS_SET(). However in our case, mask##_LOC > is a known constant defined in dlb_regs.h, so we don't need to use > _buildin_ffs(mask) to calculate the location of mask as FIELD_GET() and FIELD_PREP() > do. We can still use FIELD_GET and FIELD_PREP, but our macros are a little more > efficient. Would it be OK to keep them? No, please use the kernel-wide proper functions, there's no need for single tiny driver to be "special" in this regard. If somehow the in-kernel functions are not sufficient, it's always better to fix them up than to go your own way here. thanks, greg k-h