diff options
author | Greg Watson <jarrah@users.sourceforge.net> | 2003-06-09 22:08:08 +0000 |
---|---|---|
committer | Greg Watson <jarrah@users.sourceforge.net> | 2003-06-09 22:08:08 +0000 |
commit | dc18ef018d080f050de9e28be913f544d3009cb2 (patch) | |
tree | 6226cd038abe4437211be6bec4c22447d71857c9 /src/mainboard/motorola/sandpoint/flash/flash.c | |
parent | f655bf7f3e0c608f4b9cae1ee76e2be5477f4df6 (diff) | |
download | coreboot-dc18ef018d080f050de9e28be913f544d3009cb2.tar.xz |
Moved from freebios
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@864 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/mainboard/motorola/sandpoint/flash/flash.c')
-rw-r--r-- | src/mainboard/motorola/sandpoint/flash/flash.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/mainboard/motorola/sandpoint/flash/flash.c b/src/mainboard/motorola/sandpoint/flash/flash.c new file mode 100644 index 0000000000..b9401ec9e6 --- /dev/null +++ b/src/mainboard/motorola/sandpoint/flash/flash.c @@ -0,0 +1,48 @@ +/* $Id$ */ +/* Copyright 2000 AG Electronics Ltd. */ +/* This code is distributed without warranty under the GPL v2 (see COPYING) */ + +#include <types.h> +#include <string.h> +#include <printk.h> +#include <stdlib.h> +#include "../flash.h" + +static flash_device *first_flash = 0; + +int register_flash_device (const flash_fn * fn, char *tag, void *data) +{ + flash_device *device = malloc (sizeof (flash_device)); + + if (device) + { + const char *result; + device->fn = fn; + device->tag = tag; + device->data = data; + if ((result = fn->identify(device)) != 0) + { + printk_info("Registered flash %s\n", result); + device->next = first_flash; + first_flash = device; + } + return result ? 0 : -1; + } + return -1; +} + +flash_device *find_flash_device(const char *name) +{ + int len = strlen(name); + + if (first_flash) + { + flash_device *flash; + + for (flash = first_flash; flash; flash = flash->next) + if (strlen(flash->tag) == len && memcmp(name, flash->tag, len) == 0) + return flash; + } + printk_info ("No flash %s registered\n", name); + return 0; +} |