From patchwork Thu Oct 4 01:47:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 189011 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 88D832C0338 for ; Thu, 4 Oct 2012 11:58:33 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BD577283FE; Thu, 4 Oct 2012 03:58:24 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tM6-dECT6paH; Thu, 4 Oct 2012 03:58:24 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7B467283DE; Thu, 4 Oct 2012 03:58:06 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 97307283B8 for ; Thu, 4 Oct 2012 03:57:58 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tcoEwkMMrOBl for ; Thu, 4 Oct 2012 03:57:58 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by theia.denx.de (Postfix) with ESMTPS id 63DFB28315 for ; Thu, 4 Oct 2012 03:57:29 +0200 (CEST) Received: by mail-pa0-f44.google.com with SMTP id fb11so7093781pad.3 for ; Wed, 03 Oct 2012 18:57:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=oOoOUTO500XoVW0dv4AsvSxqmGbwzKz4yTtijqQlJHY=; b=SBX4BQVkSZsHe1c17lSX+pTsVG3msvL1nLhxXC5so04lUZGXghikk1otsqCzaJEKaI 1JyGStC0Skv9N4ElgPKBTjxgB8Lbh973BM3crNepfmP8k/jTiJAhytjaodJpEBaqRHwc XHVrh5Fxm9jx4062FA6nwNsx7ON9GXHyHB15Y8Fkru6LhDbd2ZySIfDlmujSCXafsSxG H412XzTO3IwncLm61Evs5zdo//7BAsdu9AHZb7U8++0OsqpszMyb12TnmZ4y/09aeASc 6+mzL3RLXbDFyhnIzX7JME90PVdqQpsq1W211KS8Ryji53DCGWIzRx4v/bkC8ddHe779 HFmQ== Received: by 10.66.79.65 with SMTP id h1mr9229143pax.84.1349315848969; Wed, 03 Oct 2012 18:57:28 -0700 (PDT) Received: from officeserver-2 ([70.96.116.236]) by mx.google.com with ESMTPS id pj8sm3473126pbb.60.2012.10.03.18.57.27 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 03 Oct 2012 18:57:28 -0700 (PDT) Received: from tkisky by officeserver-2 with local (Exim 4.76) (envelope-from ) id 1TJaXc-0005WZ-NW; Wed, 03 Oct 2012 18:47:56 -0700 From: Troy Kisky To: sbabic@denx.de Date: Wed, 3 Oct 2012 18:47:12 -0700 Message-Id: <1349315254-21151-11-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349315254-21151-1-git-send-email-troy.kisky@boundarydevices.com> References: <1348281558-19520-1-git-send-email-troy.kisky@boundarydevices.com> <1349315254-21151-1-git-send-email-troy.kisky@boundarydevices.com> X-Gm-Message-State: ALoCoQn74m78x4BmRxqZPieKRotz4QET4Yh8gKlpmfhznVAY/QL+m2WZ/8qit1XG3+XyBO5jyRX/ Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH V3 10/32] imximage: prepare to move static variables to struct data_src X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Need to move accesses to the static variables to a function where struct data_src is used. Signed-off-by: Troy Kisky --- v3: new patch --- tools/imximage.c | 24 +++++++++++++----------- tools/imximage.h | 3 +++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/tools/imximage.c b/tools/imximage.c index 10ccfa9..a2460d6 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -407,8 +407,11 @@ static void parse_cfg_fld(struct imx_header *imxhdr, int32_t *cmd, break; } } -static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name) + +static int parse_cfg_file(struct imx_header *imxhdr, char *name, + uint32_t entry_point) { + struct data_src ds; FILE *fd = NULL; char *line = NULL; char *token, *saveptr1, *saveptr2; @@ -418,6 +421,10 @@ static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name) int dcd_len = 0; int32_t cmd; + /* Be able to detect if the cfg file has no BOOT_FROM tag */ + g_flash_offset = FLASH_OFFSET_UNDEFINED; + memset(&ds, 0, sizeof(struct data_src)); + ds.imxhdr = imxhdr; /* * In order to not change the old imx cfg file * by adding VERSION command into it, here need @@ -465,10 +472,10 @@ static uint32_t parse_cfg_file(struct imx_header *imxhdr, char *name) fprintf(stderr, "Error: No BOOT_FROM tag in %s\n", name); exit(EXIT_FAILURE); } - return dcd_len; + /* Set the imx header */ + return (*set_imx_hdr)(imxhdr, dcd_len, entry_point, g_flash_offset); } - static int imximage_check_image_types(uint8_t type) { if (type == IH_TYPE_IMXIMAGE) @@ -510,21 +517,16 @@ int imximage_vrec_header(struct mkimage_params *params, struct image_type_params *tparams) { struct imx_header *imxhdr; - uint32_t dcd_len; imxhdr = calloc(1, MAX_HEADER_SIZE); if (!imxhdr) { fprintf(stderr, "Error: out of memory\n"); exit(EXIT_FAILURE); } - /* Be able to detect if the cfg file has no BOOT_FROM tag */ - g_flash_offset = FLASH_OFFSET_UNDEFINED; - /* Parse dcd configuration file */ - dcd_len = parse_cfg_file(imxhdr, params->imagename); - /* Set the imx header */ - imximage_params.header_size = (*set_imx_hdr)(imxhdr, dcd_len, - params->ep, g_flash_offset); + /* Parse dcd configuration file */ + imximage_params.header_size = parse_cfg_file(imxhdr, params->imagename, + params->ep); imximage_params.hdr = imxhdr; return 0; } diff --git a/tools/imximage.h b/tools/imximage.h index 0f39447..2895378 100644 --- a/tools/imximage.h +++ b/tools/imximage.h @@ -171,4 +171,7 @@ typedef void (*set_dcd_rst_t)(struct imx_header *imxhdr, typedef int (*set_imx_hdr_t)(struct imx_header *imxhdr, uint32_t dcd_len, uint32_t entry_point, uint32_t flash_offset); +struct data_src { + struct imx_header *imxhdr; +}; #endif /* _IMXIMAGE_H_ */