From: Dan Williams <dan.j.williams@intel.com>
To: Alison Schofield <alison.schofield@intel.com>,
Dan Williams <dan.j.williams@intel.com>
Cc: <linux-cxl@vger.kernel.org>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: Re: [PATCH v2] cxl/acpi: Cleanup __cxl_parse_cfmws()
Date: Fri, 1 Mar 2024 11:34:52 -0800 [thread overview]
Message-ID: <65e22ddcab471_2bce9294e2@dwillia2-mobl3.amr.corp.intel.com.notmuch> (raw)
In-Reply-To: <ZeIekICjXpqVUrUG@aschofie-mobl2>
Alison Schofield wrote:
> On Wed, Feb 28, 2024 at 12:30:56PM -0800, Dan Williams wrote:
> > As a follow on to the recent rework of __cxl_parse_cfmws() to always
> > return errors [1], use cleanup.h helpers to remove goto and other cleanups
> > now that logging is moved to the cxl_parse_cfmws() wrapper.
>
> one question about helper below...
>
>
> >
> snip
>
> > +static struct resource *alloc_cxl_resource(resource_size_t base,
> > + resource_size_t n, const char *fmt,
> > + ...)
> > +{
> > + va_list ap;
> > +
> > + struct resource *res __free(kfree) = kzalloc(sizeof(*res), GFP_KERNEL);
> > + if (!res)
> > + return NULL;
> > +
> > + res->start = base;
> > + res->end = base + n - 1;
> > + res->flags = IORESOURCE_MEM;
> > +
> > + va_start(ap, fmt);
> > + res->name = kvasprintf(GFP_KERNEL, fmt, ap);
> > + va_end(ap);
>
> Why is alloc_cxl_resource() defined w variable params and using
> kvasprintf(), rather than tailored to the one caller and used
> kasprintf()?
>
> Perhaps you have bigger plans for this helper?
Good point, thanks! I think this function can just take the window id for now.
diff --git a/drivers/cxl/acpi.c b/drivers/cxl/acpi.c
index 1a47207932e2..db38ead0353a 100644
--- a/drivers/cxl/acpi.c
+++ b/drivers/cxl/acpi.c
@@ -325,25 +325,20 @@ static void del_cxl_resource(struct resource *res)
}
static struct resource *alloc_cxl_resource(resource_size_t base,
- resource_size_t n, const char *fmt,
- ...)
+ resource_size_t n, int id)
{
- va_list ap;
-
struct resource *res __free(kfree) = kzalloc(sizeof(*res), GFP_KERNEL);
+
if (!res)
return NULL;
res->start = base;
res->end = base + n - 1;
res->flags = IORESOURCE_MEM;
-
- va_start(ap, fmt);
- res->name = kvasprintf(GFP_KERNEL, fmt, ap);
- va_end(ap);
-
+ res->name = kasprintf(GFP_KERNEL, "CXL Window %d", id);
if (!res->name)
return NULL;
+
return no_free_ptr(res);
}
@@ -384,9 +379,8 @@ static int __cxl_parse_cfmws(struct acpi_cedt_cfmws *cfmws,
for (i = 0; i < ways; i++)
target_map[i] = cfmws->interleave_targets[i];
- struct resource *res __free(del_cxl_resource) =
- alloc_cxl_resource(cfmws->base_hpa, cfmws->window_size,
- "CXL Window %d", ctx->id++);
+ struct resource *res __free(del_cxl_resource) = alloc_cxl_resource(
+ cfmws->base_hpa, cfmws->window_size, ctx->id++);
if (!res)
return -ENOMEM;
next prev parent reply other threads:[~2024-03-01 19:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-28 20:30 [PATCH v2] cxl/acpi: Cleanup __cxl_parse_cfmws() Dan Williams
2024-03-01 0:57 ` Verma, Vishal L
2024-03-01 18:29 ` Alison Schofield
2024-03-01 19:19 ` Alison Schofield
2024-03-01 19:34 ` Dan Williams [this message]
2024-04-05 22:05 ` [PATCH v3] " Dan Williams
2024-04-05 23:56 ` Alison Schofield
2024-04-22 15:59 ` Jonathan Cameron
2024-04-30 22:46 ` Dan Williams
2024-05-01 12:21 ` Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=65e22ddcab471_2bce9294e2@dwillia2-mobl3.amr.corp.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=alison.schofield@intel.com \
--cc=linux-cxl@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox