[PATCH] drm: Provide drm_set_busid() fallback
Daniel Vetter
daniel at ffwll.ch
Fri Apr 11 10:43:18 PDT 2014
On Fri, Apr 11, 2014 at 03:28:56PM +0200, Thierry Reding wrote:
> From: Thierry Reding <treding at nvidia.com>
>
> The only reason why struct drm_bus is still around is because the
> SETVERSION IOCTL calls a bus specific .set_busid() function. This commit
> provides a fallback implementation if a device either doesn't have a bus
> associated with it or if it doesn't implement .set_busid(). The bus ID
> will be set to the device's name as returned by dev_name().
>
> This can be useful to create DRM devices directly in drivers using the
> drm_dev_alloc() and drm_dev_register() functions rather than going
> through the bus-specific implementations, with the goal of eventually
> getting rid of drm_bus entirely.
>
> Signed-off-by: Thierry Reding <treding at nvidia.com>
> ---
> drivers/gpu/drm/drm_ioctl.c | 26 +++++++++++++++++++++++---
> 1 file changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 93a42040bedb..d27134a94d69 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -122,6 +122,19 @@ err:
> return ret;
> }
>
> +static int __drm_set_busid(struct drm_device *dev, struct drm_master *master)
> +{
> + const char *name = dev_name(dev->dev);
> +
> + master->unique = kstrdup(name, GFP_KERNEL);
> + if (!master->unique)
> + return -ENOMEM;
> +
> + master->unique_len = strlen(name);
> +
> + return 0;
> +}
> +
> static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
> {
> struct drm_master *master = file_priv->master;
> @@ -130,9 +143,16 @@ static int drm_set_busid(struct drm_device *dev, struct drm_file *file_priv)
> if (master->unique != NULL)
> drm_unset_busid(dev, master);
>
> - ret = dev->driver->bus->set_busid(dev, master);
> - if (ret)
> - goto err;
> + if (dev->driver->bus && dev->driver->bus->set_busid) {
> + ret = dev->driver->bus->set_busid(dev, master);
> + if (ret)
> + goto err;
> + } else {
Hm, my plan was actually to just provide a drm_dev_setunique to drivers so
that they can set whatever their userspace wants, and then have no
set_busid implementation here at all for !pci. Some userspace at least
uses the unique thing to match for the driver, so we need to do the usual
bending over backwards to keep it consistent.
The approach with a drm_set_unique helper would also make conversion of
existing platform and usb drivers easier.
-Daniel
> + ret = __drm_set_busid(dev, master);
> + if (ret)
> + goto err;
> + }
> +
> return 0;
> err:
> drm_unset_busid(dev, master);
> --
> 1.9.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
More information about the dri-devel
mailing list