Re: [PATCH v2 4/4] ACPI: Change NFIT driver to insert new resource

From: Toshi Kani
Date: Thu Mar 03 2016 - 18:19:26 EST


On Thu, 2016-03-03 at 14:49 -0800, Dan Williams wrote:
> On Wed, Mar 2, 2016 at 2:50 PM, Toshi Kani <toshi.kani@xxxxxxx> wrote:
Â:
> > diff --git a/drivers/acpi/nfit.c b/drivers/acpi/nfit.c
> > index fb53db1..d97b53f 100644
> > --- a/drivers/acpi/nfit.c
> > +++ b/drivers/acpi/nfit.c
> > @@ -1571,6 +1571,30 @@ static int ars_status_process_records(struct
> > nvdimm_bus *nvdimm_bus,
> > ÂÂÂÂÂÂÂÂreturn 0;
> > Â}
> >
> > +static int acpi_nfit_insert_resource(struct acpi_nfit_desc *acpi_desc,
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂstruct nd_region_desc *ndr_desc)
> > +{
> > +ÂÂÂÂÂÂÂstruct resource *res, *nd_res = ndr_desc->res;
> > +ÂÂÂÂÂÂÂsize_t size = nd_res->end - nd_res->start + 1;
> > +
> > +ÂÂÂÂÂÂÂ/* No operation if the region is already registered as PMEM */
> > +ÂÂÂÂÂÂÂif (region_intersects(nd_res->start, size, IORESOURCE_MEM,
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂIORES_DESC_PERSISTENT_MEMORY) ==
> > REGION_INTERSECTS)
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn 0;
> > +
> > +ÂÂÂÂÂÂÂres = devm_kzalloc(acpi_desc->dev, sizeof(*res), GFP_KERNEL);
>
> How about allocating this resource on the stack and then have
> devm_insert_resource handle the dynamic allocation (memdup) so we have
> one less failure point to handle in the driver.

I like the idea, but existing callers of insert_resource() allocate a
resource either statically or dynamically. ÂIt may be contained by other
structure as well. ÂSo, I think devm_insert_resource() should be consistent
with insert_resource() on this regard.Â

Thanks,
-Toshi