mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-21 10:05:00 +08:00
b3f2333de8
There's really no need for the drm core to keep a list of all devices of a given driver - the linux device model keeps perfect track of this already for us. The exception is old legacy ums drivers using pci shadow attaching. So rename the lists to make the use case clearer and rip out everything else. v2: Rebase on top of David Herrmann's drm device register changes. Also drop the bogus dev_set_drvdata for platform drivers that somehow crept into the original version - drivers really should be in full control of that field. v3: Initialize driver->legacy_dev_list outside of the loop, spotted by David Herrmann. v4: Rebase on top of the newly created host1x drm_bus for tegra. Cc: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
76 lines
1.7 KiB
C
76 lines
1.7 KiB
C
/*
|
|
* Copyright (C) 2013 NVIDIA Corporation
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#include "drm.h"
|
|
|
|
static int drm_host1x_set_busid(struct drm_device *dev,
|
|
struct drm_master *master)
|
|
{
|
|
const char *device = dev_name(dev->dev);
|
|
const char *driver = dev->driver->name;
|
|
const char *bus = dev->dev->bus->name;
|
|
int length;
|
|
|
|
master->unique_len = strlen(bus) + 1 + strlen(device);
|
|
master->unique_size = master->unique_len;
|
|
|
|
master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
|
|
if (!master->unique)
|
|
return -ENOMEM;
|
|
|
|
snprintf(master->unique, master->unique_len + 1, "%s:%s", bus, device);
|
|
|
|
length = strlen(driver) + 1 + master->unique_len;
|
|
|
|
dev->devname = kmalloc(length + 1, GFP_KERNEL);
|
|
if (!dev->devname)
|
|
return -ENOMEM;
|
|
|
|
snprintf(dev->devname, length + 1, "%s@%s", driver, master->unique);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static struct drm_bus drm_host1x_bus = {
|
|
.bus_type = DRIVER_BUS_HOST1X,
|
|
.set_busid = drm_host1x_set_busid,
|
|
};
|
|
|
|
int drm_host1x_init(struct drm_driver *driver, struct host1x_device *device)
|
|
{
|
|
struct drm_device *drm;
|
|
int ret;
|
|
|
|
driver->bus = &drm_host1x_bus;
|
|
|
|
drm = drm_dev_alloc(driver, &device->dev);
|
|
if (!drm)
|
|
return -ENOMEM;
|
|
|
|
ret = drm_dev_register(drm, 0);
|
|
if (ret)
|
|
goto err_free;
|
|
|
|
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", driver->name,
|
|
driver->major, driver->minor, driver->patchlevel,
|
|
driver->date, drm->primary->index);
|
|
|
|
return 0;
|
|
|
|
err_free:
|
|
drm_dev_free(drm);
|
|
return ret;
|
|
}
|
|
|
|
void drm_host1x_exit(struct drm_driver *driver, struct host1x_device *device)
|
|
{
|
|
struct tegra_drm *tegra = dev_get_drvdata(&device->dev);
|
|
|
|
drm_put_dev(tegra->drm);
|
|
}
|