From patchwork Sat Mar 28 04:08:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 46452 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CA8E12159F for ; Sat, 28 Mar 2015 12:05:47 +0000 (UTC) Received: by lajy8 with SMTP id y8sf5056388laj.3 for ; Sat, 28 Mar 2015 05:05:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=GoAOUSBsBGUv3LzjqztWDagVS2eKSwmDz9xGi1IPlvw=; b=DMu+xjGefIhqq0KgEFnkAO9HO1nf1xzSO3OlV2rsGk312FUgbADlwSpsi7MezfVk22 ub5AbyjIKWFXuIGLpmJQOgO+JFtSDmR2C2cjSC4VBiL4XrROhnsChEiLg53w28sj0eCv L57TYXfYKCgUJGth2QT5geLCd2WjjutpGuCzr01dLmSO8ohiQi/+SLPrJmXg1A8wBDHd jjzoMiycoYHPwpxNpRhWpm08wAOamekBHTIuyMqF6w9YbuOXMBgBmpXAcEK7VAdbx7jT hNLBVnApModjxfn6n27OFqoZ+q2ZtC6XI+k4TyMOyLu2mtzKwUe8SJXalC2QjUDxorzV WWDg== X-Gm-Message-State: ALoCoQli/+7qQOhyyPSbT2IP/n7Z/4g9Wc1uw33ZnF3x4wjSQN2WzRObjmTf1gjCUbI0fbxExd+K X-Received: by 10.194.53.225 with SMTP id e1mr5783059wjp.4.1427544346769; Sat, 28 Mar 2015 05:05:46 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.4 with SMTP id lc4ls440316lac.104.gmail; Sat, 28 Mar 2015 05:05:46 -0700 (PDT) X-Received: by 10.152.244.161 with SMTP id xh1mr20970677lac.119.1427544346453; Sat, 28 Mar 2015 05:05:46 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id p3si3235114lae.151.2015.03.28.05.05.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Mar 2015 05:05:46 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by lahp7 with SMTP id p7so69077858lah.2 for ; Sat, 28 Mar 2015 05:05:46 -0700 (PDT) X-Received: by 10.112.162.167 with SMTP id yb7mr20858237lbb.76.1427544346304; Sat, 28 Mar 2015 05:05:46 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.57.201 with SMTP id k9csp407379lbq; Sat, 28 Mar 2015 05:05:45 -0700 (PDT) X-Received: by 10.70.37.3 with SMTP id u3mr42947515pdj.143.1427544344178; Sat, 28 Mar 2015 05:05:44 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zg5si6737114pbb.66.2015.03.28.05.05.14; Sat, 28 Mar 2015 05:05:44 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753502AbbC1MEs (ORCPT + 27 others); Sat, 28 Mar 2015 08:04:48 -0400 Received: from mail-wg0-f42.google.com ([74.125.82.42]:35643 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752987AbbC1MCr (ORCPT ); Sat, 28 Mar 2015 08:02:47 -0400 Received: by wgdm6 with SMTP id m6so124800894wgd.2 for ; Sat, 28 Mar 2015 05:02:46 -0700 (PDT) X-Received: by 10.180.89.163 with SMTP id bp3mr5667083wib.88.1427544166329; Sat, 28 Mar 2015 05:02:46 -0700 (PDT) Received: from trevor.secretlab.ca ([37.205.61.206]) by mx.google.com with ESMTPSA id d9sm6868609wib.20.2015.03.28.05.02.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Mar 2015 05:02:45 -0700 (PDT) Received: by trevor.secretlab.ca (Postfix, from userid 1000) id 73038C40BE0; Sat, 28 Mar 2015 04:08:28 +0000 (GMT) From: Grant Likely To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Grant Likely , Frank Rowand , Pantelis Antoniou , Pawel Moll Subject: [PATCH] of/unittest: Fix of_platform_depopulate test case Date: Fri, 27 Mar 2015 21:08:27 -0700 Message-Id: <1427515707-29879-1-git-send-email-grant.likely@linaro.org> X-Mailer: git-send-email 2.1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: grant.likely@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The previous commit, "of/unittest: early return from test skips tests" exposed broken tests for the of_platform_unpopulate() function. The problem was the populate and depopulate calls were not symmetrical like they were intended to be, and unpopulate depends on the parent device to have it's of_node pointer pointing to the parent device node. Fix these bugs so that the test case works correctly. In the process, the test_bus used as a container for the test devices has been changed from a statically allocated struct device (which is bad) to a properly allocated device with a .release() method (which is good). This stops the test code from being a bad example of abusing the device model. Signed-off-by: Grant Likely Cc: Frank Rowand Cc: Pantelis Antoniou Cc: Pawel Moll --- (I've already got this commit in my tree queued up after the patch that exposes the bug, which is why I've written the description the way I did.) drivers/of/unittest.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 3b155774dfee..a4f90c238e78 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -751,14 +751,14 @@ static void __init of_selftest_match_node(void) } } -struct device test_bus = { - .init_name = "unittest-bus", +static const struct platform_device_info test_bus_info = { + .name = "unittest-bus", }; static void __init of_selftest_platform_populate(void) { int irq, rc; struct device_node *np, *child, *grandchild; - struct platform_device *pdev; + struct platform_device *pdev, *test_bus; const struct of_device_id match[] = { { .compatible = "test-device", }, {} @@ -787,20 +787,22 @@ static void __init of_selftest_platform_populate(void) if (!np) return; - rc = device_register(&test_bus); + test_bus = platform_device_register_full(&test_bus_info); + rc = PTR_ERR_OR_ZERO(test_bus); selftest(!rc, "testbus registration failed; rc=%i\n", rc); if (rc) return; + test_bus->dev.of_node = np; + of_platform_populate(np, match, NULL, &test_bus->dev); for_each_child_of_node(np, child) { - of_platform_populate(child, match, NULL, &test_bus); for_each_child_of_node(child, grandchild) selftest(of_find_device_by_node(grandchild), "Could not create device for node '%s'\n", grandchild->name); } - of_platform_depopulate(&test_bus); + of_platform_depopulate(&test_bus->dev); for_each_child_of_node(np, child) { for_each_child_of_node(child, grandchild) selftest(!of_find_device_by_node(grandchild), @@ -808,7 +810,7 @@ static void __init of_selftest_platform_populate(void) grandchild->name); } - device_unregister(&test_bus); + platform_device_unregister(test_bus); of_node_put(np); }