PM / sleep: Asynchronous threads for suspend_noirq
[linux/fpc-iii.git] / drivers / gpu / drm / tegra / bus.c
blobe38e5967d77bdc4a4c709cd44744887318cb87bf
1 /*
2 * Copyright (C) 2013 NVIDIA Corporation
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 */
9 #include "drm.h"
11 static int drm_host1x_set_busid(struct drm_device *dev,
12 struct drm_master *master)
14 const char *device = dev_name(dev->dev);
15 const char *driver = dev->driver->name;
16 const char *bus = dev->dev->bus->name;
17 int length;
19 master->unique_len = strlen(bus) + 1 + strlen(device);
20 master->unique_size = master->unique_len;
22 master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
23 if (!master->unique)
24 return -ENOMEM;
26 snprintf(master->unique, master->unique_len + 1, "%s:%s", bus, device);
28 length = strlen(driver) + 1 + master->unique_len;
30 dev->devname = kmalloc(length + 1, GFP_KERNEL);
31 if (!dev->devname)
32 return -ENOMEM;
34 snprintf(dev->devname, length + 1, "%s@%s", driver, master->unique);
36 return 0;
39 static struct drm_bus drm_host1x_bus = {
40 .bus_type = DRIVER_BUS_HOST1X,
41 .set_busid = drm_host1x_set_busid,
44 int drm_host1x_init(struct drm_driver *driver, struct host1x_device *device)
46 struct drm_device *drm;
47 int ret;
49 driver->bus = &drm_host1x_bus;
51 drm = drm_dev_alloc(driver, &device->dev);
52 if (!drm)
53 return -ENOMEM;
55 ret = drm_dev_register(drm, 0);
56 if (ret)
57 goto err_free;
59 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", driver->name,
60 driver->major, driver->minor, driver->patchlevel,
61 driver->date, drm->primary->index);
63 return 0;
65 err_free:
66 drm_dev_free(drm);
67 return ret;
70 void drm_host1x_exit(struct drm_driver *driver, struct host1x_device *device)
72 struct tegra_drm *tegra = dev_get_drvdata(&device->dev);
74 drm_put_dev(tegra->drm);