i915: Re-use DEFINE_SHOW_ATTRIBUTE() macro
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 16 Mar 2018 14:12:13 +0000 (16:12 +0200)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 16 Mar 2018 15:59:49 +0000 (15:59 +0000)
...instead of open coding file operations followed by custom ->open()
callbacks per each attribute.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20180316141213.38774-1-andriy.shevchenko@linux.intel.com
drivers/gpu/drm/i915/gvt/debugfs.c
drivers/gpu/drm/i915/i915_debugfs.c

index 32a66dfdf1127d3a0277fd29579cbdc2418fd7ac..f7d0078eb61b8bfa500b212c743c78e2ce4db7dd 100644 (file)
@@ -122,18 +122,7 @@ static int vgpu_mmio_diff_show(struct seq_file *s, void *unused)
        seq_printf(s, "Total: %d, Diff: %d\n", param.total, param.diff);
        return 0;
 }
-
-static int vgpu_mmio_diff_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, vgpu_mmio_diff_show, inode->i_private);
-}
-
-static const struct file_operations vgpu_mmio_diff_fops = {
-       .open           = vgpu_mmio_diff_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(vgpu_mmio_diff);
 
 /**
  * intel_gvt_debugfs_add_vgpu - register debugfs entries for a vGPU
index 298a3aa9513b85c2b7c248530d48cb1aec58c5de..5378863e32381ec873f7d5ae3354c2c7be84d0cf 100644 (file)
@@ -3562,7 +3562,8 @@ static ssize_t i915_displayport_test_active_write(struct file *file,
 
 static int i915_displayport_test_active_show(struct seq_file *m, void *data)
 {
-       struct drm_device *dev = m->private;
+       struct drm_i915_private *dev_priv = m->private;
+       struct drm_device *dev = &dev_priv->drm;
        struct drm_connector *connector;
        struct drm_connector_list_iter conn_iter;
        struct intel_dp *intel_dp;
@@ -3596,10 +3597,8 @@ static int i915_displayport_test_active_show(struct seq_file *m, void *data)
 static int i915_displayport_test_active_open(struct inode *inode,
                                             struct file *file)
 {
-       struct drm_i915_private *dev_priv = inode->i_private;
-
        return single_open(file, i915_displayport_test_active_show,
-                          &dev_priv->drm);
+                          inode->i_private);
 }
 
 static const struct file_operations i915_displayport_test_active_fops = {
@@ -3613,7 +3612,8 @@ static const struct file_operations i915_displayport_test_active_fops = {
 
 static int i915_displayport_test_data_show(struct seq_file *m, void *data)
 {
-       struct drm_device *dev = m->private;
+       struct drm_i915_private *dev_priv = m->private;
+       struct drm_device *dev = &dev_priv->drm;
        struct drm_connector *connector;
        struct drm_connector_list_iter conn_iter;
        struct intel_dp *intel_dp;
@@ -3652,26 +3652,12 @@ static int i915_displayport_test_data_show(struct seq_file *m, void *data)
 
        return 0;
 }
-static int i915_displayport_test_data_open(struct inode *inode,
-                                          struct file *file)
-{
-       struct drm_i915_private *dev_priv = inode->i_private;
-
-       return single_open(file, i915_displayport_test_data_show,
-                          &dev_priv->drm);
-}
-
-static const struct file_operations i915_displayport_test_data_fops = {
-       .owner = THIS_MODULE,
-       .open = i915_displayport_test_data_open,
-       .read = seq_read,
-       .llseek = seq_lseek,
-       .release = single_release
-};
+DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_data);
 
 static int i915_displayport_test_type_show(struct seq_file *m, void *data)
 {
-       struct drm_device *dev = m->private;
+       struct drm_i915_private *dev_priv = m->private;
+       struct drm_device *dev = &dev_priv->drm;
        struct drm_connector *connector;
        struct drm_connector_list_iter conn_iter;
        struct intel_dp *intel_dp;
@@ -3698,23 +3684,7 @@ static int i915_displayport_test_type_show(struct seq_file *m, void *data)
 
        return 0;
 }
-
-static int i915_displayport_test_type_open(struct inode *inode,
-                                      struct file *file)
-{
-       struct drm_i915_private *dev_priv = inode->i_private;
-
-       return single_open(file, i915_displayport_test_type_show,
-                          &dev_priv->drm);
-}
-
-static const struct file_operations i915_displayport_test_type_fops = {
-       .owner = THIS_MODULE,
-       .open = i915_displayport_test_type_open,
-       .read = seq_read,
-       .llseek = seq_lseek,
-       .release = single_release
-};
+DEFINE_SHOW_ATTRIBUTE(i915_displayport_test_type);
 
 static void wm_latency_show(struct seq_file *m, const uint16_t wm[8])
 {
@@ -4875,19 +4845,7 @@ static int i915_dpcd_show(struct seq_file *m, void *data)
 
        return 0;
 }
-
-static int i915_dpcd_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, i915_dpcd_show, inode->i_private);
-}
-
-static const struct file_operations i915_dpcd_fops = {
-       .owner = THIS_MODULE,
-       .open = i915_dpcd_open,
-       .read = seq_read,
-       .llseek = seq_lseek,
-       .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(i915_dpcd);
 
 static int i915_panel_show(struct seq_file *m, void *data)
 {
@@ -4909,19 +4867,7 @@ static int i915_panel_show(struct seq_file *m, void *data)
 
        return 0;
 }
-
-static int i915_panel_open(struct inode *inode, struct file *file)
-{
-       return single_open(file, i915_panel_show, inode->i_private);
-}
-
-static const struct file_operations i915_panel_fops = {
-       .owner = THIS_MODULE,
-       .open = i915_panel_open,
-       .read = seq_read,
-       .llseek = seq_lseek,
-       .release = single_release,
-};
+DEFINE_SHOW_ATTRIBUTE(i915_panel);
 
 /**
  * i915_debugfs_connector_add - add i915 specific connector debugfs files