From patchwork Sun Jun 7 14:20:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 49603 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2C4DD22B3F for ; Sun, 7 Jun 2015 17:00:11 +0000 (UTC) Received: by lagh7 with SMTP id h7sf9546449lag.2 for ; Sun, 07 Jun 2015 10:00:10 -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:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=gL4NXijNAdkYjtfVBT8RasC4nmVjroNaxIfrHeLqPqI=; b=lKyStJw8WrcoFzMngyTLUltV8RSQaDcXTnvWeELZYQ3MxPJpJpGSUXUJiHWZey7SWJ AUDWdqcI8H2b7neJtX6BC260+Qw5v7UnYGQ2GGupxc5VAGKj8ZTSXWqm1zuQvFhNzzep EmIEC12TbzwdBbGB4QUGyGcJjMbeTpLsfdKPEc4uEdDiS/vpQmHWBR5pITIhFhEtsuWs yvV9fMNqF1yOLeLiBn3eKPJldXTdRRvk1BrBf/BRH/tkx436mtP27ynKWV0NsAHPCBni Hn7sSZ0IgOsoeZ4wKtt17wy3HrOczrf3Symgr/y66Dy5DZPN7RSISSuZXMrSJbOrd4pL aPHQ== X-Gm-Message-State: ALoCoQkwB6GGbEEMjreF0QMNaNtDpoIhM9rs62PNwhG603Y+ncSQDOuNCDyuRZ8VG5QPYcwEnsUW X-Received: by 10.180.106.10 with SMTP id gq10mr8508080wib.0.1433696410124; Sun, 07 Jun 2015 10:00:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.8.1 with SMTP id n1ls486419laa.87.gmail; Sun, 07 Jun 2015 10:00:09 -0700 (PDT) X-Received: by 10.112.151.178 with SMTP id ur18mr12805338lbb.59.1433696409808; Sun, 07 Jun 2015 10:00:09 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id ks3si148417lac.164.2015.06.07.10.00.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Jun 2015 10:00:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbqq2 with SMTP id qq2so68082554lbb.3 for ; Sun, 07 Jun 2015 10:00:09 -0700 (PDT) X-Received: by 10.112.199.133 with SMTP id jk5mr12971163lbc.32.1433696409707; Sun, 07 Jun 2015 10:00:09 -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.108.230 with SMTP id hn6csp1263239lbb; Sun, 7 Jun 2015 10:00:08 -0700 (PDT) X-Received: by 10.68.107.97 with SMTP id hb1mr22636681pbb.143.1433696407834; Sun, 07 Jun 2015 10:00:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id je6si194421pbd.229.2015.06.07.10.00.06; Sun, 07 Jun 2015 10:00:07 -0700 (PDT) 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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751656AbbFGRAB (ORCPT + 7 others); Sun, 7 Jun 2015 13:00:01 -0400 Received: from mail-wg0-f41.google.com ([74.125.82.41]:36014 "EHLO mail-wg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752270AbbFGQ7f (ORCPT ); Sun, 7 Jun 2015 12:59:35 -0400 Received: by wgbgq6 with SMTP id gq6so86915249wgb.3 for ; Sun, 07 Jun 2015 09:59:34 -0700 (PDT) X-Received: by 10.194.61.236 with SMTP id t12mr24956567wjr.59.1433696373999; Sun, 07 Jun 2015 09:59:33 -0700 (PDT) Received: from trevor.secretlab.ca (host81-159-186-103.range81-159.btcentralplus.com. [81.159.186.103]) by mx.google.com with ESMTPSA id yz3sm274242wjc.19.2015.06.07.09.59.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Jun 2015 09:59:32 -0700 (PDT) Received: by trevor.secretlab.ca (Postfix, from userid 1000) id EEF8CC41EA8; Sun, 7 Jun 2015 23:20:16 +0900 (JST) From: Grant Likely To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Grant Likely , Pantelis Antoniou , Wolfram Sang , Rob Herring , Greg Kroah-Hartman , Ricardo Ribalda Delgado Subject: [PATCH 2/2] drivercore: Fix unregistration path of platform devices Date: Sun, 7 Jun 2015 15:20:11 +0100 Message-Id: <1433686811-12303-3-git-send-email-grant.likely@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1433686811-12303-1-git-send-email-grant.likely@linaro.org> References: <1433686811-12303-1-git-send-email-grant.likely@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@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.217.169 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 unregister path of platform_device is broken. On registration, it will register all resources with either a parent already set, or type==IORESOURCE_{IO,MEM}. However, on unregister it will release everything with type==IORESOURCE_{IO,MEM}, but ignore the others. There are also cases where resources don't get registered in the first place, like with devices created by of_platform_populate()*. Fix the unregister path to be symmetrical with the register path by checking the parent pointer instead of the type field to decide which resources to unregister. This is safe because the upshot of the registration path algorithm is that registered resources have a parent pointer, and non-registered resources do not. * It can be argued that of_platform_populate() should be registering it's resources, and they argument has some merit. However, there are quite a few platforms that end up broken if we try to do that due to overlapping resources in the device tree. Until that is fixed, we need to solve the immediate problem. Cc: Pantelis Antoniou Cc: Wolfram Sang Cc: Rob Herring Cc: Greg Kroah-Hartman Cc: Ricardo Ribalda Delgado Signed-off-by: Grant Likely --- drivers/base/platform.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index ebf034b97278..7403de94832c 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -375,9 +375,7 @@ int platform_device_add(struct platform_device *pdev) while (--i >= 0) { struct resource *r = &pdev->resource[i]; - unsigned long type = resource_type(r); - - if (type == IORESOURCE_MEM || type == IORESOURCE_IO) + if (r->parent) release_resource(r); } @@ -408,9 +406,7 @@ void platform_device_del(struct platform_device *pdev) for (i = 0; i < pdev->num_resources; i++) { struct resource *r = &pdev->resource[i]; - unsigned long type = resource_type(r); - - if (type == IORESOURCE_MEM || type == IORESOURCE_IO) + if (r->parent) release_resource(r); } }