David Hendricks has uploaded this change for review. ( https://review.coreboot.org/22502
Change subject: linux_mtd: Fix compilation errors ......................................................................
linux_mtd: Fix compilation errors
This fixes compilation errors from the initial import patch.
Change-Id: I216fab281f7a20a5819de3adf610b770a0b3d37c Signed-off-by: David Hendricks dhendricks@fb.com --- M linux_mtd.c 1 file changed, 26 insertions(+), 37 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/02/22502/1
diff --git a/linux_mtd.c b/linux_mtd.c index e1b11cd..07db2e9 100644 --- a/linux_mtd.c +++ b/linux_mtd.c @@ -22,6 +22,7 @@ #include <fcntl.h> #include <inttypes.h> #include <libgen.h> +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <mtd/mtd-user.h> @@ -42,32 +43,12 @@
static int dev_fd = -1;
-static char *mtd_device_name; static int mtd_device_is_writeable;
/* Size info is presented in bytes in sysfs. */ static unsigned long int mtd_total_size; static unsigned long int mtd_numeraseregions; static unsigned long int mtd_erasesize; /* only valid if numeraseregions is 0 */ - -static int stat_mtd_files(char *dev_path, char *sysfs_path) -{ - struct stat s; - - errno = 0; - if (stat(dev_path, &s) < 0) { - msg_pdbg("Cannot stat "%s": %s\n", dev_path, strerror(errno)); - return 1; - } - - if (lstat(sysfs_path, &s) < 0) { - msg_pdbg("Cannot stat "%s" : %s\n", - sysfs_path, strerror(errno)); - return 1; - } - - return 0; -}
/* read a string from a sysfs file and sanitize it */ static int read_sysfs_string(const char *filename, char *buf, int len) @@ -109,7 +90,6 @@
static int read_sysfs_int(const char *filename, unsigned long int *val) { - uint32_t tmp; char buf[32]; char *endptr;
@@ -181,17 +161,20 @@ return 0; }
-static int linux_mtd_probe(struct flashchip *flash) +static int linux_mtd_probe(struct flashctx *flash) { - flash->tested = TEST_OK_PREW; - flash->total_size = mtd_total_size / 1024; /* bytes -> kB */ - flash->block_erasers[0].eraseblocks[0].size = mtd_erasesize; - flash->block_erasers[0].eraseblocks[0].count = + flash->chip->tested.probe = OK; + flash->chip->tested.read = OK; + flash->chip->tested.erase = OK; + flash->chip->tested.write = OK; + flash->chip->total_size = mtd_total_size / 1024; /* bytes -> kB */ + flash->chip->block_erasers[0].eraseblocks[0].size = mtd_erasesize; + flash->chip->block_erasers[0].eraseblocks[0].count = mtd_total_size / mtd_erasesize; return 1; }
-static int linux_mtd_read(struct flashchip *flash, uint8_t *buf, +static int linux_mtd_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len) { if (lseek(dev_fd, start, SEEK_SET) != start) { @@ -209,13 +192,13 @@ }
/* this version assumes we must divide the write request into pages ourselves */ -static int linux_mtd_write(struct flashchip *flash, uint8_t *buf, +static int linux_mtd_write(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) { unsigned int page; unsigned int chunksize, page_size;
- chunksize = page_size = flash->page_size; + chunksize = page_size = flash->chip->page_size;
if (!mtd_device_is_writeable) return 1; @@ -246,10 +229,9 @@ return 0; }
-static int linux_mtd_erase(struct flashchip *flash, +static int linux_mtd_erase(struct flashctx *flash, unsigned int start, unsigned int len) { - struct region_info_user region_info; uint32_t u;
if (mtd_numeraseregions != 0) { @@ -272,7 +254,7 @@ return 0; }
-static struct opaque_programmer programmer_linux_mtd = { +static struct opaque_master opaque_master_linux_mtd = { /* FIXME: Do we need to change these (especially write) as per * page size requirements? */ .max_data_read = MAX_DATA_UNSPECIFIED, @@ -318,8 +300,18 @@ msg_pdbg("%s: sysfs_path: "%s", dev_path: "%s"\n", __func__, sysfs_path, dev_path);
- if (stat_mtd_files(dev_path, sysfs_path)) + struct stat s; + errno = 0; + if (stat(dev_path, &s) < 0) { + msg_pdbg("Cannot stat "%s": %s\n", dev_path, strerror(errno)); goto linux_mtd_setup_exit; + } + + if (lstat(sysfs_path, &s) < 0) { + msg_pdbg("Cannot stat "%s" : %s\n", + sysfs_path, strerror(errno)); + goto linux_mtd_setup_exit; + }
if (get_mtd_info()) goto linux_mtd_setup_exit; @@ -351,9 +343,6 @@ int dev_num = -1; /* linux_mtd_setup will search if dev_num < 0 */ int ret = 1;
- if (alias && alias->type != ALIAS_HOST) - return 1; - param = extract_programmer_param("dev"); if (param) { char *endptr; @@ -373,7 +362,7 @@ if (register_shutdown(linux_mtd_shutdown, NULL)) goto linux_mtd_init_exit;
- register_opaque_programmer(&programmer_linux_mtd); + register_opaque_master(&opaque_master_linux_mtd);
ret = 0; linux_mtd_init_exit: