aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_ioctl.c')
-rw-r--r--drivers/gpu/drm/drm_ioctl.c71
1 files changed, 48 insertions, 23 deletions
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 9b9ff46c2378..76d3d18056dd 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -132,32 +132,57 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
132 struct drm_master *master = file_priv->master; 132 struct drm_master *master = file_priv->master;
133 int len; 133 int len;
134 134
135 if (master->unique != NULL) 135 if (drm_core_check_feature(dev, DRIVER_USE_PLATFORM_DEVICE)) {
136 return -EBUSY; 136 master->unique_len = 10 + strlen(dev->platformdev->name);
137 137 master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
138 master->unique_len = 40; 138
139 master->unique_size = master->unique_len; 139 if (master->unique == NULL)
140 master->unique = kmalloc(master->unique_size, GFP_KERNEL); 140 return -ENOMEM;
141 if (master->unique == NULL) 141
142 return -ENOMEM; 142 len = snprintf(master->unique, master->unique_len,
143 "platform:%s", dev->platformdev->name);
144
145 if (len > master->unique_len)
146 DRM_ERROR("Unique buffer overflowed\n");
147
148 dev->devname =
149 kmalloc(strlen(dev->platformdev->name) +
150 master->unique_len + 2, GFP_KERNEL);
151
152 if (dev->devname == NULL)
153 return -ENOMEM;
154
155 sprintf(dev->devname, "%s@%s", dev->platformdev->name,
156 master->unique);
157
158 } else {
159 master->unique_len = 40;
160 master->unique_size = master->unique_len;
161 master->unique = kmalloc(master->unique_size, GFP_KERNEL);
162 if (master->unique == NULL)
163 return -ENOMEM;
164
165 len = snprintf(master->unique, master->unique_len,
166 "pci:%04x:%02x:%02x.%d",
167 drm_get_pci_domain(dev),
168 dev->pdev->bus->number,
169 PCI_SLOT(dev->pdev->devfn),
170 PCI_FUNC(dev->pdev->devfn));
171 if (len >= master->unique_len)
172 DRM_ERROR("buffer overflow");
173 else
174 master->unique_len = len;
143 175
144 len = snprintf(master->unique, master->unique_len, "pci:%04x:%02x:%02x.%d", 176 dev->devname =
145 drm_get_pci_domain(dev), 177 kmalloc(strlen(dev->driver->pci_driver.name) +
146 dev->pdev->bus->number, 178 master->unique_len + 2, GFP_KERNEL);
147 PCI_SLOT(dev->pdev->devfn),
148 PCI_FUNC(dev->pdev->devfn));
149 if (len >= master->unique_len)
150 DRM_ERROR("buffer overflow");
151 else
152 master->unique_len = len;
153 179
154 dev->devname = kmalloc(strlen(dev->driver->pci_driver.name) + 180 if (dev->devname == NULL)
155 master->unique_len + 2, GFP_KERNEL); 181 return -ENOMEM;
156 if (dev->devname == NULL)
157 return -ENOMEM;
158 182
159 sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name, 183 sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name,
160 master->unique); 184 master->unique);
185 }
161 186
162 return 0; 187 return 0;
163} 188}