diff options
author | Rob Clark <rob@ti.com> | 2012-03-06 10:20:36 -0600 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2012-03-07 14:03:40 +0000 |
commit | b19c19afa880105179b3c25e57b169c8fcda334c (patch) | |
tree | 7865567a22ff38c4cce39ade316f46b872e99291 /drivers/gpu/drm/drm_platform.c | |
parent | 966e0cdd504657333415f43de6a219197511ebff (diff) |
drm: cope with platformdev->id == -1
If there are not multiple instances of a platform device, the id
should apparently be set to -1. Which results in a odd looking
bus-id like "platform:foodrm:-1". Probably we should just treat
this case as id 0.
Signed-off-by: Rob Clark <rob@ti.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/drm_platform.c')
-rw-r--r-- | drivers/gpu/drm/drm_platform.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_platform.c b/drivers/gpu/drm/drm_platform.c index ae9db5e2b27..82431dcae37 100644 --- a/drivers/gpu/drm/drm_platform.c +++ b/drivers/gpu/drm/drm_platform.c @@ -122,7 +122,7 @@ static const char *drm_platform_get_name(struct drm_device *dev) static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *master) { - int len, ret; + int len, ret, id; master->unique_len = 13 + strlen(dev->platformdev->name); master->unique_size = master->unique_len; @@ -131,8 +131,16 @@ static int drm_platform_set_busid(struct drm_device *dev, struct drm_master *mas if (master->unique == NULL) return -ENOMEM; + id = dev->platformdev->id; + + /* if only a single instance of the platform device, id will be + * set to -1.. use 0 instead to avoid a funny looking bus-id: + */ + if (id == -1) + id = 0; + len = snprintf(master->unique, master->unique_len, - "platform:%s:%02d", dev->platformdev->name, dev->platformdev->id); + "platform:%s:%02d", dev->platformdev->name, id); if (len > master->unique_len) { DRM_ERROR("Unique buffer overflowed\n"); |