public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: Jesse Barnes <jbarnes@engr.sgi.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] export PCI resources in sysfs
Date: Tue, 21 Dec 2004 10:43:55 -0800	[thread overview]
Message-ID: <20041221184355.GB8557@kroah.com> (raw)
In-Reply-To: <200412210943.40101.jbarnes@engr.sgi.com>

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.

thanks,

greg k-h

  reply	other threads:[~2004-12-21 18:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-21 17:43 [PATCH] export PCI resources in sysfs Jesse Barnes
2004-12-21 18:43 ` Greg KH [this message]
2004-12-21 19:09   ` Jesse Barnes
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=20041221184355.GB8557@kroah.com \
    --to=greg@kroah.com \
    --cc=jbarnes@engr.sgi.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