From patchwork Fri Dec 19 15:24:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 5520451 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AC6F79F1CD for ; Fri, 19 Dec 2014 15:25:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD44B2013D for ; Fri, 19 Dec 2014 15:25:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C964C20131 for ; Fri, 19 Dec 2014 15:25:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 48BB06E537; Fri, 19 Dec 2014 07:25:04 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by gabe.freedesktop.org (Postfix) with ESMTP id 5EA586E537 for ; Fri, 19 Dec 2014 07:25:03 -0800 (PST) Received: by mail-pd0-f178.google.com with SMTP id r10so1398238pdi.9 for ; Fri, 19 Dec 2014 07:25:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=EoM5ypHvAXEab+9bjWsgjJCvYKircn089h9cmSZXA7I=; b=rZc/c52TXOuoJkCxF3GyDg3sbT/qkfl3/enqbXjsFkbFCc/r/b4Rc9Pueo/yBsrOwl C34m4dFpfQYat4MNzqa/LR3Fsq9zfu0ZKnp4osd9kUcZA1AJsBuFsR8BXejbGbjYH2Jr pH6FBn247fbdg2hzwQRglIGrdGuty+1Lyv1wVkdGMZvAUBhXUMmpLTJDYzGhg1oimnok 5tJdZBRIawtT9U5aWYyFeEB1cCToMUGOWlixReOCyhmulBmT7HogyIl/G+IHrh0NMrDo T2vk0DbmldSm6bpSBx3seQNPC+KPUbE1c+BqAn10Ke82wOKiXjlfXIz/C0bReLJUmcJ/ 6U4g== X-Received: by 10.70.137.42 with SMTP id qf10mr13358099pdb.11.1419002703102; Fri, 19 Dec 2014 07:25:03 -0800 (PST) Received: from localhost ([216.228.120.20]) by mx.google.com with ESMTPSA id x8sm9980047pdi.7.2014.12.19.07.25.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Dec 2014 07:25:02 -0800 (PST) From: Thierry Reding To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/5] gpu: host1x: Call ->remove() only when a device is bound Date: Fri, 19 Dec 2014 16:24:54 +0100 Message-Id: <1419002698-4963-1-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.1.3 Cc: linux-tegra@vger.kernel.org, Mark Zhang X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding When a driver's ->probe() function fails, the host1x bus must not call its ->remove() function because the driver will already have cleaned up in the error handling path in ->probe(). Signed-off-by: Thierry Reding --- drivers/gpu/host1x/bus.c | 9 +++++++-- include/linux/host1x.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index aaf54859adb0..e4182e68e29c 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -116,7 +116,10 @@ static void host1x_subdev_register(struct host1x_device *device, if (list_empty(&device->subdevs)) { err = device->driver->probe(device); if (err < 0) - dev_err(&device->dev, "probe failed: %d\n", err); + dev_err(&device->dev, "probe failed for %ps: %d\n", + device->driver, err); + else + device->bound = true; } } @@ -130,10 +133,12 @@ static void __host1x_subdev_unregister(struct host1x_device *device, * If all subdevices have been activated, we're about to remove the * first active subdevice, so unload the driver first. */ - if (list_empty(&device->subdevs)) { + if (list_empty(&device->subdevs) && device->bound) { err = device->driver->remove(device); if (err < 0) dev_err(&device->dev, "remove failed: %d\n", err); + + device->bound = false; } /* diff --git a/include/linux/host1x.h b/include/linux/host1x.h index bb9840fd1e18..7890b553d12e 100644 --- a/include/linux/host1x.h +++ b/include/linux/host1x.h @@ -272,6 +272,8 @@ struct host1x_device { struct mutex clients_lock; struct list_head clients; + + bool bound; }; static inline struct host1x_device *to_host1x_device(struct device *dev)