From: Jesse Barnes <jbarnes@engr.sgi.com>
To: Greg KH <greg@kroah.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] export PCI resources in sysfs
Date: Tue, 21 Dec 2004 11:09:03 -0800 [thread overview]
Message-ID: <200412211109.03826.jbarnes@engr.sgi.com> (raw)
In-Reply-To: <20041221184355.GB8557@kroah.com>
On Tuesday, December 21, 2004 10:43 am, Greg KH wrote:
> On Tue, Dec 21, 2004 at 09:43:39AM -0800, Jesse Barnes wrote:
> > int pci_create_sysfs_dev_files (struct pci_dev *pdev)
> > {
> > +#ifdef HAVE_PCI_MMAP
> > + int i;
> > +#endif
> > +
> > if (!sysfs_initialized)
> > return -EACCES;
> >
> > @@ -269,6 +300,31 @@
> > else
> > sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr);
> >
> > +#ifdef HAVE_PCI_MMAP
> > + /* Expose the PCI resources from this device as files */
> > + for (i = 0; i < PCI_ROM_RESOURCE; i++) {
> > + struct bin_attribute *res_attr;
> > +
> > + /* skip empty resources */
> > + if (!pci_resource_len(pdev, i))
> > + continue;
> > +
> > + res_attr = kmalloc(sizeof(*res_attr) + 10, GFP_ATOMIC);
> > + if (res_attr) {
> > + pdev->res_attr[i] = res_attr;
> > + /* Allocated above after the res_attr struct */
> > + res_attr->attr.name = (char *)(res_attr + 1);
> > + sprintf(res_attr->attr.name, "resource%d", i);
> > + res_attr->size = pci_resource_len(pdev, i);
> > + res_attr->attr.mode = S_IRUSR | S_IWUSR;
> > + res_attr->attr.owner = THIS_MODULE;
> > + res_attr->mmap = pci_mmap_resource;
> > + res_attr->private = &pdev->resource[i];
> > + sysfs_create_bin_file(&pdev->dev.kobj, res_attr);
> > + }
> > + }
> > +#endif /* HAVE_PCI_MMAP */
>
> How about wrapping these two #ifdef blocks into one function, and moving
> it up in the file under the other #ifdef. Do that for the other cleanup
> function, and it will drop a bunch of #ifdefs.
Yeah, that sounds good. I really don't like adding these ifdefs, and limiting
their scope to a function somewhere up above would be nicer. I'll do that
and respin.
Thanks,
Jesse
next prev parent reply other threads:[~2004-12-21 19:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-21 17:43 Jesse Barnes
2004-12-21 18:43 ` Greg KH
2004-12-21 19:09 ` Jesse Barnes [this message]
2004-12-21 19:56 ` Jesse Barnes
2004-12-21 20:18 ` Greg KH
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=200412211109.03826.jbarnes@engr.sgi.com \
--to=jbarnes@engr.sgi.com \
--cc=greg@kroah.com \
--cc=linux-kernel@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
Powered by JetHome