aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_platform.c')
-rw-r--r--drivers/gpu/drm/drm_platform.c31
1 files changed, 8 insertions, 23 deletions
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c
index d5b76f148c12..0c09ddd50c15 100644
--- a/drivers/gpu/drm/drm_platform.c
+++ b/drivers/gpu/drm/drm_platform.c
@@ -70,35 +70,20 @@ err_free:
70 70
71static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master) 71static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master)
72{ 72{
73 int len, ret, id; 73 int id;
74
75 master->unique_len = 13 + strlen(dev->platformdev->name);
76 master->unique_size = master->unique_len;
77 master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
78
79 if (master->unique == NULL)
80 return -ENOMEM;
81 74
82 id = dev->platformdev->id; 75 id = dev->platformdev->id;
83 76 if (id < 0)
84 /* if only a single instance of the platform device, id will be
85 * set to -1.. use 0 instead to avoid a funny looking bus-id:
86 */
87 if (id == -1)
88 id = 0; 77 id = 0;
89 78
90 len = snprintf(master->unique, master->unique_len, 79 master->unique = kasprintf(GFP_KERNEL, "platform:%s:%02d",
91 "platform:%s:%02d", dev->platformdev->name, id); 80 dev->platformdev->name, id);
92 81 if (!master->unique)
93 if (len > master->unique_len) { 82 return -ENOMEM;
94 DRM_ERROR("Unique buffer overflowed\n");
95 ret = -EINVAL;
96 goto err;
97 }
98 83
84 master->unique_len = strlen(master->unique);
85 master->unique_size = master->unique_len;
99 return 0; 86 return 0;
100err:
101 return ret;
102} 87}
103 88
104static struct drm_bus drm_platform_bus = { 89static struct drm_bus drm_platform_bus = {