lkml.org 
[lkml]   [2004]   [Aug]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] add PCI ROMs to sysfs
On Thu, Aug 26, 2004 at 12:54:59PM -0700, Jon Smirl wrote:
> New version that uses the PCI data structure to get the size. It's
> against 2.6.9-rc1-mm1, but that kernel is DOA on my machine.
>
> I was confused about the type 0 versus other types and see that this
> code doesn't need to know the ROM type.

A few more bugfixes:

- I was confused, it was hex 18, not decimal 16
- Its/it's again ;-)
- Only return the bits of the ROM that are in PCI format
- Remove the actual resource, not some strange static one
- Delete the static one that wasn't really used.

BTW, what do you think to moving all the ROM code from pci-sysfs.c to a
new file rom.c? There's not much sense to the ROM accessing code being
mixed in with the sysfs code like this. After all, we might choose to
expose the ROM in some other way in the future.

diff -u edited/drivers/pci/pci-sysfs.c vpd-2.6/drivers/pci/pci-sysfs.c
--- edited/drivers/pci/pci-sysfs.c Thu Aug 26 15:21:02 2004
+++ vpd-2.6/drivers/pci/pci-sysfs.c 27 Aug 2004 19:33:37 -0000
@@ -262,8 +262,8 @@
break;
if (readb(image + 1) != 0xAA)
break;
- /* get the PCI data structure and check it's signature */
- pds = image + readw(image + 16);
+ /* get the PCI data structure and check its signature */
+ pds = image + readw(image + 24);
if (readb(pds) != 'P')
break;
if (readb(pds + 1) != 'C')
@@ -277,8 +277,7 @@
image += readw(pds + 16) * 512;
} while (!last_image);

- if (image != rom)
- *size = min((size_t)(image - rom), *size); /* make sure we didn't include an adjacent ROM */
+ *size = image - rom;

return rom;
}
@@ -340,8 +342,6 @@
pci_disable_rom(pdev);
}

-static struct bin_attribute rom_attr;
-
/**
* pci_remove_rom - disable the ROM and remove its sysfs attribute
* @dev: pointer to pci device struct
@@ -353,7 +353,7 @@
struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];

if (pci_resource_len(pdev, PCI_ROM_RESOURCE))
- sysfs_remove_bin_file(&pdev->dev.kobj, &rom_attr);
+ sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);
if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW | IORESOURCE_ROM_COPY)))
pci_disable_rom(pdev);
}

--
"Next the statesmen will invent cheap lies, putting the blame upon
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince
himself that the war is just, and will thank God for the better sleep
he enjoys after this process of grotesque self-deception." -- Mark Twain
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:05    [W:0.120 / U:0.444 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site