Re: [PATCH] pci: Allow read/write access to I/O port resources

From: Rolf Eike Beer
Date: Mon Jul 19 2010 - 01:58:09 EST


Alex Williamson wrote:
> PCI sysfs resource files currently only allow mmap'ing, which doesn't
> work on all architectures, particularly x86. Add read/write to
> allow access to these device regions using sysfs.

I think you should update that description a bit. It took me some time to find
out you are not talking about mmap() on PCI resource files in general, but
those that are backed by I/O BARs. The other ones work fine on x86 with mmap().

> +static ssize_t
> +pci_resource_io(struct file *filp, struct kobject *kobj,
> + struct bin_attribute *attr, char *buf,
> + loff_t off, size_t count, int write)
> +{

The "write" can be bool.

> + struct pci_dev *pdev = to_pci_dev(container_of(kobj,
> + struct device,
kobj));
> + struct resource *res = (struct resource *)attr->private;

No need to cast here, private is void* anyway.

Eike

Attachment: signature.asc
Description: This is a digitally signed message part.