Patchwork Clean up board enable matching

login
register
about
Submitter Carl-Daniel Hailfinger
Date 2012-08-09 23:59:37
Message ID <50244EE9.1070804@gmx.net>
Download mbox | patch
Permalink /patch/3703/
State Superseded
Headers show

Comments

Carl-Daniel Hailfinger - 2012-08-09 23:59:37
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@gmx.net>
Stefan Tauner - 2012-08-13 16:51:46
On Fri, 10 Aug 2012 01:59:37 +0200
Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> wrote:

> 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.

Superseded by Refactor the -p internal:mainboard handling, see:
1344819105-11920-1-git-send-email-stefan.tauner@student.tuwien.ac.at

Patch

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@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;