From patchwork Tue Aug 29 06:25:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 806975 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xhJxb5rjjz9ryr for ; Tue, 29 Aug 2017 16:43:31 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3xhJxb4q3hzDrWK for ; Tue, 29 Aug 2017 16:43:31 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xhJY83cXlzDqTm for ; Tue, 29 Aug 2017 16:25:48 +1000 (AEST) Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T6OCRo076863 for ; Tue, 29 Aug 2017 02:25:42 -0400 Received: from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cn1hye6p1-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 29 Aug 2017 02:25:42 -0400 Received: from localhost by e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 29 Aug 2017 16:25:39 +1000 Received: from d23relay10.au.ibm.com (202.81.31.229) by e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 29 Aug 2017 16:25:37 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T6PaL73145832 for ; Tue, 29 Aug 2017 16:25:36 +1000 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v7T6PbO6017786 for ; Tue, 29 Aug 2017 16:25:37 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v7T6Pas1017774; Tue, 29 Aug 2017 16:25:36 +1000 Received: from camb691.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 7B8B5A010B; Tue, 29 Aug 2017 16:25:35 +1000 (AEST) From: Cyril Bur To: skiboot@lists.ozlabs.org, stewart@linux.vnet.ibm.com Date: Tue, 29 Aug 2017 16:25:02 +1000 X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170829062506.8317-1-cyril.bur@au1.ibm.com> References: <20170829062506.8317-1-cyril.bur@au1.ibm.com> X-TM-AS-MML: disable x-cbid: 17082906-0040-0000-0000-00000351E322 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082906-0041-0000-0000-00000CCFDD93 Message-Id: <20170829062506.8317-10-cyril.bur@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-29_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290096 Subject: [Skiboot] [RFC PATCH 09/13] libflash/libffs: Remove backup partition from TOC generation code X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" It turns out this code was messy and not all that reliable. Doing it at the library level adds complexity to the library and restrictions to the caller. A simpler approach can be achived with the just instantiating multiple ffs_header structures pointing to different parts of the same file. Signed-off-by: Cyril Bur --- libflash/ffs.h | 2 -- libflash/libffs.c | 52 +--------------------------------------------------- libflash/libffs.h | 2 -- 3 files changed, 1 insertion(+), 55 deletions(-) diff --git a/libflash/ffs.h b/libflash/ffs.h index cc2460c8..957155b9 100644 --- a/libflash/ffs.h +++ b/libflash/ffs.h @@ -204,7 +204,6 @@ struct __ffs_hdr { * @size: Size of partition table (in bytes) * @block_size: Size of block on device (in bytes) * @block_count: Number of blocks on device. - * @backup The backup partition * @entries: List of partition entries */ struct ffs_hdr { @@ -214,7 +213,6 @@ struct ffs_hdr { uint32_t block_size; uint32_t block_count; struct ffs_entry *part; - struct ffs_entry *backup; struct list_head entries; }; diff --git a/libflash/libffs.c b/libflash/libffs.c index e741121d..5888c73f 100644 --- a/libflash/libffs.c +++ b/libflash/libffs.c @@ -546,7 +546,7 @@ int ffs_next_side(struct ffs_handle *ffs, struct ffs_handle **new_ffs, return ffs_init(offset, max_size, ffs->bl, new_ffs, mark_ecc); } -static int __ffs_entry_add(struct ffs_hdr *hdr, struct ffs_entry *entry) +int ffs_entry_add(struct ffs_hdr *hdr, struct ffs_entry *entry) { struct ffs_entry *ent; uint32_t smallest_base; @@ -599,50 +599,6 @@ static int __ffs_entry_add(struct ffs_hdr *hdr, struct ffs_entry *entry) return 0; } -int ffs_entry_add(struct ffs_hdr *hdr, struct ffs_entry *entry) -{ - /* - * Refuse to add anything after BACKUP_PART has been added, not - * sure why this is needed anymore - */ - if (hdr->backup) - return FLASH_ERR_PARM_ERROR; - - return __ffs_entry_add(hdr, entry); -} - -/* This should be done last! */ -int ffs_hdr_create_backup(struct ffs_hdr *hdr) -{ - struct ffs_entry *ent; - struct ffs_entry *backup; - uint32_t hdr_size, flash_end; - int rc = 0; - - ent = list_tail(&hdr->entries, struct ffs_entry, list); - if (!ent) { - return FLASH_ERR_PARM_ERROR; - } - - hdr_size = ffs_hdr_raw_size(ffs_num_entries(hdr) + 1); - /* Whole number of blocks BACKUP_PART needs to be */ - hdr_size = ((hdr_size + hdr->block_size) / hdr->block_size) * hdr->block_size; - flash_end = hdr->base + (hdr->block_size * hdr->block_count); - rc = ffs_entry_new("BACKUP_PART", flash_end - hdr_size, hdr_size, &backup); - if (rc) - return rc; - - rc = __ffs_entry_add(hdr, backup); - if (rc) { - free(backup); - return rc; - } - - hdr->backup = backup; - - return rc; -} - int ffs_hdr_finalise(struct blocklevel_device *bl, struct ffs_hdr *hdr) { int num_entries, i, rc = 0; @@ -699,12 +655,6 @@ int ffs_hdr_finalise(struct blocklevel_device *bl, struct ffs_hdr *hdr) if (rc) goto out; - if (hdr->backup) { - fprintf(stderr, "Actually writing backup part @ 0x%08x\n", hdr->backup->base); - blocklevel_erase(bl, hdr->backup->base, hdr->size); - rc = blocklevel_write(bl, hdr->backup->base, real_hdr, - ffs_hdr_raw_size(num_entries)); - } out: free(real_hdr); return rc; diff --git a/libflash/libffs.h b/libflash/libffs.h index d81b9dfe..56428a2c 100644 --- a/libflash/libffs.h +++ b/libflash/libffs.h @@ -154,8 +154,6 @@ struct ffs_entry_user ffs_entry_user_get(struct ffs_entry *ent); int ffs_entry_add(struct ffs_hdr *hdr, struct ffs_entry *entry); -int ffs_hdr_create_backup(struct ffs_hdr *hdr); - int ffs_hdr_finalise(struct blocklevel_device *bl, struct ffs_hdr *hdr); int ffs_hdr_free(struct ffs_hdr *hdr);