lkml.org 
[lkml]   [2014]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2 07/14] regulator: s2mps11: Copy supported regulators from initconst
From
Date
On Thu, 2014-02-13 at 19:07 +0000, Mark Brown wrote:
> On Thu, Feb 13, 2014 at 10:14:00AM +0100, Krzysztof Kozlowski wrote:
>
> > - for (i = 0; i < S2MPS11_REGULATOR_CNT; i++)
> > + s2mps11->rdev = devm_kzalloc(&pdev->dev,
> > + sizeof(*s2mps11->rdev)*rdev_num, GFP_KERNEL);
> > + if (!s2mps11->rdev)
> > + return -ENOMEM;
>
> If we're using managed allocations do we actually need to keep the rdev
> table at all? We only normally use it to free.

You're right, the "s2mps11->rdev" is not needed at all.

>
> > + rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata)*rdev_num, GFP_KERNEL);
> > + if (!rdata)
> > + return -ENOMEM;
> > +
>
> > + /* rdata was needed only for of_regulator_match() during probe */
> > + if (rdata)
> > + devm_kfree(&pdev->dev, rdata);
> > +
>
> If this is always going to be freed within the probe path (in the same
> function indeed) why is it a managed allocaton at all?

Actually no good reason, simplifies a little the return statements on
error conditions. I'll use kzalloc() and kfree().

Best regards,
Krzysztof



\
 
 \ /
  Last update: 2014-02-14 09:21    [W:0.233 / U:0.456 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site