diff options
author | Thierry Reding <treding@nvidia.com> | 2014-12-18 09:26:02 -0500 |
---|---|---|
committer | Thierry Reding <treding@nvidia.com> | 2015-01-23 06:07:01 -0500 |
commit | 99d2cd81d7261e6ddd325189134faf752206bfe7 (patch) | |
tree | fb9feece87e89725dfdbb7ac8da4283bb3664125 | |
parent | 38d98de4332fcdaa72fc83443c1e3268e4b2214b (diff) |
gpu: host1x: Factor out __host1x_device_del()
This function is needed in several places, so factor it out.
Signed-off-by: Thierry Reding <treding@nvidia.com>
-rw-r--r-- | drivers/gpu/host1x/bus.c | 93 |
1 files 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) | |||
279 | bus_unregister(&host1x_bus_type); | 279 | bus_unregister(&host1x_bus_type); |
280 | } | 280 | } |
281 | 281 | ||
282 | static void __host1x_device_del(struct host1x_device *device) | ||
283 | { | ||
284 | struct host1x_subdev *subdev, *sd; | ||
285 | struct host1x_client *client, *cl; | ||
286 | |||
287 | mutex_lock(&device->subdevs_lock); | ||
288 | |||
289 | /* unregister subdevices */ | ||
290 | list_for_each_entry_safe(subdev, sd, &device->active, list) { | ||
291 | /* | ||
292 | * host1x_subdev_unregister() will remove the client from | ||
293 | * any lists, so we'll need to manually add it back to the | ||
294 | * list of idle clients. | ||
295 | * | ||
296 | * XXX: Alternatively, perhaps don't remove the client from | ||
297 | * any lists in host1x_subdev_unregister() and instead do | ||
298 | * that explicitly from host1x_unregister_client()? | ||
299 | */ | ||
300 | client = subdev->client; | ||
301 | |||
302 | __host1x_subdev_unregister(device, subdev); | ||
303 | |||
304 | /* add the client to the list of idle clients */ | ||
305 | mutex_lock(&clients_lock); | ||
306 | list_add_tail(&client->list, &clients); | ||
307 | mutex_unlock(&clients_lock); | ||
308 | } | ||
309 | |||
310 | /* remove subdevices */ | ||
311 | list_for_each_entry_safe(subdev, sd, &device->subdevs, list) | ||
312 | host1x_subdev_del(subdev); | ||
313 | |||
314 | mutex_unlock(&device->subdevs_lock); | ||
315 | |||
316 | /* move clients to idle list */ | ||
317 | mutex_lock(&clients_lock); | ||
318 | mutex_lock(&device->clients_lock); | ||
319 | |||
320 | list_for_each_entry_safe(client, cl, &device->clients, list) | ||
321 | list_move_tail(&client->list, &clients); | ||
322 | |||
323 | mutex_unlock(&device->clients_lock); | ||
324 | mutex_unlock(&clients_lock); | ||
325 | |||
326 | /* finally remove the device */ | ||
327 | list_del_init(&device->list); | ||
328 | } | ||
329 | |||
282 | static void host1x_device_release(struct device *dev) | 330 | static void host1x_device_release(struct device *dev) |
283 | { | 331 | { |
284 | struct host1x_device *device = to_host1x_device(dev); | 332 | struct host1x_device *device = to_host1x_device(dev); |
285 | 333 | ||
334 | __host1x_device_del(device); | ||
286 | kfree(device); | 335 | kfree(device); |
287 | } | 336 | } |
288 | 337 | ||
@@ -350,50 +399,6 @@ static int host1x_device_add(struct host1x *host1x, | |||
350 | static void host1x_device_del(struct host1x *host1x, | 399 | static void host1x_device_del(struct host1x *host1x, |
351 | struct host1x_device *device) | 400 | struct host1x_device *device) |
352 | { | 401 | { |
353 | struct host1x_subdev *subdev, *sd; | ||
354 | struct host1x_client *client, *cl; | ||
355 | |||
356 | mutex_lock(&device->subdevs_lock); | ||
357 | |||
358 | /* unregister subdevices */ | ||
359 | list_for_each_entry_safe(subdev, sd, &device->active, list) { | ||
360 | /* | ||
361 | * host1x_subdev_unregister() will remove the client from | ||
362 | * any lists, so we'll need to manually add it back to the | ||
363 | * list of idle clients. | ||
364 | * | ||
365 | * XXX: Alternatively, perhaps don't remove the client from | ||
366 | * any lists in host1x_subdev_unregister() and instead do | ||
367 | * that explicitly from host1x_unregister_client()? | ||
368 | */ | ||
369 | client = subdev->client; | ||
370 | |||
371 | __host1x_subdev_unregister(device, subdev); | ||
372 | |||
373 | /* add the client to the list of idle clients */ | ||
374 | mutex_lock(&clients_lock); | ||
375 | list_add_tail(&client->list, &clients); | ||
376 | mutex_unlock(&clients_lock); | ||
377 | } | ||
378 | |||
379 | /* remove subdevices */ | ||
380 | list_for_each_entry_safe(subdev, sd, &device->subdevs, list) | ||
381 | host1x_subdev_del(subdev); | ||
382 | |||
383 | mutex_unlock(&device->subdevs_lock); | ||
384 | |||
385 | /* move clients to idle list */ | ||
386 | mutex_lock(&clients_lock); | ||
387 | mutex_lock(&device->clients_lock); | ||
388 | |||
389 | list_for_each_entry_safe(client, cl, &device->clients, list) | ||
390 | list_move_tail(&client->list, &clients); | ||
391 | |||
392 | mutex_unlock(&device->clients_lock); | ||
393 | mutex_unlock(&clients_lock); | ||
394 | |||
395 | /* finally remove the device */ | ||
396 | list_del_init(&device->list); | ||
397 | device_unregister(&device->dev); | 402 | device_unregister(&device->dev); |
398 | } | 403 | } |
399 | 404 | ||