usb: dwc3: ep0: add handling for unaligned OUT transfers
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / pci / vpd.c
bloba5a5ca17cfe6bd9bb28afc0248546f80dca6cf99
1 /*
2 * File: vpd.c
3 * Purpose: Provide PCI VPD support
5 * Copyright (C) 2010 Broadcom Corporation.
6 */
8 #include <linux/pci.h>
10 int pci_vpd_find_tag(const u8 *buf, unsigned int off, unsigned int len, u8 rdt)
12 int i;
14 for (i = off; i < len; ) {
15 u8 val = buf[i];
17 if (val & PCI_VPD_LRDT) {
18 /* Don't return success of the tag isn't complete */
19 if (i + PCI_VPD_LRDT_TAG_SIZE > len)
20 break;
22 if (val == rdt)
23 return i;
25 i += PCI_VPD_LRDT_TAG_SIZE +
26 pci_vpd_lrdt_size(&buf[i]);
27 } else {
28 u8 tag = val & ~PCI_VPD_SRDT_LEN_MASK;
30 if (tag == rdt)
31 return i;
33 if (tag == PCI_VPD_SRDT_END)
34 break;
36 i += PCI_VPD_SRDT_TAG_SIZE +
37 pci_vpd_srdt_size(&buf[i]);
41 return -ENOENT;
43 EXPORT_SYMBOL_GPL(pci_vpd_find_tag);
45 int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
46 unsigned int len, const char *kw)
48 int i;
50 for (i = off; i + PCI_VPD_INFO_FLD_HDR_SIZE <= off + len;) {
51 if (buf[i + 0] == kw[0] &&
52 buf[i + 1] == kw[1])
53 return i;
55 i += PCI_VPD_INFO_FLD_HDR_SIZE +
56 pci_vpd_info_field_size(&buf[i]);
59 return -ENOENT;
61 EXPORT_SYMBOL_GPL(pci_vpd_find_info_keyword);