Stephen Hemminger wrote: > Change PCI VPD API which was only used by sysfs to something usable > in drivers. > * move iteration over multiple words to the low level > * cleanup types of arguments > * add exportable wrapper > > Signed-off-by: Stephen Hemminger <shemminger@xxxxxxxxxx> > > --- a/drivers/pci/access.c 2008-09-04 10:16:52.000000000 -0700 > +++ b/drivers/pci/access.c 2008-09-04 10:19:47.000000000 -0700 [...] > -static int pci_vpd_pci22_write(struct pci_dev *dev, int pos, int size, > - const char *buf) > +static int pci_vpd_pci22_write(struct pci_dev *dev, loff_t pos, size_t count, > + const void *buf) > { > struct pci_vpd_pci22 *vpd = > container_of(dev->vpd, struct pci_vpd_pci22, base); > - u32 val; > + loff_t end = pos + count; > int ret; > > - if (pos < 0 || pos > vpd->base.len || pos & 3 || > - size > vpd->base.len - pos || size < 4) > + if (pos > vpd->base.len || pos & 3) > return -EINVAL; > > - val = (u8) *buf++; > - val |= ((u8) *buf++) << 8; > - val |= ((u8) *buf++) << 16; > - val |= ((u32)(u8) *buf++) << 24; > - > ret = mutex_lock_killable(&vpd->lock); > if (ret) > return ret; > - ret = pci_vpd_pci22_wait(dev); > - if (ret < 0) > - goto out; > - ret = pci_user_write_config_dword(dev, vpd->cap + PCI_VPD_DATA, > - val); > - if (ret < 0) > - goto out; > - ret = pci_user_write_config_word(dev, vpd->cap + PCI_VPD_ADDR, > - pos | PCI_VPD_ADDR_F); > - if (ret < 0) > - goto out; > - vpd->busy = true; > - vpd->flag = 0; > - ret = pci_vpd_pci22_wait(dev); > -out: > - mutex_unlock(&vpd->lock); > - if (ret < 0) > - return ret; > > - return 4; > + while (pos < end) { > + u32 val; > + > + ret = pci_vpd_pci22_wait(dev); > + if (ret < 0) > + break; > + memcpy(&val, buf, sizeof(u32)); [...] I'm not sure this is correct. pci_user_write_config_dword() expects a value in host byte order, but this memcpy() makes val always little-endian. Ben. -- Ben Hutchings, Senior Software Engineer, Solarflare Communications Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked. -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html