diff options
Diffstat (limited to 'drivers/gpu/drm/drm_platform.c')
| -rw-r--r-- | drivers/gpu/drm/drm_platform.c | 115 |
1 files changed, 57 insertions, 58 deletions
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c index 92d1d0fb7b7..d5b76f148c1 100644 --- a/drivers/gpu/drm/drm_platform.c +++ b/drivers/gpu/drm/drm_platform.c @@ -25,9 +25,10 @@ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "drmP.h" +#include <linux/export.h> +#include <drm/drmP.h> -/** +/* * Register. * * \param platdev - Platform device struture @@ -38,90 +39,88 @@ * Try and register, if we fail to register, backout previous work. */ -int drm_get_platform_dev(struct platform_device *platdev, - struct drm_driver *driver) +static int drm_get_platform_dev(struct platform_device *platdev, + struct drm_driver *driver) { struct drm_device *dev; int ret; DRM_DEBUG("\n"); - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = drm_dev_alloc(driver, &platdev->dev); if (!dev) return -ENOMEM; dev->platformdev = platdev; - dev->dev = &platdev->dev; - mutex_lock(&drm_global_mutex); + ret = drm_dev_register(dev, 0); + if (ret) + goto err_free; - ret = drm_fill_in_dev(dev, NULL, driver); + DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", + driver->name, driver->major, driver->minor, driver->patchlevel, + driver->date, dev->primary->index); - if (ret) { - printk(KERN_ERR "DRM: Fill_in_dev failed.\n"); - goto err_g1; - } + return 0; - if (drm_core_check_feature(dev, DRIVER_MODESET)) { - dev_set_drvdata(&platdev->dev, dev); - ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL); - if (ret) - goto err_g1; - } +err_free: + drm_dev_unref(dev); + return ret; +} - ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY); - if (ret) - goto err_g2; +static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master) +{ + int len, ret, id; - if (dev->driver->load) { - ret = dev->driver->load(dev, 0); - if (ret) - goto err_g3; - } + master->unique_len = 13 + strlen(dev->platformdev->name); + master->unique_size = master->unique_len; + master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL); - /* setup the grouping for the legacy output */ - if (drm_core_check_feature(dev, DRIVER_MODESET)) { - ret = drm_mode_group_init_legacy_group(dev, - &dev->primary->mode_group); - if (ret) - goto err_g3; - } + if (master->unique == NULL) + return -ENOMEM; - list_add_tail(&dev->driver_item, &driver->device_list); + id = dev->platformdev->id; - mutex_unlock(&drm_global_mutex); + /* if only a single instance of the platform device, id will be + * set to -1.. use 0 instead to avoid a funny looking bus-id: + */ + if (id == -1) + id = 0; - DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", - driver->name, driver->major, driver->minor, driver->patchlevel, - driver->date, dev->primary->index); + len = snprintf(master->unique, master->unique_len, + "platform:%s:%02d", dev->platformdev->name, id); - return 0; + if (len > master->unique_len) { + DRM_ERROR("Unique buffer overflowed\n"); + ret = -EINVAL; + goto err; + } -err_g3: - drm_put_minor(&dev->primary); -err_g2: - if (drm_core_check_feature(dev, DRIVER_MODESET)) - drm_put_minor(&dev->control); -err_g1: - kfree(dev); - mutex_unlock(&drm_global_mutex); + return 0; +err: return ret; } -EXPORT_SYMBOL(drm_get_platform_dev); + +static struct drm_bus drm_platform_bus = { + .set_busid = drm_platform_set_busid, +}; /** - * Platform device initialization. Called via drm_init at module load time, - * - * \return zero on success or a negative number on failure. + * drm_platform_init - Register a platform device with the DRM subsystem + * @driver: DRM device driver + * @platform_device: platform device to register * - * Initializes a drm_device structures,registering the - * stubs + * Registers the specified DRM device driver and platform device with the DRM + * subsystem, initializing a drm_device structure and calling the driver's + * .load() function. * - * Expands the \c DRIVER_PREINIT and \c DRIVER_POST_INIT macros before and - * after the initialization for driver customization. + * Return: 0 on success or a negative error code on failure. */ - -int drm_platform_init(struct drm_driver *driver) +int drm_platform_init(struct drm_driver *driver, struct platform_device *platform_device) { - return drm_get_platform_dev(driver->platform_device, driver); + DRM_DEBUG("\n"); + + driver->bus = &drm_platform_bus; + return drm_get_platform_dev(platform_device, driver); } +EXPORT_SYMBOL(drm_platform_init); |
