[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <SA2PR11MB5018D896774B86B57354D32ED9AC0@SA2PR11MB5018.namprd11.prod.outlook.com>
Date: Sun, 10 Jan 2021 17:22:32 +0000
From: "Chen, Mike Ximing" <mike.ximing.chen@...el.com>
To: Greg KH <gregkh@...uxfoundation.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"arnd@...db.de" <arnd@...db.de>,
"Williams, Dan J" <dan.j.williams@...el.com>,
"pierre-louis.bossart@...ux.intel.com"
<pierre-louis.bossart@...ux.intel.com>
Subject: RE: [PATCH v8 03/20] dlb: add resource and device initialization
> -----Original Message-----
> From: Greg KH <gregkh@...uxfoundation.org>
> Sent: Thursday, January 7, 2021 2:40 PM
> To: Chen, Mike Ximing <mike.ximing.chen@...el.com>
> Cc: linux-kernel@...r.kernel.org; arnd@...db.de; Williams, Dan J
> <dan.j.williams@...el.com>; pierre-louis.bossart@...ux.intel.com; Gage Eads
> <gage.eads@...el.com>
> Subject: Re: [PATCH v8 03/20] dlb: add resource and device initialization
>
> On Mon, Jan 04, 2021 at 08:58:22PM -0600, Mike Ximing Chen wrote:
> > Introduce dlb_bitmap_* functions, a thin convenience layer wrapping the
> > Linux bitmap interfaces, used by the bitmaps in the dlb hardware types.
>
> No, you created custom #defines:
>
> > --- a/drivers/misc/dlb/dlb_hw_types.h
> > +++ b/drivers/misc/dlb/dlb_hw_types.h
> > @@ -5,6 +5,15 @@
> > #define __DLB_HW_TYPES_H
> >
> > #include <linux/io.h>
> > +#include <linux/types.h>
> > +
> > +#include "dlb_bitmap.h"
> > +
> > +#define BITS_SET(x, val, mask) (x = ((x) & ~(mask)) \
> > + | (((val) << (mask##_LOC)) & (mask)))
> > +#define BITS_CLR(x, mask) ((x) &= ~(mask))
> > +#define BIT_SET(x, mask) ((x) |= (mask))
> > +#define BITS_GET(x, mask) (((x) & (mask)) >> (mask##_LOC))
>
> We have functions for this, use them, don't create custom macros for
> them. Use the Linux functions please.
>
> thanks,
>
> greg k-h
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 use them?
Thanks
Mike
Powered by blists - more mailing lists