Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4640191imm; Mon, 15 Oct 2018 19:40:31 -0700 (PDT) X-Google-Smtp-Source: ACcGV60fpuaDkdudR+MfxlyX9p7FHHen/DbA2rNRzAdMGWGSqc9JlkGQNb63wFyRPIilNDqqkxO0 X-Received: by 2002:a62:670a:: with SMTP id b10-v6mr20038659pfc.243.1539657630936; Mon, 15 Oct 2018 19:40:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539657630; cv=none; d=google.com; s=arc-20160816; b=RAhUxxdZZ4pWOihEyqx4p6kDlNmVZOnjNrvbM0XW/gLRoK+1L/uJPamJuWGEsk8SxA GVdXKZWjgPAGs+/4T9fy+nXn9CX2ULqoHoH18ZV+I//SPKtigtSuDGnhHs2EgIoEWVrk g+8HpkJFPe7XIpSacnwXr8zPCrfVBpYjeFkgQRE0XmNkT7VvLILw+z376rhyHUt4/+3D +AD+TDPhSCibLbyV3M9gWlz9jivy7dqOcGJtipujTtq3yUF/WQ0NIQARHFr1Sc4VcNv8 ro2gwvsJibbru57NQ3n1T/cwRkRfboEueR7ZNRy+m0dWaHlSKfVqJKwPuCfQdEjRa7Gx i4lA== 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=z9gITIcELWG27rLaIcJk8tbseVFI0WYmEbNyztkaaOmatDm/zw6qQE+mrqXLFo0dUQ oU1dgnhFI4DLpzAQTLW4QXnB/lEBwr0fzq0COf5N+E+ppXTNVL5RfhTBTeK1i49Izj4j Kf5LLxFUNEKHK7cphEINvtJjUQPi6Am8rm/k7oxz3ZS4fXrm0rsAnhGGvtIrajAIgdwF GPnzFlRwGqG0p4rDYEbSuYpLnHvSIx4xnO/qAuaCIHVVPW/RVfNfsE0YUG/qqn4fAjWO uk1GVysFQ6W8JEUyJBBHBX7G8JIJQXUCQ09A2fBYmX29XA+cI/rBGjKk8PoBtPw9ag/K 1oYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cNWp6OTI; 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 11-v6si13561579plc.224.2018.10.15.19.40.15; Mon, 15 Oct 2018 19:40:30 -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=cNWp6OTI; 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 S1727288AbeJPK1i (ORCPT + 99 others); Tue, 16 Oct 2018 06:27:38 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36643 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727266AbeJPK1g (ORCPT ); Tue, 16 Oct 2018 06:27:36 -0400 Received: by mail-pl1-f195.google.com with SMTP id y11-v6so10214355plt.3; Mon, 15 Oct 2018 19:39:32 -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=cNWp6OTIr9yNPrhjf6nUHyWFwdqYPcsARgDVtqR1LXavRAKnv2rzoWqg4PF9vRV0qS 6Cnk6gYyBHX33GKTwjHdNxQ4/tsbdEqeL6wpX/rqj+idxmRYRl6jaCzwuAVpmF+zdOud qTaXMvEZHnwuFCvAcbWDdZK4pwD58c4awu+Rfu/pX/Axalpak0FVnEzIIZ7EaOA3Lyb1 97K2wdGV+1t3LFURiNuJA35R3T1lkNXFXUpb8tcZ3/CY1GkPeipx/ODf9Dr2w0SArTqJ qKMO6eJWRRDXykH7M6iTnVPleDItYDTI2bSo9Juh22lPEYKGb5EzGQq2RZeQIvjbZIvH QYMQ== 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=CyIgZeE673ulbUaEj+QPaL6Kez+RDFtLhdHlVxK2eNC8QUhb0KUgj13KuL82XXDiBv xTNpZ75QVi0oR6uh6W4gLXzo7kVygU08szWosi+YlOO0CH+Rn5tg5VTy8w0tJJkXONLj bgaJ4EmLXS2IHElNp7F0BI3r1GqiYbtrbbWJxZQFbhZ1S+DMurNXtG1cDZtpMBeUOCOt RT5L3+Zw15J1i/JrmYB8WtGKDPsU5nQ4hnXKzDlhjCibNKtn40F9wAm2oJjI12gztyzn Oa+gBLZpGg1Lv0cNs9FivdI4k8GI+KpGnDV8jKWQ5p1DQPFngarAxRz0UAQcme8IDhf9 BQBg== X-Gm-Message-State: ABuFfojX/eDAPlFSs6q3yoQS3trpu6TSSYBJ8/gHBXuwBKYkaROuFfhI JklVyvXIYMv2JKC+k/GF1tQ= X-Received: by 2002:a17:902:b611:: with SMTP id b17-v6mr19578346pls.217.1539657572500; Mon, 15 Oct 2018 19:39:32 -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 u79-v6sm18620287pfd.117.2018.10.15.19.39.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Oct 2018 19:39:32 -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 v4 17/18] of: unittest: find overlays[] entry by name instead of index Date: Mon, 15 Oct 2018 19:37:37 -0700 Message-Id: <1539657458-24401-18-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539657458-24401-1-git-send-email-frowand.list@gmail.com> References: <1539657458-24401-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