aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_pci.c')
-rw-r--r--drivers/gpu/drm/drm_pci.c41
1 files changed, 10 insertions, 31 deletions
diff --git a/drivers/gpu/drm/drm_pci.c b/drivers/gpu/drm/drm_pci.c
index 020cfd934854..7563130c6b70 100644
--- a/drivers/gpu/drm/drm_pci.c
+++ b/drivers/gpu/drm/drm_pci.c
@@ -127,34 +127,20 @@ static int drm_get_pci_domain(struct drm_device *dev)
127 return pci_domain_nr(dev->pdev->bus); 127 return pci_domain_nr(dev->pdev->bus);
128} 128}
129 129
130static int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master) 130int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master)
131{ 131{
132 int len, ret; 132 master->unique = kasprintf(GFP_KERNEL, "pci:%04x:%02x:%02x.%d",
133 master->unique_len = 40; 133 drm_get_pci_domain(dev),
134 master->unique_size = master->unique_len; 134 dev->pdev->bus->number,
135 master->unique = kmalloc(master->unique_size, GFP_KERNEL); 135 PCI_SLOT(dev->pdev->devfn),
136 if (master->unique == NULL) 136 PCI_FUNC(dev->pdev->devfn));
137 if (!master->unique)
137 return -ENOMEM; 138 return -ENOMEM;
138 139
139 140 master->unique_len = strlen(master->unique);
140 len = snprintf(master->unique, master->unique_len,
141 "pci:%04x:%02x:%02x.%d",
142 drm_get_pci_domain(dev),
143 dev->pdev->bus->number,
144 PCI_SLOT(dev->pdev->devfn),
145 PCI_FUNC(dev->pdev->devfn));
146
147 if (len >= master->unique_len) {
148 DRM_ERROR("buffer overflow");
149 ret = -EINVAL;
150 goto err;
151 } else
152 master->unique_len = len;
153
154 return 0; 141 return 0;
155err:
156 return ret;
157} 142}
143EXPORT_SYMBOL(drm_pci_set_busid);
158 144
159int drm_pci_set_unique(struct drm_device *dev, 145int drm_pci_set_unique(struct drm_device *dev,
160 struct drm_master *master, 146 struct drm_master *master,
@@ -163,8 +149,7 @@ int drm_pci_set_unique(struct drm_device *dev,
163 int domain, bus, slot, func, ret; 149 int domain, bus, slot, func, ret;
164 150
165 master->unique_len = u->unique_len; 151 master->unique_len = u->unique_len;
166 master->unique_size = u->unique_len + 1; 152 master->unique = kmalloc(master->unique_len + 1, GFP_KERNEL);
167 master->unique = kmalloc(master->unique_size, GFP_KERNEL);
168 if (!master->unique) { 153 if (!master->unique) {
169 ret = -ENOMEM; 154 ret = -ENOMEM;
170 goto err; 155 goto err;
@@ -269,10 +254,6 @@ void drm_pci_agp_destroy(struct drm_device *dev)
269 } 254 }
270} 255}
271 256
272static struct drm_bus drm_pci_bus = {
273 .set_busid = drm_pci_set_busid,
274};
275
276/** 257/**
277 * drm_get_pci_dev - Register a PCI device with the DRM subsystem 258 * drm_get_pci_dev - Register a PCI device with the DRM subsystem
278 * @pdev: PCI device 259 * @pdev: PCI device
@@ -353,8 +334,6 @@ int drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
353 334
354 DRM_DEBUG("\n"); 335 DRM_DEBUG("\n");
355 336
356 driver->bus = &drm_pci_bus;
357
358 if (driver->driver_features & DRIVER_MODESET) 337 if (driver->driver_features & DRIVER_MODESET)
359 return pci_register_driver(pdriver); 338 return pci_register_driver(pdriver);
360 339