Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758657AbcCCXTY (ORCPT ); Thu, 3 Mar 2016 18:19:24 -0500 Received: from g9t5009.houston.hp.com ([15.240.92.67]:56848 "EHLO g9t5009.houston.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757773AbcCCXTX (ORCPT ); Thu, 3 Mar 2016 18:19:23 -0500 Message-ID: <1457050323.15454.131.camel@hpe.com> Subject: Re: [PATCH v2 4/4] ACPI: Change NFIT driver to insert new resource From: Toshi Kani To: Dan Williams Cc: Ingo Molnar , Borislav Petkov , "Rafael J. Wysocki" , Andrew Morton , "linux-nvdimm@lists.01.org" , Linux ACPI , "linux-kernel@vger.kernel.org" Date: Thu, 03 Mar 2016 17:12:03 -0700 In-Reply-To: References: <1456959056-12316-1-git-send-email-toshi.kani@hpe.com> <1456959056-12316-5-git-send-email-toshi.kani@hpe.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.4 (3.18.4-1.fc23) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1585 Lines: 37 On Thu, 2016-03-03 at 14:49 -0800, Dan Williams wrote: > On Wed, Mar 2, 2016 at 2:50 PM, Toshi Kani 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