mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-26 14:42:36 +02:00

A NULL func pointer is necessary and sufficient for the condition `NULL func pointer => fallback_chip_X' as to not need this explicit specification. Therefore drop the explicit need to specify these fallback callback function pointer in the par_master struct. This is a reasonable default for every driver in the tree. Furthermore, move the 'fallback_chip_X()' func from the generic programmer.c register logic into its relevant home of parallel.c and make static local to clean up link-time symbol space. This simplifies the code and driver development. Change-Id: If25c0048a07057aa72be6ffa8d8ad7f0a568dcf7 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/71745 Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
49 lines
1.4 KiB
C
49 lines
1.4 KiB
C
/*
|
|
* This file is part of the flashrom project.
|
|
*
|
|
* Copyright (C) 2009,2010,2011 Carl-Daniel Hailfinger
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include "flash.h"
|
|
#include "programmer.h"
|
|
|
|
/* The limit of 4 is totally arbitrary. */
|
|
#define MASTERS_MAX 4
|
|
struct registered_master registered_masters[MASTERS_MAX];
|
|
int registered_master_count = 0;
|
|
|
|
/* This function copies the struct registered_master parameter. */
|
|
int register_master(const struct registered_master *mst)
|
|
{
|
|
if (registered_master_count >= MASTERS_MAX) {
|
|
msg_perr("Tried to register more than %i master "
|
|
"interfaces.\n", MASTERS_MAX);
|
|
return ERROR_FLASHROM_LIMIT;
|
|
}
|
|
registered_masters[registered_master_count] = *mst;
|
|
registered_master_count++;
|
|
|
|
return 0;
|
|
}
|
|
|
|
enum chipbustype get_buses_supported(void)
|
|
{
|
|
int i;
|
|
enum chipbustype ret = BUS_NONE;
|
|
|
|
for (i = 0; i < registered_master_count; i++)
|
|
ret |= registered_masters[i].buses_supported;
|
|
|
|
return ret;
|
|
}
|