From patchwork Sun Oct 6 00:45:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 2992131 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2EDB9BF924 for ; Sun, 6 Oct 2013 00:54:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 578C320254 for ; Sun, 6 Oct 2013 00:54:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4DC022024A for ; Sun, 6 Oct 2013 00:54:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 39231E643C for ; Sat, 5 Oct 2013 17:54:07 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qe0-f53.google.com (mail-qe0-f53.google.com [209.85.128.53]) by gabe.freedesktop.org (Postfix) with ESMTP id AA0B1E5C64 for ; Sat, 5 Oct 2013 17:46:20 -0700 (PDT) Received: by mail-qe0-f53.google.com with SMTP id cy11so418941qeb.12 for ; Sat, 05 Oct 2013 17:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=k0p8veWKkbbbsKechwAw/T/5fieNy4b/plwSpcL9QzU=; b=MkEPXk62P3KECGR654ZNe016jcLhLsRHDp2IwmDD4ksXfmURHGC1REonzsvhQ31UqM RPOUjIOltB0yPJuHFvzHok1UjWZ42eCJ34VsPUKmfGgcD5g7xIAPCEvbHuxSkG4pJxeb YxVZYdRqmI03EFHw8HUXBreTIS/DNbAPvNJd/uIWIhcTsd0Eya3PU7u58KBGgBpU2EPj yM9WG9IfQ+B54WM0t33bSUPfZMZRvn3nzXvZa9IxVWfA5Inh5LelEAjC52klKcmhhGKe v+gkN01PMgjZP4ZQtJZxcQlNslIJ3FKtlGkjl7+hriOsreclnryyL6/1CaUP3jqNjK2v QLJg== X-Received: by 10.229.191.7 with SMTP id dk7mr27307733qcb.4.1381020380148; Sat, 05 Oct 2013 17:46:20 -0700 (PDT) Received: from localhost (pool-108-20-247-120.bstnma.east.verizon.net. [108.20.247.120]) by mx.google.com with ESMTPSA id n7sm45660555qai.1.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 05 Oct 2013 17:46:19 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Subject: [RFCv1 07/12] drm: Allow drm_mode_object_find() to look up an object of any type Date: Sat, 5 Oct 2013 20:45:45 -0400 Message-Id: <1381020350-1125-8-git-send-email-robdclark@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1381020350-1125-1-git-send-email-robdclark@gmail.com> References: <1381020350-1125-1-git-send-email-robdclark@gmail.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ville Syrjälä To avoid having to pass object types from userspace for atomic mode setting ioctl, allow drm_mode_object_find() to look up an object of any type. This will only work as long as the all object types share the ID space. Signed-off-by: Ville Syrjälä --- drivers/gpu/drm/drm_crtc.c | 3 ++- include/drm/drm_crtc.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 0b6e196..c0546e8 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -360,7 +360,8 @@ struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, mutex_lock(&dev->mode_config.idr_mutex); obj = idr_find(&dev->mode_config.crtc_idr, id); - if (!obj || (obj->type != type) || (obj->id != id)) + if (!obj || (type != DRM_MODE_OBJECT_ANY && obj->type != type) || + (obj->id != id)) obj = NULL; mutex_unlock(&dev->mode_config.idr_mutex); diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 372b159..8831562 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -51,6 +51,7 @@ struct drm_object_property_values; #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee #define DRM_MODE_OBJECT_BRIDGE 0xbdbdbdbd +#define DRM_MODE_OBJECT_ANY 0 struct drm_mode_object { uint32_t id;