[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Ve_EMq=+4gvF449z1tM_oMHwRyYx03WCY-Lcet2JwJsjg@mail.gmail.com>
Date: Sat, 16 Jun 2018 21:50:19 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Yury Norov <ynorov@...iumnetworks.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
agk@...hat.com, Mike Snitzer <snitzer@...hat.com>,
dm-devel@...hat.com, shli@...nel.org, linux-raid@...r.kernel.org,
Dmitry Torokhov <dmitry.torokhov@...il.com>,
linux-input <linux-input@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Mika Westerberg <mika.westerberg@...ux.intel.com>
Subject: Re: [PATCH v2 4/5] Input: gpio-keys - Switch to bitmap_zalloc()
On Sat, Jun 16, 2018 at 1:08 AM Yury Norov <ynorov@...iumnetworks.com> wrote:
>
> On Fri, Jun 15, 2018 at 04:20:16PM +0300, Andy Shevchenko wrote:
> > External Email
> >
> > Switch to bitmap_zalloc() to show clearly what we are allocating.
> > Besides that it returns pointer of bitmap type instead of opaque void *.
>
> Nit. There's no special type for bitmaps, bitmap_zalloc() returns long *.
> Is it less opaque than void *, not sure.
Yes, it enables type checking by compiler, which is good thing.
You can't supply other pointer to this API, like
unsigned char *bar = kmalloc(BITS_PER_LONGS(nbits) * sizeof(unsigned
long), GFP_KERNEL);
...
bitmap_free(bar); //<< compiler will not pass this silently!
Or other way around:
unsigned char *foo = bitmap_alloc(nbits, GFP_KERNEL); //<< wrong types!
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists