Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1639732
| From | Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] omapfb: Use devm_kcalloc() in vrfb_probe() |
| Date | 2017-05-11 17:30 +0200 |
| Message-ID | <tFYcq-859-21@gated-at.bofh.it> (permalink) |
| References | <tFXgn-7ta-55@gated-at.bofh.it> <tArAu-oA-9@gated-at.bofh.it> <tFXgn-7ta-53@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thursday, May 11, 2017 04:27:19 PM Bartlomiej Zolnierkiewicz wrote:
> > @@ -358,11 +358,7 @@ static int __init vrfb_probe(struct platform_device *pdev)
> > return PTR_ERR(vrfb_base);
> >
> > num_ctxs = pdev->num_resources - 1;
> > -
> > - ctxs = devm_kzalloc(&pdev->dev,
> > - sizeof(struct vrfb_ctx) * num_ctxs,
> > - GFP_KERNEL);
> > -
> > + ctxs = devm_kcalloc(&pdev->dev, num_ctxs, sizeof(*ctxs), GFP_KERNEL);
>
> This change makes the resulting binary larger by 24 bytes (probably
> because of the need to have an additional function argument) and
24 bytes seemed too much for just an additional function argument
so I've checked the source:
static inline void *devm_kzalloc(struct device *dev, size_t size, gfp_t gfp)
{
return devm_kmalloc(dev, size, gfp | __GFP_ZERO);
}
static inline void *devm_kmalloc_array(struct device *dev,
size_t n, size_t size, gfp_t flags)
{
if (size != 0 && n > SIZE_MAX / size)
return NULL;
return devm_kmalloc(dev, n * size, flags);
}
static inline void *devm_kcalloc(struct device *dev,
size_t n, size_t size, gfp_t flags)
{
return devm_kmalloc_array(dev, n, size, flags | __GFP_ZERO);
}
The extra kcalloc() checks are inlined currently into each instance.
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] omapfb: Use devm_kcalloc() in vrfb_probe() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-04-26 11:40 +0200
Re: [PATCH] omapfb: Use devm_kcalloc() in vrfb_probe() Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> - 2017-05-11 16:30 +0200
Re: [PATCH] omapfb: Use devm_kcalloc() in vrfb_probe() Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> - 2017-05-11 17:30 +0200
Re: [PATCH] omapfb: Use devm_kcalloc() in vrfb_probe() Geert Uytterhoeven <geert@linux-m68k.org> - 2017-05-12 09:10 +0200
csiph-web