Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3323027imm; Sun, 14 Oct 2018 17:29:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV63gjOsBbdhn2NWKMFq/TcvFz/u4VtFfHMkpd3kouOQ+/to7IX59iefw8BLdHRg2v0xBoXLc X-Received: by 2002:a62:6c48:: with SMTP id h69-v6mr15236545pfc.61.1539563349449; Sun, 14 Oct 2018 17:29:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539563349; cv=none; d=google.com; s=arc-20160816; b=w1+Bq9reJxaSjrYNR36zJCNNok5BMR1WgFaOsCon8OyLIdNMnTG/isHyQEi/mP7yZD 6zHasfguNFsFfono01IUdXL/rRAwQo92jA5sJhjIZTQo3iATJwX1cI+CpN44h+e0SXhf qy3Ni0C6YbhgOrGcnUMblARDAMUi9kfnx5DLPWPAAGBf3enNo1/I74nshl+Cna0uZVrW /MMsQGuqvBHfRZzTKlmuIMXlOAp5EZxy2eJOXB1MIb37Z645BUJrd6oB6iuhD/K/sRSm H8ENhAEgJpWcClLtGwQXEfHLVyB9KwOgALigDcsv/UTWJw1KYOLBRWnfMJJK8xM22tP0 KMCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=VS64Bboo/cHvVCqyzYbNqD36WUkYJGIhe/8UN1uSi10=; b=zql5gadLXZbeLeGqcBMSXkUwbmWfVo2H8tmg017KW1E6pC6wkzTDj4Un+S1Z6Q4GKe cK7QD2nM0nilV8LPmrqbIxGrIhkxas1l3ZTWIxLeZvip9DeuBi/mbx8UdhwLfTeUAk3o ja3OpCwmtRRjM1fgMYN/eMCK9DrKkMqfBGrVos86TkfnGZyN3trF15E6kMYHKJe8Y8CE wQ/IpmXYAaeobsFXdF/jP6atAb7P8aMZZZjKWO60GsmIjohPoQdEXk/4pSAgku9siC0E W83z0/yFAFfOxZYhsg1VxHOcamnwnInDrBtJcRrIVTVNMH0WPge+br19J46zsZoxAYAx +rmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aTlxhko5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o67-v6si7793384pga.597.2018.10.14.17.28.55; Sun, 14 Oct 2018 17:29:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aTlxhko5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727000AbeJOIJK (ORCPT + 99 others); Mon, 15 Oct 2018 04:09:10 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43232 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726968AbeJOIJJ (ORCPT ); Mon, 15 Oct 2018 04:09:09 -0400 Received: by mail-pg1-f196.google.com with SMTP id 80-v6so8286438pgh.10; Sun, 14 Oct 2018 17:26:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VS64Bboo/cHvVCqyzYbNqD36WUkYJGIhe/8UN1uSi10=; b=aTlxhko51/9f7aed6ItraXbkxoe6kGvYd83E/fHXVWgFecy1Olmna2VISAbwpqOokE LuaNWMwGnLMWgIg948vD01hZG/GNZblxL922C/9Fc/e7xHjtbXS7Kjg7HxCS4XbcRoRu CVLARIIFO8rqZ45rvZHsjHlNGNb87L3/itRq+5izC/wpR0DUY/Ac/7HOzkaqAykeHXOj n07owHvlwnmicy5P+Dp07Rbk/KEchuh64vcsLT+kneWaEdLfG94ayH+CWdL7RhPaSig7 dCLqzIvxrb+5QwrZJNJeqBP2sjhtHT33Wb4eEc3wM/WYRm4vaos6Hy8CX9MV5gVOSihH Koaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VS64Bboo/cHvVCqyzYbNqD36WUkYJGIhe/8UN1uSi10=; b=mm3hbmR3pUsHnqtwmnyRRQcggw9QbmY/+zLfndGLLSUICieCB+Wi1uZ00RldIIoAkn hvaherh2bz8nhhs9ou+U7iMzL9z7zqsx9CpsXQcOqP9DO0tCamcIPQaX6z7sSqt7rBql FGsDiE8ZCiaNcDTovQn8HLvD+37sQY2l6T5OtgQy5EU5fzBE7Ddo+7JAcNOjrbV/H5YA M8uXYiU8x+6dN/pVkm0kR2O51vNZwRoeS5jIWWEygIi1mzHAJ7xSXZ86pDyNIGoGYm28 qTzWxhDaMeKujO4tDF7YRpgrzyzn45aKmP/mCKeiOtmMvQP3i3G+xmGjksdpB4lo9EJB IzQg== X-Gm-Message-State: ABuFfog2jkw3sKiOW93D4FW8MJvANbNKB0WWDz94csMmRO80E/vwfxz3 +ptYBFAmmC0+KhRH0oQHhCo= X-Received: by 2002:a63:9742:: with SMTP id d2-v6mr14079573pgo.278.1539563181169; Sun, 14 Oct 2018 17:26:21 -0700 (PDT) Received: from localhost.localdomain (c-24-6-192-50.hsd1.ca.comcast.net. [24.6.192.50]) by smtp.gmail.com with ESMTPSA id j14-v6sm11387110pgh.52.2018.10.14.17.26.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Oct 2018 17:26:20 -0700 (PDT) From: frowand.list@gmail.com To: Rob Herring , Pantelis Antoniou , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Alan Tull , Moritz Fischer Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, devicetree@vger.kernel.org, linux-fpga@vger.kernel.org Subject: [PATCH v3 17/18] of: unittest: find overlays[] entry by name instead of index Date: Sun, 14 Oct 2018 17:24:29 -0700 Message-Id: <1539563070-12969-18-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> References: <1539563070-12969-1-git-send-email-frowand.list@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Frank Rowand One accessor of overlays[] was using a hard coded index value to find the correct array entry instead of searching for the entry containing the correct name. Signed-off-by: Frank Rowand --- drivers/of/unittest.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 1c2bd8503095..785985bdbfa6 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -2178,7 +2178,7 @@ struct overlay_info { OVERLAY_INFO_EXTERN(overlay_bad_phandle); OVERLAY_INFO_EXTERN(overlay_bad_symbol); -/* order of entries is hard-coded into users of overlays[] */ +/* entries found by name */ static struct overlay_info overlays[] = { OVERLAY_INFO(overlay_base, -9999), OVERLAY_INFO(overlay, 0), @@ -2201,7 +2201,8 @@ struct overlay_info { OVERLAY_INFO(overlay_bad_add_dup_prop, -EINVAL), OVERLAY_INFO(overlay_bad_phandle, -EINVAL), OVERLAY_INFO(overlay_bad_symbol, -EINVAL), - {} + /* end marker */ + {.dtb_begin = NULL, .dtb_end = NULL, .expected_result = 0, .name = NULL} }; static struct device_node *overlay_base_root; @@ -2231,6 +2232,19 @@ void __init unittest_unflatten_overlay_base(void) u32 data_size; void *new_fdt; u32 size; + int found = 0; + const char *overlay_name = "overlay_base"; + + for (info = overlays; info && info->name; info++) { + if (!strcmp(overlay_name, info->name)) { + found = 1; + break; + } + } + if (!found) { + pr_err("no overlay data for %s\n", overlay_name); + return; + } info = &overlays[0]; @@ -2278,11 +2292,10 @@ static int __init overlay_data_apply(const char *overlay_name, int *overlay_id) { struct overlay_info *info; int found = 0; - int k; int ret; u32 size; - for (k = 0, info = overlays; info && info->name; info++, k++) { + for (info = overlays; info && info->name; info++) { if (!strcmp(overlay_name, info->name)) { found = 1; break; -- Frank Rowand