drm/sysfs: add a helper for extracting connector type from kobject
authorJani Nikula <jani.nikula@intel.com>
Tue, 12 May 2015 09:14:52 +0000 (12:14 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 12 May 2015 17:15:52 +0000 (19:15 +0200)
This reduces duplication in the patches to follow. No functional
changes.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/drm_sysfs.c

index ffc305fc20768c29af6883eeb2d70553839cfa6e..33466999b59a58b85389f22e0e5844797c025e6c 100644 (file)
@@ -407,17 +407,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: