diff options
author | Thomas White <taw@bitwiz.org.uk> | 2009-03-25 00:23:38 +0000 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2009-03-26 21:34:13 +0000 |
commit | 6255cc61de0bf9932c853fe3d7988dbc7f00a45b (patch) | |
tree | 5658279fa4da12c368c8d0ea46210947fd811f3c /drivers/gpu/drm | |
parent | 3ef7d4c47ca2ca61e56aae3fdf7b16dc27ca79ad (diff) |
Take account of platform devices in drm_setunique() and drm_set_busid()
This is done in a slightly nasty way. We should perhaps try to come up
with a better way of uniquely identifying the platform device to DRM.
Signed-off-by: Thomas White <taw@bitwiz.org.uk>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r-- | drivers/gpu/drm/drm_ioctl.c | 140 |
1 files changed, 96 insertions, 44 deletions
diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 1fad76289e6..cebde45b638 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -83,8 +83,7 @@ int drm_setunique(struct drm_device *dev, void *data, { struct drm_unique *u = data; struct drm_master *master = file_priv->master; - int domain, bus, slot, func, ret; - + if (master->unique_len || master->unique) return -EBUSY; @@ -101,29 +100,50 @@ int drm_setunique(struct drm_device *dev, void *data, master->unique[master->unique_len] = '\0'; - dev->devname = - drm_alloc(strlen(dev->driver->pci_driver.name) + - strlen(master->unique) + 2, DRM_MEM_DRIVER); - if (!dev->devname) - return -ENOMEM; - - sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name, - master->unique); - - /* Return error if the busid submitted doesn't match the device's actual - * busid. - */ - ret = sscanf(master->unique, "PCI:%d:%d:%d", &bus, &slot, &func); - if (ret != 3) - return -EINVAL; - domain = bus >> 8; - bus &= 0xff; - - if ((domain != drm_get_pci_domain(dev)) || - (bus != dev->pdev->bus->number) || - (slot != PCI_SLOT(dev->pdev->devfn)) || - (func != PCI_FUNC(dev->pdev->devfn))) - return -EINVAL; + if ( !drm_core_is_platform(dev) ) { + + /* PCI device */ + + int domain, bus, slot, func, ret; + + dev->devname = + drm_alloc(strlen(dev->driver->pci_driver.name) + + strlen(master->unique) + 2, DRM_MEM_DRIVER); + if (!dev->devname) + return -ENOMEM; + + sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name, + master->unique); + + /* Return error if the busid submitted doesn't match the + * device's actual busid. + */ + ret = sscanf(master->unique, "PCI:%d:%d:%d", + &bus, &slot, &func); + if (ret != 3) + return -EINVAL; + domain = bus >> 8; + bus &= 0xff; + + if ((domain != drm_get_pci_domain(dev)) || + (bus != dev->pdev->bus->number) || + (slot != PCI_SLOT(dev->pdev->devfn)) || + (func != PCI_FUNC(dev->pdev->devfn))) + return -EINVAL; + + } else { + + /* Platform device */ + dev->devname = + drm_alloc(strlen(dev->driver->name) + + strlen(master->unique) + 2, DRM_MEM_DRIVER); + if (!dev->devname) + return -ENOMEM; + + sprintf(dev->devname, "%s@%s", dev->driver->name, + master->unique); + + } return 0; } @@ -131,8 +151,7 @@ int drm_setunique(struct drm_device *dev, void *data, static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv) { struct drm_master *master = file_priv->master; - int len; - + if (master->unique != NULL) return -EBUSY; @@ -142,25 +161,58 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv) if (master->unique == NULL) return -ENOMEM; - len = snprintf(master->unique, master->unique_len, "pci:%04x:%02x:%02x.%d", - drm_get_pci_domain(dev), - dev->pdev->bus->number, - PCI_SLOT(dev->pdev->devfn), - PCI_FUNC(dev->pdev->devfn)); - if (len >= master->unique_len) - DRM_ERROR("buffer overflow"); - else - master->unique_len = len; - - dev->devname = - drm_alloc(strlen(dev->driver->pci_driver.name) + master->unique_len + - 2, DRM_MEM_DRIVER); - if (dev->devname == NULL) - return -ENOMEM; + if ( !drm_core_is_platform(dev) ) { + + /* PCI device */ + + int len; + + len = snprintf(master->unique, master->unique_len, + "pci:%04x:%02x:%02x.%d", + drm_get_pci_domain(dev), + dev->pdev->bus->number, + PCI_SLOT(dev->pdev->devfn), + PCI_FUNC(dev->pdev->devfn)); + + if (len >= master->unique_len) + DRM_ERROR("buffer overflow"); + else + master->unique_len = len; + + dev->devname = + drm_alloc(strlen(dev->driver->pci_driver.name) + + master->unique_len + 2, DRM_MEM_DRIVER); + if (dev->devname == NULL) + return -ENOMEM; + + sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name, + master->unique); + + } else { + + /* Platform device */ + + int len; + + len = snprintf(master->unique, master->unique_len, + "platform:%s", dev->platform_dev->name); + + if (len >= master->unique_len) + DRM_ERROR("buffer overflow"); + else + master->unique_len = len; - sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name, - master->unique); + dev->devname = + drm_alloc(strlen(dev->driver->name) + + master->unique_len + 2, DRM_MEM_DRIVER); + if (dev->devname == NULL) + return -ENOMEM; + sprintf(dev->devname, "%s@%s", dev->driver->name, + master->unique); + + } + return 0; } |