From patchwork Fri Dec 19 15:24:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 422898 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 752F614009B for ; Sat, 20 Dec 2014 02:25:13 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751880AbaLSPZM (ORCPT ); Fri, 19 Dec 2014 10:25:12 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:45422 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751533AbaLSPZM (ORCPT ); Fri, 19 Dec 2014 10:25:12 -0500 Received: by mail-pa0-f50.google.com with SMTP id bj1so1379420pad.37 for ; Fri, 19 Dec 2014 07:25:12 -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:in-reply-to:references; bh=abRTt5FFAVDwhCfoC5Wbfqot7FqWl/HQYBi/jxdzvaY=; b=x+UvmlKLE3ie8/jEK48FS9BcRud1tL2sAHkxhy/SdCFrD4eYKOV4n/VRCrXYVpKQC0 1ozLap86GGLKzG/6ZITlEAusI3s20carhn/uKuZ39fjft4igjTxnbjC9Mg8aoSt9E/Ey FgY7fmeKWyq1gtIDIFDVzH8IfmL+jN0SIIczMXmsjSUszH7SlOEIyouLO24+Uo+ROyj7 riqGY9KxXek+10F+f/V3d17jWx5fW2ylurdxMw2f7pWy42zLfjBIn21QF2DFTwj9UrlY /2027IJmKPtTgwgiypVeY0iVqZNQYZQWrpCylcJFEL7NxOPNVV8PzHk4VeozCpZCvnWW CpkQ== X-Received: by 10.70.128.15 with SMTP id nk15mr13011020pdb.121.1419002711919; Fri, 19 Dec 2014 07:25:11 -0800 (PST) Received: from localhost ([216.228.120.20]) by mx.google.com with ESMTPSA id ju4sm9848158pbc.81.2014.12.19.07.25.10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Dec 2014 07:25:11 -0800 (PST) From: Thierry Reding To: dri-devel@lists.freedesktop.org Cc: Sean Paul , Mark Zhang , linux-tegra@vger.kernel.org Subject: [PATCH 3/5] gpu: host1x: Factor out __host1x_device_del() Date: Fri, 19 Dec 2014 16:24:56 +0100 Message-Id: <1419002698-4963-3-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1419002698-4963-1-git-send-email-thierry.reding@gmail.com> References: <1419002698-4963-1-git-send-email-thierry.reding@gmail.com> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org From: Thierry Reding This function is needed in several places, so factor it out. Signed-off-by: Thierry Reding --- drivers/gpu/host1x/bus.c | 93 +++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index 769116dba797..0b52f0ea8871 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -279,10 +279,59 @@ void host1x_bus_exit(void) bus_unregister(&host1x_bus_type); } +static void __host1x_device_del(struct host1x_device *device) +{ + struct host1x_subdev *subdev, *sd; + struct host1x_client *client, *cl; + + mutex_lock(&device->subdevs_lock); + + /* unregister subdevices */ + list_for_each_entry_safe(subdev, sd, &device->active, list) { + /* + * host1x_subdev_unregister() will remove the client from + * any lists, so we'll need to manually add it back to the + * list of idle clients. + * + * XXX: Alternatively, perhaps don't remove the client from + * any lists in host1x_subdev_unregister() and instead do + * that explicitly from host1x_unregister_client()? + */ + client = subdev->client; + + __host1x_subdev_unregister(device, subdev); + + /* add the client to the list of idle clients */ + mutex_lock(&clients_lock); + list_add_tail(&client->list, &clients); + mutex_unlock(&clients_lock); + } + + /* remove subdevices */ + list_for_each_entry_safe(subdev, sd, &device->subdevs, list) + host1x_subdev_del(subdev); + + mutex_unlock(&device->subdevs_lock); + + /* move clients to idle list */ + mutex_lock(&clients_lock); + mutex_lock(&device->clients_lock); + + list_for_each_entry_safe(client, cl, &device->clients, list) + list_move_tail(&client->list, &clients); + + mutex_unlock(&device->clients_lock); + mutex_unlock(&clients_lock); + + /* finally remove the device */ + list_del_init(&device->list); +} + static void host1x_device_release(struct device *dev) { struct host1x_device *device = to_host1x_device(dev); + __host1x_device_del(device); kfree(device); } @@ -350,50 +399,6 @@ static int host1x_device_add(struct host1x *host1x, static void host1x_device_del(struct host1x *host1x, struct host1x_device *device) { - struct host1x_subdev *subdev, *sd; - struct host1x_client *client, *cl; - - mutex_lock(&device->subdevs_lock); - - /* unregister subdevices */ - list_for_each_entry_safe(subdev, sd, &device->active, list) { - /* - * host1x_subdev_unregister() will remove the client from - * any lists, so we'll need to manually add it back to the - * list of idle clients. - * - * XXX: Alternatively, perhaps don't remove the client from - * any lists in host1x_subdev_unregister() and instead do - * that explicitly from host1x_unregister_client()? - */ - client = subdev->client; - - __host1x_subdev_unregister(device, subdev); - - /* add the client to the list of idle clients */ - mutex_lock(&clients_lock); - list_add_tail(&client->list, &clients); - mutex_unlock(&clients_lock); - } - - /* remove subdevices */ - list_for_each_entry_safe(subdev, sd, &device->subdevs, list) - host1x_subdev_del(subdev); - - mutex_unlock(&device->subdevs_lock); - - /* move clients to idle list */ - mutex_lock(&clients_lock); - mutex_lock(&device->clients_lock); - - list_for_each_entry_safe(client, cl, &device->clients, list) - list_move_tail(&client->list, &clients); - - mutex_unlock(&device->clients_lock); - mutex_unlock(&clients_lock); - - /* finally remove the device */ - list_del_init(&device->list); device_unregister(&device->dev); }