From patchwork Mon Jan 4 12:13:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 59124 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp5321201lbb; Mon, 4 Jan 2016 04:14:00 -0800 (PST) X-Received: by 10.66.250.165 with SMTP id zd5mr52790547pac.9.1451909640565; Mon, 04 Jan 2016 04:14:00 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c7si65696815pfj.114.2016.01.04.04.14.00; Mon, 04 Jan 2016 04:14:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753318AbcADMN7 (ORCPT + 6 others); Mon, 4 Jan 2016 07:13:59 -0500 Received: from sauhun.de ([89.238.76.85]:44388 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753299AbcADMN6 (ORCPT ); Mon, 4 Jan 2016 07:13:58 -0500 Received: from p4fe24e64.dip0.t-ipconnect.de ([79.226.78.100]:44225 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1aG41L-0006Q0-4B; Mon, 04 Jan 2016 13:13:55 +0100 From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Pantelis Antoniou , Rob Herring , Greg Kroah-Hartman , Ricardo Ribalda Delgado , Rob Herring , Frank Rowand , Grant Likely , devicetree@vger.kernel.org Subject: [PATCH v2] of/unittest: Show broken behaviour in the platform bus Date: Mon, 4 Jan 2016 13:13:21 +0100 Message-Id: <1451909614-5519-1-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.1.4 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Grant Likely Add a single resource to the test bus device to exercise the platform bus code a little more. This isn't strictly a devicetree test, but it is a corner case that the devicetree runs into. Until we've got platform device unittests, it can live here. It doesn't need to be an explicit text because the kernel will oops when it is wrong. Cc: Pantelis Antoniou Cc: Rob Herring Cc: Greg Kroah-Hartman Cc: Ricardo Ribalda Delgado Signed-off-by: Grant Likely [wsa: added the comment provided by Grant, rebased, and tested] Signed-off-by: Wolfram Sang --- drivers/of/unittest.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) I found this patch in one of my branches and think it is still worth applying. In v1, Rob wanted a comment added which Grant provided but never folded into the patch. I have done so now :) Note that the fix to this problem was already picked up by Rob. -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index e16ea5717b7f76..bbff09dee1cf45 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -757,6 +757,11 @@ static void __init of_unittest_match_node(void) } } +static struct resource test_bus_res = { + .start = 0xfffffff8, + .end = 0xfffffff9, + .flags = IORESOURCE_MEM, +}; static const struct platform_device_info test_bus_info = { .name = "unittest-bus", }; @@ -800,6 +805,15 @@ static void __init of_unittest_platform_populate(void) return; test_bus->dev.of_node = np; + /* + * Add a dummy resource to the test bus node after it is + * registered to catch problems with un-inserted resources. The + * DT code doesn't insert the resources, and it has caused the + * kernel to oops in the past. This makes sure the same bug + * doesn't crop up again. + */ + platform_device_add_resources(test_bus, &test_bus_res, 1); + of_platform_populate(np, match, NULL, &test_bus->dev); for_each_child_of_node(np, child) { for_each_child_of_node(child, grandchild)