[flashrom] [PATCH] Clean up board enable matching
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Fri Aug 10 01:59:37 CEST 2012
This is an update of a really old patch.
User-visible changes: You have to specify vendor+mainboard for the
internal:mainboard= parameter. The vendor name is no longer optional.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
Index: flashrom-cbtable_matching_cleanup/board_enable.c
===================================================================
--- flashrom-cbtable_matching_cleanup/board_enable.c (Revision 1567)
+++ flashrom-cbtable_matching_cleanup/board_enable.c (Arbeitskopie)
@@ -2447,37 +2447,50 @@
* Match boards on coreboot table gathered vendor and part name.
* Require main PCI IDs to match too as extra safety.
*/
-static const struct board_match *board_match_cbname(const char *vendor,
- const char *part)
+static const struct board_match *board_match_cbname(const char *vendor, const char *part)
{
const struct board_match *board = board_matches;
const struct board_match *partmatch = NULL;
+ /* If a board uses coreboot, we have full vendor+part name.
+ * If a board doesn't use coreboot, we have DMI.
+ * If a board has no useful DMI and no coreboot table and no subsystem IDs, the user should specify
+ * full board vendor+part name.
+ */
+ if ((!vendor && part) || (vendor && !part)) {
+ msg_pinfo("Please supply board vendor and part name.\n");
+ return NULL;
+ }
+ if (!vendor && !part)
+ return NULL;
+
for (; board->vendor_name; board++) {
- if (vendor && (!board->lb_vendor
- || strcasecmp(board->lb_vendor, vendor)))
+ if (!board->lb_vendor || strcasecmp(board->lb_vendor, vendor))
continue;
if (!board->lb_part || strcasecmp(board->lb_part, part))
continue;
- if (!pci_dev_find(board->first_vendor, board->first_device))
+ if (!pci_dev_find(board->first_vendor, board->first_device)) {
+ msg_pdbg("Odd. coreboot name \"%s\":\"%s\" matches, but first PCI device %04x:%04x "
+ "doesn't.\n", vendor, part, board->first_vendor, board->first_device);
continue;
+ }
+ /* FIXME: Once the entries for agami Aruma and IWILL DK8-HTX are fixed to have a second PCI
+ * device, we can run pci_dev_find unconditionally.
+ */
if (board->second_vendor &&
- !pci_dev_find(board->second_vendor, board->second_device))
+ !pci_dev_find(board->second_vendor, board->second_device)) {
+ msg_pdbg("Odd. coreboot name \"%s\":\"%s\" matches, but second PCI device %04x:%04x "
+ "doesn't.\n", vendor, part, board->second_vendor, board->second_device);
continue;
+ }
- if (vendor)
- return board;
-
if (partmatch) {
- /* a second entry has a matching part name */
- msg_pinfo("AMBIGUOUS BOARD NAME: %s\n", part);
- msg_pinfo("At least vendors '%s' and '%s' match.\n",
- partmatch->lb_vendor, board->lb_vendor);
- msg_perr("Please use the full -p internal:mainboard="
- "vendor:part syntax.\n");
+ /* More than one entry has a matching name. */
+ msg_perr("Board name \"%s\":\"%s\" and PCI IDs matched more than one board enable "
+ "entry. Please report a bug at flashrom at flashrom.org\n", part, vendor);
return NULL;
}
partmatch = board;
@@ -2487,12 +2500,10 @@
return partmatch;
if (!partvendor_from_cbtable) {
- /* Only warn if the mainboard type was not gathered from the
- * coreboot table. If it was, the coreboot implementor is
- * expected to fix flashrom, too.
+ /* Only warn if the mainboard type was not gathered from the coreboot table. If it was, the
+ * coreboot implementor is expected to fix flashrom, too.
*/
- msg_perr("\nUnknown vendor:board from -p internal:mainboard="
- " programmer parameter:\n%s:%s\n\n",
+ msg_perr("\nUnknown vendor:board from -p internal:mainboard= programmer parameter:\n%s:%s\n\n",
vendor, part);
}
return NULL;
--
http://www.hailfinger.org/
More information about the flashrom
mailing list