xref: /aosp_15_r20/external/flashrom/programmer.c (revision 0d6140be3aa665ecc836e8907834fcd3e3b018fc)
1 /*
2  * This file is part of the flashrom project.
3  *
4  * Copyright (C) 2009,2010,2011 Carl-Daniel Hailfinger
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  */
16 
17 #include "flash.h"
18 #include "programmer.h"
19 
20 /* The limit of 4 is totally arbitrary. */
21 #define MASTERS_MAX 4
22 struct registered_master registered_masters[MASTERS_MAX];
23 int registered_master_count = 0;
24 
25 /* This function copies the struct registered_master parameter. */
register_master(const struct registered_master * mst)26 int register_master(const struct registered_master *mst)
27 {
28 	if (registered_master_count >= MASTERS_MAX) {
29 		msg_perr("Tried to register more than %i master "
30 			 "interfaces.\n", MASTERS_MAX);
31 		return ERROR_FLASHROM_LIMIT;
32 	}
33 	registered_masters[registered_master_count] = *mst;
34 	registered_master_count++;
35 
36 	return 0;
37 }
38 
get_buses_supported(void)39 enum chipbustype get_buses_supported(void)
40 {
41 	int i;
42 	enum chipbustype ret = BUS_NONE;
43 
44 	for (i = 0; i < registered_master_count; i++)
45 		ret |= registered_masters[i].buses_supported;
46 
47 	return ret;
48 }
49