From patchwork Tue Feb 24 13:08:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 5872641 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 335C2BF440 for ; Tue, 24 Feb 2015 13:07:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56BB720251 for ; Tue, 24 Feb 2015 13:07:01 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D00C120256 for ; Tue, 24 Feb 2015 13:06:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D498689DA4; Tue, 24 Feb 2015 05:06:54 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by gabe.freedesktop.org (Postfix) with ESMTP id D4C206E204 for ; Tue, 24 Feb 2015 05:06:53 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 24 Feb 2015 05:06:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,638,1418112000"; d="scan'208";a="682599295" Received: from jnikula-mobl.fi.intel.com (HELO localhost) ([10.237.72.77]) by fmsmga002.fm.intel.com with ESMTP; 24 Feb 2015 05:06:51 -0800 From: Jani Nikula To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/4] drm/sysfs: add a helper for extracting connector type from kobject Date: Tue, 24 Feb 2015 15:08:00 +0200 Message-Id: <929028cf455f1b2b9f6a3baf07b2c3c28332179e.1424782644.git.jani.nikula@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Cc: jani.nikula@intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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 This reduces duplication in the patches to follow. No functional changes. Signed-off-by: Jani Nikula --- drivers/gpu/drm/drm_sysfs.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c index 5c99d3773212..9ce4d62feb46 100644 --- a/drivers/gpu/drm/drm_sysfs.c +++ b/drivers/gpu/drm/drm_sysfs.c @@ -362,17 +362,23 @@ static struct attribute *connector_opt_dev_attrs[] = { NULL }; -static umode_t connector_opt_dev_is_visible(struct kobject *kobj, - struct attribute *attr, int idx) +/* Connector type related helpers */ +static int kobj_connector_type(struct kobject *kobj) { struct device *dev = kobj_to_dev(kobj); struct drm_connector *connector = to_drm_connector(dev); + return connector->connector_type; +} + +static umode_t connector_opt_dev_is_visible(struct kobject *kobj, + struct attribute *attr, int idx) +{ /* * In the long run it maybe a good idea to make one set of * optionals per connector type. */ - switch (connector->connector_type) { + switch (kobj_connector_type(kobj)) { case DRM_MODE_CONNECTOR_DVII: case DRM_MODE_CONNECTOR_Composite: case DRM_MODE_CONNECTOR_SVIDEO: