From patchwork Tue Mar 6 16:20:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 7116 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id CF1C723E74 for ; Tue, 6 Mar 2012 16:20:42 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 958CAA1835B for ; Tue, 6 Mar 2012 16:20:42 +0000 (UTC) Received: by yhpp61 with SMTP id p61so2688647yhp.11 for ; Tue, 06 Mar 2012 08:20:42 -0800 (PST) Received: by 10.50.158.133 with SMTP id wu5mr9171952igb.50.1331050841680; Tue, 06 Mar 2012 08:20:41 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.53.18 with SMTP id k18csp61729ibg; Tue, 6 Mar 2012 08:20:40 -0800 (PST) Received: by 10.236.170.193 with SMTP id p41mr27387229yhl.15.1331050840495; Tue, 06 Mar 2012 08:20:40 -0800 (PST) Received: from mail-yx0-f178.google.com (mail-yx0-f178.google.com [209.85.213.178]) by mx.google.com with ESMTPS id d68si20961718yhe.98.2012.03.06.08.20.39 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 06 Mar 2012 08:20:40 -0800 (PST) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 209.85.213.178 as permitted sender) client-ip=209.85.213.178; Authentication-Results: mx.google.com; spf=pass (google.com: domain of robdclark@gmail.com designates 209.85.213.178 as permitted sender) smtp.mail=robdclark@gmail.com; dkim=pass header.i=@gmail.com Received: by yenm14 with SMTP id m14so2713682yen.37 for ; Tue, 06 Mar 2012 08:20:39 -0800 (PST) Received-SPF: pass (google.com: domain of robdclark@gmail.com designates 10.236.145.230 as permitted sender) client-ip=10.236.145.230; Received: from mr.google.com ([10.236.145.230]) by 10.236.145.230 with SMTP id p66mr34353853yhj.27.1331050839673 (num_hops = 1); Tue, 06 Mar 2012 08:20:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=gQj0Cmci0ulatoL1/Jsyndsr4yRMIA779bjDdsE3QlA=; b=GaXtiiosNflXjHpCWL2T7q41YeJOHACuTPtoNLFM8yoZTaY1IL+BshXRY4D1pBlChk fc8/gUeRl0ajnnrJpkrCwgK9VpfEoNyKaZbn0JPdY9wGYdSJVhPnAhghxo/kGwR+O3As 20DvbGkSVQXEdti/encAwodKFGnMM7ZSzG8m7Xh+WfOAs23R7t7xQTxHyY6dfxkXnMyB J3THmoasWoAtkbK2OXwS+u2No1hK+GHRl8jT3sW4jQBXUfl7jHrPED9rBvVrcEJQ4Oxy nl0VpIXiXtdNfpW8V5hMHD2Gcu9LtigCjuBt8qzFVTdR47f8oU3+vfBsh4MtSdcllFHq fCjw== Received: by 10.236.145.230 with SMTP id p66mr27238035yhj.27.1331050839412; Tue, 06 Mar 2012 08:20:39 -0800 (PST) Received: from localhost (dragon.ti.com. [192.94.94.33]) by mx.google.com with ESMTPS id o31sm39628436yhe.12.2012.03.06.08.20.38 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 06 Mar 2012 08:20:38 -0800 (PST) Sender: Rob Clark From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: patches@linaro.org, Rob Clark Subject: [PATCH] drm: cope with platformdev->id == -1 Date: Tue, 6 Mar 2012 10:20:36 -0600 Message-Id: <1331050836-8992-1-git-send-email-rob.clark@linaro.org> X-Mailer: git-send-email 1.7.5.4 X-Gm-Message-State: ALoCoQlZWFMDEzvtfENamJQCDG3UC1s7f1BsWZPnYc8OBgedN8x/r9P/k+ee6GrbPACxwSnN6fuG From: Rob Clark 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 --- 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 ae9db5e..82431dc 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");