Re: [PATCH 02/11] drm/msm/dpu: Use DEFINE_SHOW_ATTRIBUTE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 05, 2018 at 04:30:54PM -0700, Jordan Crouse wrote:
> Use the standard DEFINE_SHOW_ATTRIBUTE macro for seq_file based
> debugfs files instead of custom macros and hand-coded functions.
> 
> v2: Added a cleanup for dpu_encoder.c too
> 
> Signed-off-by: Jordan Crouse <jcrouse@xxxxxxxxxxxxxx>

Reviewed-by: Sean Paul <sean@xxxxxxxxxx>

> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c | 14 +-------
>  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c     | 31 +++---------------
>  drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c  | 20 +++---------
>  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c      | 34 +++-----------------
>  4 files changed, 14 insertions(+), 85 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c
> index 879c13fe74e0..7607aac9449c 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_core_irq.c
> @@ -299,18 +299,6 @@ static void dpu_disable_all_irqs(struct dpu_kms *dpu_kms)
>  }
>  
>  #ifdef CONFIG_DEBUG_FS
> -#define DEFINE_DPU_DEBUGFS_SEQ_FOPS(__prefix)				\
> -static int __prefix ## _open(struct inode *inode, struct file *file)	\
> -{									\
> -	return single_open(file, __prefix ## _show, inode->i_private);	\
> -}									\
> -static const struct file_operations __prefix ## _fops = {		\
> -	.owner = THIS_MODULE,						\
> -	.open = __prefix ## _open,					\
> -	.release = single_release,					\
> -	.read = seq_read,						\
> -	.llseek = seq_lseek,						\
> -}
>  
>  static int dpu_debugfs_core_irq_show(struct seq_file *s, void *v)
>  {
> @@ -341,7 +329,7 @@ static int dpu_debugfs_core_irq_show(struct seq_file *s, void *v)
>  	return 0;
>  }
>  
> -DEFINE_DPU_DEBUGFS_SEQ_FOPS(dpu_debugfs_core_irq);
> +DEFINE_SHOW_ATTRIBUTE(dpu_debugfs_core_irq);
>  
>  int dpu_debugfs_core_irq_init(struct dpu_kms *dpu_kms,
>  		struct dentry *parent)
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index ed84cf44a222..11052bee03cf 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -1232,7 +1232,7 @@ int dpu_crtc_vblank(struct drm_crtc *crtc, bool en)
>  }
>  
>  #ifdef CONFIG_DEBUG_FS
> -static int _dpu_debugfs_status_show(struct seq_file *s, void *data)
> +static int dpu_crtc_debugfs_status_show(struct seq_file *s, void *data)
>  {
>  	struct dpu_crtc *dpu_crtc;
>  	struct dpu_plane_state *pstate = NULL;
> @@ -1351,23 +1351,7 @@ static int _dpu_debugfs_status_show(struct seq_file *s, void *data)
>  	return 0;
>  }
>  
> -static int _dpu_debugfs_status_open(struct inode *inode, struct file *file)
> -{
> -	return single_open(file, _dpu_debugfs_status_show, inode->i_private);
> -}
> -
> -#define DEFINE_DPU_DEBUGFS_SEQ_FOPS(__prefix)                          \
> -static int __prefix ## _open(struct inode *inode, struct file *file)	\
> -{									\
> -	return single_open(file, __prefix ## _show, inode->i_private);	\
> -}									\
> -static const struct file_operations __prefix ## _fops = {		\
> -	.owner = THIS_MODULE,						\
> -	.open = __prefix ## _open,					\
> -	.release = single_release,					\
> -	.read = seq_read,						\
> -	.llseek = seq_lseek,						\
> -}
> +DEFINE_SHOW_ATTRIBUTE(dpu_crtc_debugfs_status);
>  
>  static int dpu_crtc_debugfs_state_show(struct seq_file *s, void *v)
>  {
> @@ -1391,20 +1375,13 @@ static int dpu_crtc_debugfs_state_show(struct seq_file *s, void *v)
>  
>  	return 0;
>  }
> -DEFINE_DPU_DEBUGFS_SEQ_FOPS(dpu_crtc_debugfs_state);
> +DEFINE_SHOW_ATTRIBUTE(dpu_crtc_debugfs_state);
>  
>  static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc)
>  {
>  	struct dpu_crtc *dpu_crtc;
>  	struct dpu_kms *dpu_kms;
>  
> -	static const struct file_operations debugfs_status_fops = {
> -		.open =		_dpu_debugfs_status_open,
> -		.read =		seq_read,
> -		.llseek =	seq_lseek,
> -		.release =	single_release,
> -	};
> -
>  	if (!crtc)
>  		return -EINVAL;
>  	dpu_crtc = to_dpu_crtc(crtc);
> @@ -1419,7 +1396,7 @@ static int _dpu_crtc_init_debugfs(struct drm_crtc *crtc)
>  	/* don't error check these */
>  	debugfs_create_file("status", 0400,
>  			dpu_crtc->debugfs_root,
> -			dpu_crtc, &debugfs_status_fops);
> +			dpu_crtc, &dpu_crtc_debugfs_status_fops);
>  	debugfs_create_file("state", 0600,
>  			dpu_crtc->debugfs_root,
>  			&dpu_crtc->base,
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> index d5e252941ba8..5559e5d40142 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> @@ -1836,7 +1836,7 @@ void dpu_encoder_prepare_commit(struct drm_encoder *drm_enc)
>  }
>  
>  #ifdef CONFIG_DEBUG_FS
> -static int _dpu_encoder_status_show(struct seq_file *s, void *data)
> +static int dpu_encoder_status_show(struct seq_file *s, void *data)
>  {
>  	struct dpu_encoder_virt *dpu_enc;
>  	int i;
> @@ -1875,11 +1875,7 @@ static int _dpu_encoder_status_show(struct seq_file *s, void *data)
>  	return 0;
>  }
>  
> -static int _dpu_encoder_debugfs_status_open(struct inode *inode,
> -		struct file *file)
> -{
> -	return single_open(file, _dpu_encoder_status_show, inode->i_private);
> -}
> +DEFINE_SHOW_ATTRIBUTE(dpu_encoder_status);
>  
>  static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc)
>  {
> @@ -1887,14 +1883,6 @@ static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc)
>  	struct msm_drm_private *priv;
>  	struct dpu_kms *dpu_kms;
>  	int i;
> -
> -	static const struct file_operations debugfs_status_fops = {
> -		.open =		_dpu_encoder_debugfs_status_open,
> -		.read =		seq_read,
> -		.llseek =	seq_lseek,
> -		.release =	single_release,
> -	};
> -
>  	char name[DPU_NAME_SIZE];
>  
>  	if (!drm_enc || !drm_enc->dev || !drm_enc->dev->dev_private) {
> @@ -1915,8 +1903,8 @@ static int _dpu_encoder_init_debugfs(struct drm_encoder *drm_enc)
>  		return -ENOMEM;
>  
>  	/* don't error check these */
> -	debugfs_create_file("status", 0600,
> -		dpu_enc->debugfs_root, dpu_enc, &debugfs_status_fops);
> +	debugfs_create_file("status", 0600, dpu_enc->debugfs_root, dpu_enc,
> +		&dpu_encoder_status_fops);
>  
>  	for (i = 0; i < dpu_enc->num_phys_encs; i++)
>  		if (dpu_enc->phys_encs[i] &&
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> index fd5bad16338d..7e3ba128cbaf 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
> @@ -113,30 +113,17 @@ static int _dpu_danger_signal_status(struct seq_file *s,
>  	return 0;
>  }
>  
> -#define DEFINE_DPU_DEBUGFS_SEQ_FOPS(__prefix)				\
> -static int __prefix ## _open(struct inode *inode, struct file *file)	\
> -{									\
> -	return single_open(file, __prefix ## _show, inode->i_private);	\
> -}									\
> -static const struct file_operations __prefix ## _fops = {		\
> -	.owner = THIS_MODULE,						\
> -	.open = __prefix ## _open,					\
> -	.release = single_release,					\
> -	.read = seq_read,						\
> -	.llseek = seq_lseek,						\
> -}
> -
>  static int dpu_debugfs_danger_stats_show(struct seq_file *s, void *v)
>  {
>  	return _dpu_danger_signal_status(s, true);
>  }
> -DEFINE_DPU_DEBUGFS_SEQ_FOPS(dpu_debugfs_danger_stats);
> +DEFINE_SHOW_ATTRIBUTE(dpu_debugfs_danger_stats);
>  
>  static int dpu_debugfs_safe_stats_show(struct seq_file *s, void *v)
>  {
>  	return _dpu_danger_signal_status(s, false);
>  }
> -DEFINE_DPU_DEBUGFS_SEQ_FOPS(dpu_debugfs_safe_stats);
> +DEFINE_SHOW_ATTRIBUTE(dpu_debugfs_safe_stats);
>  
>  static void dpu_debugfs_danger_destroy(struct dpu_kms *dpu_kms)
>  {
> @@ -162,7 +149,7 @@ static int dpu_debugfs_danger_init(struct dpu_kms *dpu_kms,
>  	return 0;
>  }
>  
> -static int _dpu_debugfs_show_regset32(struct seq_file *s, void *data)
> +static int dpu_debugfs_regset32_show(struct seq_file *s, void *data)
>  {
>  	struct dpu_debugfs_regset32 *regset;
>  	struct dpu_kms *dpu_kms;
> @@ -212,18 +199,7 @@ static int _dpu_debugfs_show_regset32(struct seq_file *s, void *data)
>  	return 0;
>  }
>  
> -static int dpu_debugfs_open_regset32(struct inode *inode,
> -		struct file *file)
> -{
> -	return single_open(file, _dpu_debugfs_show_regset32, inode->i_private);
> -}
> -
> -static const struct file_operations dpu_fops_regset32 = {
> -	.open =		dpu_debugfs_open_regset32,
> -	.read =		seq_read,
> -	.llseek =	seq_lseek,
> -	.release =	single_release,
> -};
> +DEFINE_SHOW_ATTRIBUTE(dpu_debugfs_regset32);
>  
>  void dpu_debugfs_setup_regset32(struct dpu_debugfs_regset32 *regset,
>  		uint32_t offset, uint32_t length, struct dpu_kms *dpu_kms)
> @@ -245,7 +221,7 @@ void *dpu_debugfs_create_regset32(const char *name, umode_t mode,
>  	regset->offset = round_down(regset->offset, 4);
>  
>  	return debugfs_create_file(name, mode, parent,
> -			regset, &dpu_fops_regset32);
> +			regset, &dpu_debugfs_regset32_fops);
>  }
>  
>  static int _dpu_debugfs_init(struct dpu_kms *dpu_kms)
> -- 
> 2.18.0
> 

-- 
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux