/* Put @count bytes starting at @off into @buf from the ROM in the PCI device corresponding to @kobj.  */
static ssize_t pci_read_rom(struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
/* Put @count bytes starting at @off into @buf from the ROM in the PCI device corresponding to @kobj.  */
static ssize_t pci_read_rom(struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count)
{
	struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj));
	void __iomem *rom;
	size_t size;
	if (!pdev->rom_attr_enabled)
		return -EINVAL;
	rom = pci_map_rom(pdev, &size);
	if (!rom || !size)
		return -EIO;
	if (off >= size)
		count = 0;
	else {
		if (off + count > size)
			count = size - off;
		memcpy_fromio(buf, rom + off, count);
	}
	pci_unmap_rom(pdev, rom);
	return count;
}