[Skiboot] [PATCH 3/3] libffs: Remove unused function ffs_open_image()

Cyril Bur cyril.bur at au1.ibm.com
Thu Dec 17 13:59:49 AEDT 2015


The utility of this function has been superceeded by blocklevel code and is
no longer called from anywhere, it can be removed.

Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
 libflash/libffs.c | 82 -------------------------------------------------------
 libflash/libffs.h |  6 ----
 2 files changed, 88 deletions(-)

diff --git a/libflash/libffs.c b/libflash/libffs.c
index 631f9b8..f700da2 100644
--- a/libflash/libffs.c
+++ b/libflash/libffs.c
@@ -170,88 +170,6 @@ out:
 	return rc;
 }
 
-/* ffs_open_image is Linux only as it uses lseek, which skiboot does not
- * implement */
-#ifndef __SKIBOOT__
-int ffs_open_image(int fd, uint32_t size, uint32_t toc_offset,
-		   struct ffs_handle **ffsh)
-{
-	struct ffs_hdr hdr;
-	struct ffs_handle *f;
-	int rc;
-
-	if (!ffsh)
-		return FLASH_ERR_PARM_ERROR;
-	*ffsh = NULL;
-
-	if (fd < 0)
-		return FLASH_ERR_PARM_ERROR;
-
-	if ((toc_offset + size) < toc_offset)
-		return FLASH_ERR_PARM_ERROR;
-
-	/* Read flash header */
-	rc = lseek(fd, toc_offset, SEEK_SET);
-	if (rc < 0)
-		return FLASH_ERR_PARM_ERROR;
-
-	rc = read(fd, &hdr, sizeof(hdr));
-	if (rc != sizeof(hdr))
-		return FLASH_ERR_BAD_READ;
-
-	/* Allocate ffs_handle structure and start populating */
-	f = malloc(sizeof(*f));
-	if (!f)
-		return FLASH_ERR_MALLOC_FAILED;
-	memset(f, 0, sizeof(*f));
-	f->type = ffs_type_image;
-	f->toc_offset = toc_offset;
-	f->max_size = size;
-
-	/* Convert and check flash header */
-	rc = ffs_check_convert_header(&f->hdr, &hdr);
-	if (rc) {
-		FL_ERR("FFS: Error %d checking flash header\n", rc);
-		free(f);
-		return rc;
-	}
-
-	/*
-	 * Decide how much of the image to grab to get the whole
-	 * partition map.
-	 */
-	f->cached_size = f->hdr.block_size * f->hdr.size;
-	FL_DBG("FFS: Partition map size: 0x%x\n", f->cached_size);
-
-	/* Allocate cache */
-	f->cache = malloc(f->cached_size);
-	if (!f->cache) {
-		free(f);
-		return FLASH_ERR_MALLOC_FAILED;
-	}
-
-	/* Read the cached map */
-	rc = lseek(fd, toc_offset, SEEK_SET);
-	if (rc < 0) {
-		free(f->cache);
-		free(f);
-		return FLASH_ERR_PARM_ERROR;
-	}
-
-	rc = read(fd, f->cache, f->cached_size);
-	if (rc != f->cached_size) {
-		FL_ERR("FFS: Error %d reading flash partition map\n", rc);
-		free(f->cache);
-		free(f);
-		return FLASH_ERR_BAD_READ;
-	}
-
-	*ffsh = f;
-
-	return 0;
-}
-#endif /*!__SKIBOOT__*/
-
 void ffs_close(struct ffs_handle *ffs)
 {
 	if (ffs->cache)
diff --git a/libflash/libffs.h b/libflash/libffs.h
index ddf3793..ab3f9b1 100644
--- a/libflash/libffs.h
+++ b/libflash/libffs.h
@@ -40,12 +40,6 @@ struct ffs_handle;
 int ffs_init(uint32_t offset, uint32_t max_size,
 		struct blocklevel_device *bl, struct ffs_handle **ffs, int mark_ecc);
 
-/* ffs_open_image is Linux only as it uses lseek, which skiboot does not
- * implement */
-#ifndef __SKIBOOT__
-int ffs_open_image(int fd, uint32_t size, uint32_t toc_offset,
-		   struct ffs_handle **ffs);
-#endif
 
 void ffs_close(struct ffs_handle *ffs);
 
-- 
2.6.3



More information about the Skiboot mailing list