From patchwork Thu Aug 7 13:09:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 4691161 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BA0329F373 for ; Thu, 7 Aug 2014 13:09:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 97E13201E4 for ; Thu, 7 Aug 2014 13:09:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 89134201DE for ; Thu, 7 Aug 2014 13:09:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 193FA89FCE; Thu, 7 Aug 2014 06:09:31 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-yh0-f42.google.com (mail-yh0-f42.google.com [209.85.213.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 4FF3289FAC for ; Thu, 7 Aug 2014 06:09:29 -0700 (PDT) Received: by mail-yh0-f42.google.com with SMTP id a41so2930561yho.29 for ; Thu, 07 Aug 2014 06:09:28 -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; bh=FCfPaWZ+lWYbniK8ijUBJ5Or+K59+LRS1wZM3+ItidM=; b=cG4BLBj2+dR3ziXFFOOOahzcZNL876wPHC3FrJPnRb0y30sIdr6kEput6dS7Ml3inv 5AU//uLLRIX08Lj1s67v9xSXj/uTI5IQqpnvpxM/3wrVkbGvYrYoQN1RkjC9T0oKkeW+ JkWHSgHeuBuFAu+W8EhPyZ3UHyPEALMjuoGHgw1eQkl6Op37r1tysMbeagmfERQUgnvg K5cSnpcZMXNGt9PQLGb5ceI7yj0/OisWXEcBV+6j0KeLMJX9SvWmXxlesRS9pCOKjyAj enW8qn6W3pfULPenwy7GvP67+Eb3y99Ei/uS4hF3kd5eoNM9B5wB4tkFipzzmWS3Jmt0 SrlQ== X-Received: by 10.236.84.134 with SMTP id s6mr4882805yhe.38.1407416968718; Thu, 07 Aug 2014 06:09:28 -0700 (PDT) Received: from localhost.localdomain ([177.156.106.184]) by mx.google.com with ESMTPSA id u23sm7515674yhg.28.2014.08.07.06.09.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Aug 2014 06:09:28 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Thu, 7 Aug 2014 10:09:04 -0300 Message-Id: <1407416947-2282-3-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1407416947-2282-1-git-send-email-przanoni@gmail.com> References: <1407416947-2282-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 3/6] igt_kms: optionally return the property from get_property X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.8 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: Paulo Zanoni So we can use this function on places that also need the property pointer, without having to call drmModeGetProperty() again with the returned id. Signed-off-by: Paulo Zanoni --- lib/igt_kms.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 5dd67fe..664b9e8 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -595,42 +595,46 @@ static void igt_output_refresh(igt_output_t *output) static bool get_property(int drm_fd, uint32_t object_id, uint32_t object_type, const char *name, uint32_t *prop_id /* out */, - uint64_t *value /* out */) + uint64_t *value /* out */, drmModePropertyPtr *prop /* out */) { drmModeObjectPropertiesPtr proplist; - drmModePropertyPtr prop = NULL; + drmModePropertyPtr _prop; bool found = false; int i; proplist = drmModeObjectGetProperties(drm_fd, object_id, object_type); for (i = 0; i < proplist->count_props; i++) { - drmModeFreeProperty(prop); - prop = drmModeGetProperty(drm_fd, proplist->props[i]); - if (!prop) + _prop = drmModeGetProperty(drm_fd, proplist->props[i]); + if (!_prop) continue; - if (strcmp(prop->name, name) == 0) { + if (strcmp(_prop->name, name) == 0) { found = true; if (prop_id) *prop_id = proplist->props[i]; if (value) *value = proplist->prop_values[i]; - goto out; + if (prop) + *prop = _prop; + else + drmModeFreeProperty(_prop); + + break; } + drmModeFreeProperty(_prop); } -out: - drmModeFreeProperty(prop); drmModeFreeObjectProperties(proplist); return found; } static bool get_plane_property(int drm_fd, uint32_t plane_id, const char *name, - uint32_t *prop_id /* out */, uint64_t *value /* out */) + uint32_t *prop_id /* out */, uint64_t *value /* out */, + drmModePropertyPtr *prop /* out */) { return get_property(drm_fd, plane_id, DRM_MODE_OBJECT_PLANE, - name, prop_id, value); + name, prop_id, value, prop); } static void @@ -654,7 +658,7 @@ static int get_drm_plane_type(int drm_fd, uint32_t plane_id) bool has_prop; has_prop = get_plane_property(drm_fd, plane_id, "type", - NULL /* prop_id */, &value); + NULL /* prop_id */, &value, NULL); if (has_prop) return (int)value; @@ -743,7 +747,8 @@ void igt_display_init(igt_display_t *display, int drm_fd) get_plane_property(display->drm_fd, drm_plane->plane_id, "rotation", &plane->rotation_property, - &prop_value); + &prop_value, + NULL); plane->rotation = (igt_rotation_t)prop_value; }