From patchwork Thu Jul 19 07:28:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 142329 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1422890ljj; Thu, 19 Jul 2018 00:32:03 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdXEk2jkXLX49g/PLYOi9RB0P7n7VcRoj2mfPMyxsPKl3GCK2dk5NtYrjhFOh6aClK40BJ3 X-Received: by 2002:a50:a0c5:: with SMTP id 63-v6mr9698655edo.47.1531985523221; Thu, 19 Jul 2018 00:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531985523; cv=none; d=google.com; s=arc-20160816; b=CR7FtEyHMTBebocQECHR5TyQs9uV1NzrQ84Jv0dOfvcGRC1QpxPKAIaAqBYxZBEpgS l4BCfY/Y1lUTKiT3JOXt2UN1xRAZi1eWcqoYkJdkMFqtYm465v6fo9oBj4kgJ1iPWnEz n3CiK5n3yHqrH34PvyT6/73SyFUuUEKQm+ZUbKIBt7zlynL3DB74twcswOxj8AIAXnnS VuFEnt7hDsKJrVqcfab1sVRP6B5qEilTmbBoGwy9Pi3sW3Z77jxzr1k97tYbQ567D5EW XRspm/58F8M2rop1IbMoEfck7DCxgIPkRQwCaRcuKua1G0ug8hCl/YOrLItQTHEIIrh7 JLow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:dkim-signature :dkim-filter:arc-authentication-results; bh=LDZ6lRagXoRY/MoEYgKgO958rAWdhbESzI9xwz/yT1E=; b=Q6Z/TVViwfD1/eROHuN3uFP8s8QDHPZkZXVrkmqvGhXQ7mIcTbjOrIrNCYntiCBgZY 1QctY1SfmWVqm+mJZko9UzVt4i4wkxTY/f1twquztAWGTrkjKX1cHhaooFPBnmN8fRfW nBiBuVAZtpIXNCBgXAhmOUMxLvYCPW8R35BI5A72gjunFv5vLLg6w5/1boBn9IqMlwzA k028DeNNmB09UA9oaO2w7bpz7wTRPPARLLaMOitQh1KDEWzEdO78KFEUuf5yC8Z++dNG sPFirutLb+9gxs6EgA+XaFvAACji5IYHtpA0Y7iOowv1Ncm7CmTpNqh6znRDrRWmFfIx jTFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=QsKmU90Z; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id u42-v6si3294127edm.404.2018.07.19.00.32.02; Thu, 19 Jul 2018 00:32:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=QsKmU90Z; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id CB897C21F8A; Thu, 19 Jul 2018 07:29:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 302A4C21F8A; Thu, 19 Jul 2018 07:29:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 26EA2C21F90; Thu, 19 Jul 2018 07:28:54 +0000 (UTC) Received: from conuserg-11.nifty.com (conuserg-11.nifty.com [210.131.2.78]) by lists.denx.de (Postfix) with ESMTPS id A17CFC21FBC for ; Thu, 19 Jul 2018 07:28:50 +0000 (UTC) Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id w6J7STUA021119; Thu, 19 Jul 2018 16:28:30 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com w6J7STUA021119 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1531985310; bh=Ad+htyda3ZHwE8Td1syrn18so8MN2HoRWj2taPJzkdw=; h=From:To:Cc:Subject:Date:From; b=QsKmU90ZaywgAgMAVB8u/FAbq1Bzok40uE5gBzqcHkAWTL4SO0k2Oo5f17PhfPmcs Yg5+Ryird8cOvO9qsFB5AGBvZpMXAGK1l4KT27W+atL71cP6mixkgiXHMj5zac6mZQ yVCnTu/Zt+1g8c/Thj7KG06G0Nf2oerh2rFeT40I9Ke+hvbrlDwFEwLHZxtDzBmJKb UAATW4cAqOe0n+RNR8hTcTbdiXWXctZ43/uQdoFbT0xWF+TzA1ws4aI3YcTuT55qEB tP21CDr5nxtRVQh8g4mYRY8pR4z3Gtzl/uL5idMfw+GF7jaHOAyoSFD2VUKw7UvbuH zS+hcuAqQmJLw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Thu, 19 Jul 2018 16:28:22 +0900 Message-Id: <1531985307-4208-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 Subject: [U-Boot] [PATCH 1/6] fdt_support: make fdt_fixup_mtdparts() prototype more specific X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The second argument of fdt_fixup_mtdparts() is an opaque pointer, 'void *node_info', hence callers can pass any pointer. Obviously, fdt_fixup_mtdparts() expects 'struct node_info *' otherwise, it crashes run-time. Change the prototype so that it is compile-time checked. Also, add 'const' qualifier to it so that callers can constify the struct node_info arrays. Signed-off-by: Masahiro Yamada Reviewed-by: Simon Glass --- common/fdt_support.c | 13 +++++++------ include/fdt_support.h | 11 ++++++++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/common/fdt_support.c b/common/fdt_support.c index 812eca8..3b31f3d 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -893,9 +893,9 @@ err_prop: * * fdt_fixup_mtdparts(blob, nodes, ARRAY_SIZE(nodes)); */ -void fdt_fixup_mtdparts(void *blob, void *node_info, int node_info_size) +void fdt_fixup_mtdparts(void *blob, const struct node_info *node_info, + int node_info_size) { - struct node_info *ni = node_info; struct mtd_device *dev; int i, idx; int noff; @@ -905,12 +905,13 @@ void fdt_fixup_mtdparts(void *blob, void *node_info, int node_info_size) for (i = 0; i < node_info_size; i++) { idx = 0; - noff = fdt_node_offset_by_compatible(blob, -1, ni[i].compat); + noff = fdt_node_offset_by_compatible(blob, -1, + node_info[i].compat); while (noff != -FDT_ERR_NOTFOUND) { debug("%s: %s, mtd dev type %d\n", fdt_get_name(blob, noff, 0), - ni[i].compat, ni[i].type); - dev = device_find(ni[i].type, idx++); + node_info[i].compat, node_info[i].type); + dev = device_find(node_info[i].type, idx++); if (dev) { if (fdt_node_set_part_info(blob, noff, dev)) return; /* return on error */ @@ -918,7 +919,7 @@ void fdt_fixup_mtdparts(void *blob, void *node_info, int node_info_size) /* Jump to next flash node */ noff = fdt_node_offset_by_compatible(blob, noff, - ni[i].compat); + node_info[i].compat); } } } diff --git a/include/fdt_support.h b/include/fdt_support.h index a9a0078..27fe564 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -205,11 +205,16 @@ int fdt_increase_size(void *fdt, int add_len); int fdt_fixup_nor_flash_size(void *blob); +struct node_info; #if defined(CONFIG_FDT_FIXUP_PARTITIONS) -void fdt_fixup_mtdparts(void *fdt, void *node_info, int node_info_size); +void fdt_fixup_mtdparts(void *fdt, const struct node_info *node_info, + int node_info_size); #else -static inline void fdt_fixup_mtdparts(void *fdt, void *node_info, - int node_info_size) {} +static inline void fdt_fixup_mtdparts(void *fdt, + const struct node_info *node_info, + int node_info_size) +{ +} #endif void fdt_del_node_and_alias(void *blob, const char *alias);