drm: add drm_get_connector_force_name
authorJani Nikula <jani.nikula@intel.com>
Mon, 20 Feb 2017 08:51:48 +0000 (10:51 +0200)
committerJani Nikula <jani.nikula@intel.com>
Tue, 28 Feb 2017 10:17:08 +0000 (12:17 +0200)
Follow the naming in debugfs also for logging, add "unknown" for values
beyond the enumerated ones.

v2: add \n in connector_show, make internal to drm (Chris)

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1487580708-29340-1-git-send-email-jani.nikula@intel.com
drivers/gpu/drm/drm_connector.c
drivers/gpu/drm/drm_crtc_internal.h
drivers/gpu/drm/drm_debugfs.c

index ab73e86ffdf1b250b150a92c3f7d21d5c0f3fef4..76ea30c223dacce75844c6c5f92c06e819e338a6 100644 (file)
@@ -128,22 +128,8 @@ static void drm_connector_get_cmdline_mode(struct drm_connector *connector)
                return;
 
        if (mode->force) {
-               const char *s;
-
-               switch (mode->force) {
-               case DRM_FORCE_OFF:
-                       s = "OFF";
-                       break;
-               case DRM_FORCE_ON_DIGITAL:
-                       s = "ON - dig";
-                       break;
-               default:
-               case DRM_FORCE_ON:
-                       s = "ON";
-                       break;
-               }
-
-               DRM_INFO("forcing %s connector %s\n", connector->name, s);
+               DRM_INFO("forcing %s connector %s\n", connector->name,
+                        drm_get_connector_force_name(mode->force));
                connector->force = mode->force;
        }
 
@@ -492,6 +478,28 @@ const char *drm_get_connector_status_name(enum drm_connector_status status)
 }
 EXPORT_SYMBOL(drm_get_connector_status_name);
 
+/**
+ * drm_get_connector_force_name - return a string for connector force
+ * @force: connector force to get name of
+ *
+ * Returns: const pointer to name.
+ */
+const char *drm_get_connector_force_name(enum drm_connector_force force)
+{
+       switch (force) {
+       case DRM_FORCE_UNSPECIFIED:
+               return "unspecified";
+       case DRM_FORCE_OFF:
+               return "off";
+       case DRM_FORCE_ON:
+               return "on";
+       case DRM_FORCE_ON_DIGITAL:
+               return "digital";
+       default:
+               return "unknown";
+       }
+}
+
 #ifdef CONFIG_LOCKDEP
 static struct lockdep_map connector_list_iter_dep_map = {
        .name = "drm_connector_list_iter"
index 955c5690bf643117fc00e17108da9708acdc09cb..81bc0a390f41d435f52415321b9dfe579c6e8bb0 100644 (file)
@@ -142,6 +142,7 @@ int drm_mode_connector_set_obj_prop(struct drm_mode_object *obj,
                                    struct drm_property *property,
                                    uint64_t value);
 int drm_connector_create_standard_properties(struct drm_device *dev);
+const char *drm_get_connector_force_name(enum drm_connector_force force);
 
 /* IOCTL */
 int drm_mode_connector_property_set_ioctl(struct drm_device *dev,
index 2290a74a6e466f2a2fda546c53a2077fd6753c48..8b2c61ae000446fccfd6afe7db7e68886cd1fccc 100644 (file)
@@ -261,30 +261,8 @@ int drm_debugfs_cleanup(struct drm_minor *minor)
 static int connector_show(struct seq_file *m, void *data)
 {
        struct drm_connector *connector = m->private;
-       const char *status;
 
-       switch (connector->force) {
-       case DRM_FORCE_ON:
-               status = "on\n";
-               break;
-
-       case DRM_FORCE_ON_DIGITAL:
-               status = "digital\n";
-               break;
-
-       case DRM_FORCE_OFF:
-               status = "off\n";
-               break;
-
-       case DRM_FORCE_UNSPECIFIED:
-               status = "unspecified\n";
-               break;
-
-       default:
-               return 0;
-       }
-
-       seq_puts(m, status);
+       seq_printf(m, "%s\n", drm_get_connector_force_name(connector->force));
 
        return 0;
 }