[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f0083401-7bb8-451d-8274-d508c1b55992@nvidia.com>
Date: Tue, 2 Jul 2024 11:57:42 +0000
From: Chaitanya Kulkarni <chaitanyak@...dia.com>
To: Alistair Francis <alistair23@...il.com>, "bhelgaas@...gle.com"
<bhelgaas@...gle.com>, "linux-pci@...r.kernel.org"
<linux-pci@...r.kernel.org>, "Jonathan.Cameron@...wei.com"
<Jonathan.Cameron@...wei.com>, "lukas@...ner.de" <lukas@...ner.de>
CC: "alex.williamson@...hat.com" <alex.williamson@...hat.com>,
"christian.koenig@....com" <christian.koenig@....com>, Chaitanya Kulkarni
<chaitanyak@...dia.com>, "gregkh@...uxfoundation.org"
<gregkh@...uxfoundation.org>, "logang@...tatee.com" <logang@...tatee.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"rdunlap@...radead.org" <rdunlap@...radead.org>, Alistair Francis
<alistair.francis@....com>
Subject: Re: [PATCH v13 3/4] PCI/DOE: Expose the DOE features via sysfs
> @@ -707,6 +773,45 @@ void pci_doe_init(struct pci_dev *pdev)
> pci_doe_destroy_mb(doe_mb);
> }
> }
> +
> + if (doe_mb) {
> + xa_for_each(&doe_mb->feats, i, entry)
> + num_features++;
> +
> + sysfs_attrs = kcalloc(num_features + 1, sizeof(*sysfs_attrs), GFP_KERNEL);
> + if (!sysfs_attrs)
> + return;
> +
> + attrs = kcalloc(num_features, sizeof(*attrs), GFP_KERNEL);
> + if (!attrs) {
> + kfree(sysfs_attrs);
> + return;
> + }
> +
> + doe_mb->device_attrs = attrs;
> + doe_mb->sysfs_attrs = sysfs_attrs;
> +
> + xa_for_each(&doe_mb->feats, i, entry) {
> + sysfs_attr_init(&attrs[i].attr);
> +
> + vid = xa_to_value(entry) >> 8;
> + type = xa_to_value(entry) & 0xFF;
> +
> + attrs[i].attr.name = kasprintf(GFP_KERNEL, "%04lx:%02lx", vid, type);
> + if (!attrs[i].attr.name) {
> + pci_doe_sysfs_feature_remove(pdev, doe_mb);
> + return;
> + }
> + attrs[i].attr.mode = 0444;
> + attrs[i].show = pci_doe_sysfs_feature_show;
> +
> + sysfs_attrs[i] = &attrs[i].attr;
> + }
> +
> + sysfs_attrs[num_features] = NULL;
shouldn't sysfs_attrs[num_features] be already NULL since it's allocated
using kcalloc() ?
> +
> + pci_doe_sysfs_group.attrs = sysfs_attrs;
> + }
-ck
Powered by blists - more mailing lists