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: 422896 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E65CF14009B for ; Sat, 20 Dec 2014 02:25:04 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751545AbaLSPZE (ORCPT ); Fri, 19 Dec 2014 10:25:04 -0500 Received: from mail-pd0-f178.google.com ([209.85.192.178]:56450 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751382AbaLSPZD (ORCPT ); Fri, 19 Dec 2014 10:25:03 -0500 Received: by mail-pd0-f178.google.com with SMTP id r10so1376379pdi.23 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 Cc: Sean Paul , Mark Zhang , linux-tegra@vger.kernel.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 Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org 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)