Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1543060imm; Fri, 12 Oct 2018 21:56:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV60hKGqBPn8/z0eucPZ2jDY7j1siK1Z5NYQQPMGL11e2Z1OkJfVa8QbNbijuEDJmsrw9/DMI X-Received: by 2002:a62:3384:: with SMTP id z126-v6mr8748722pfz.85.1539406579199; Fri, 12 Oct 2018 21:56:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539406579; cv=none; d=google.com; s=arc-20160816; b=z20ZOcMH+BWpbPKcxyOkYtQj8dMKomOMxDJMkkbtgkOUJPOk0KxET8xlV/TkrlUSF2 D2+yYuMfWtSsNoFQ2sQUPx9aY3yqO7ims1Hdgdo0lSU32IgROfIEwIcZpZKN9jnVy6Iq WL64Mh1iKnQZURImlVaP1ce6+uZrzmX8trcbPvfU3QUQIoPSOWwrpR6u188ZlQKnoemu 4+NCqwWw0Nm/hCDzu7YFlazpGEFyY4uUgvGl670rJpXq4pFOLSCWtgdlV2v876u64HfA HJlzmQGiP1vTv6fuCNLQZMl6Lfw1yVS37PqdLwSL1yyDPh+bwHYcFnIdHvyXdqd+tcx/ Mm1g== 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=GWkKg9lhjzp8Bro1ieeK60OMe0zzfvDNJO6VBydH+6Cqrn2ALXoDJA9L6YYj/O1hkd W0e5DHgbNAsRlocliY6G9VlzAAjzCj5q7Hi35qLCKSrfmDO9C7tSarCUXFOWaViaKVVX zQ7gDWDZz66kpLkDdWnNO8KgT5LwOgxP6rg+yzi/l/vYjnSr0hOxaXTkUp+qs9A0fQPU VjPBLg+MHJLUa7rmOxfY/5RC0Yxovjmcg8mcifpjZ3kou10CzVHBPHB/8+SbJu+UnaUG aw+t53UT/tJNoJ0F69zMczqOhJPMFwUc9YrONDHXzdsZ9JjRN+OHEWMd/xhaCuG3+8RU 7QpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iqVjDp7q; 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 y125-v6si3267401pgb.14.2018.10.12.21.56.04; Fri, 12 Oct 2018 21:56:19 -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=iqVjDp7q; 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 S1727222AbeJMMbI (ORCPT + 99 others); Sat, 13 Oct 2018 08:31:08 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36908 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727034AbeJMMbH (ORCPT ); Sat, 13 Oct 2018 08:31:07 -0400 Received: by mail-pf1-f194.google.com with SMTP id j23-v6so7155975pfi.4; Fri, 12 Oct 2018 21:55:26 -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=iqVjDp7qSRCludwpzhZP+T2vAI8HXUGH5Z9VFN/X4D3GMsHivxJLSy2VErbzNb9hpA 6Cw1/VoT8y7Cvuvz+I0YCGphDsLaWbFGNzLdJgvui22gql3obyQOsLqEKB2TwgDquK1A dgMznPoWaz5NzpeYREodOyaJRopS6qCVWAuLJ+KzGJpwIQZWB4+zdPid97XrAkXI6qx6 7LHVawMRJwSFQSn+Ya2FaQNgcrUhvXmkx+j1ZZDnqYAGug1xzPUFg1wtnwR3QYT+TuSL +3Kdksst9QFm7W4Hf4JbZantLprYvW8qWONjBM0Ic3ETvimX0rP7s53aDT8C7HRJxSBG W8QA== 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=stqEPAgdl925nu3aKLyq3frFn8aG1GayfCX75SpYxZg7JKY6udMe+vxYWo/QVFKxvD X2u4tz1bg606Cd63g+umAU5ocvzYO9zt4LMPOwW+DsBhWw+tPutx9vrLu8KI6+CAijVJ FRZEH5NiRPgZ1IrFuUD134P0AXd3egNOExMaW4lJ7IEnZMBfkf2PkCjHRQ0dTYIbRMQ8 e1n32CTE/kgYytGFpYmrvaCJTsHMdX4c0O3qbNEQQBoDpICfdkGH9mdzzyn+eNKBLRX7 bzzq1BNUGK+iJB4aqjCLJKeTMAFp2sflA+fmAZSiB7U8VKzHkE7hFUbtmPBkILI5+e5c 79/Q== X-Gm-Message-State: ABuFfoh/sAS1cH+fbmfla0as9R5Zj+gym0PL9vE79o+ZucohXEzaksyb pul/aY4Y/V6eW8BAmURzaBM= X-Received: by 2002:a62:1551:: with SMTP id 78-v6mr8879371pfv.178.1539406526080; Fri, 12 Oct 2018 21:55:26 -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 h87-v6sm6959462pfj.78.2018.10.12.21.55.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 12 Oct 2018 21:55:25 -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 v2 17/18] of: unittest: find overlays[] entry by name instead of index Date: Fri, 12 Oct 2018 21:53:37 -0700 Message-Id: <1539406418-18162-18-git-send-email-frowand.list@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539406418-18162-1-git-send-email-frowand.list@gmail.com> References: <1539406418-18162-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