From patchwork Wed Nov 28 01:31:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 202335 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 398E42C0080 for ; Wed, 28 Nov 2012 12:32:07 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DD70F4A0BA; Wed, 28 Nov 2012 02:32:05 +0100 (CET) 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 o72teJAB-kgn; Wed, 28 Nov 2012 02:32:05 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 65B384A053; Wed, 28 Nov 2012 02:31:57 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7A8EC4A0AD for ; Wed, 28 Nov 2012 02:31:55 +0100 (CET) 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 Wt8a11dBL1Ua for ; Wed, 28 Nov 2012 02:31:54 +0100 (CET) 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-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by theia.denx.de (Postfix) with ESMTPS id 238A34A053 for ; Wed, 28 Nov 2012 02:31:53 +0100 (CET) Received: by mail-pb0-f44.google.com with SMTP id uo1so8838970pbc.3 for ; Tue, 27 Nov 2012 17:31:50 -0800 (PST) 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=amomVMyWQ8uWCH+qU2fdaigvw7o4YbwXjuDlOCi18AI=; b=ImjvUvJ7BgvN0+icOwi7Wd3fSsBmeVQuec9JF5MzHnrnzGIUVQIK3Rcz22CMRkl/3S h6cP5t26V8QB/InOfrjbm8K2MVimoQpBZdGf/1aVAdYBh8TiDtlk/eWh2JCFzP6bJpVR OicoMlfLnkAggR2A68whXjWvvdYY1Lyu3Q/OxVOgnfXx9BXjlm6GYPJX2GsQhDpNNAFz Qv05Iqp/BbXFZjbPptQ7FsKFQ4K28gHslOe/iMpgOe7h++Y5WQC3Se7J1whvDzwtCCTf 0CMcMUW4ivp13rUr5bVWP1EL6oF7MtLqMy7tPO6fdZ+uf6goKM9ktkxhQbSBQ3j9367+ GovQ== Received: by 10.68.238.8 with SMTP id vg8mr53855304pbc.26.1354066310862; Tue, 27 Nov 2012 17:31:50 -0800 (PST) Received: from officeserver-2 ([70.96.116.236]) by mx.google.com with ESMTPS id tm5sm11493965pbc.64.2012.11.27.17.31.47 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 27 Nov 2012 17:31:48 -0800 (PST) Received: from tkisky by officeserver-2 with local (Exim 4.76) (envelope-from ) id 1TdWVB-0007ku-Ro; Tue, 27 Nov 2012 18:31:49 -0700 From: Troy Kisky To: sbabic@denx.de Date: Tue, 27 Nov 2012 18:31:36 -0700 Message-Id: <1354066303-29762-5-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1354066303-29762-1-git-send-email-troy.kisky@boundarydevices.com> References: <1349315254-21151-9-git-send-email-troy.kisky@boundarydevices.com> <1354066303-29762-1-git-send-email-troy.kisky@boundarydevices.com> X-Gm-Message-State: ALoCoQkeVZAT1sClYLQzG4po2O291oTuDy0IhNlPqXTk2OtyPBhbb87U5Gx9YFDmpavMXM7YwzYe Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH V4 04/11] 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 97e5c4b..3a010a6 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_ */