Drop remainders of the removed Totalimpact board. Fix typos.
[coreboot.git] / src / mainboard / motorola / sandpoint / flash / flash.c
1 /*
2  * This file is part of the coreboot project.
3  *
4  * Copyright (C) 2000 AG Electronics Ltd.
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 version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
18  */
19
20 #include <string.h>
21 #include <console/console.h>
22 #include <stdlib.h>
23 #include "../flash.h"
24
25 static flash_device *first_flash = 0;
26
27 int register_flash_device (const flash_fn * fn, char *tag, void *data)
28 {
29     flash_device *device = malloc (sizeof (flash_device));
30
31     if (device)
32     {
33         const char *result;
34         device->fn = fn;
35         device->tag = tag;
36         device->data = data;
37         if ((result = fn->identify(device)) != 0)
38         {
39             printk_info("Registered flash %s\n", result);
40             device->next = first_flash;
41             first_flash = device;
42         }
43         return result ? 0 : -1;
44     }
45     return -1;
46 }
47
48 flash_device *find_flash_device(const char *name)
49 {
50     int len = strlen(name);
51
52     if (first_flash)
53     {
54         flash_device *flash;
55
56         for (flash = first_flash; flash; flash = flash->next)
57             if (strlen(flash->tag) == len && memcmp(name, flash->tag, len) == 0)
58                 return flash;
59     }
60     printk_info ("No flash %s registered\n", name);
61     return 0;
62 }