Re: [PATCH 09/14] staging: clocking-wizard: Provide more information in debugfs

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

 



On 7.5.2018 03:20, James Kelly wrote:
> Publish clock divider/multiplier ratios and flags specific to our
> clock provider implementation as these are not available via the
> debugfs entries provided by the common clock framework.
> 
> Signed-off-by: James Kelly <jamespeterkelly@xxxxxxxxx>
> ---
>  .../clocking-wizard/clk-xlnx-clock-wizard.c        | 57 ++++++++++++++++++++++
>  1 file changed, 57 insertions(+)
> 
> diff --git a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
> index c892c0d46801..8929913045e7 100644
> --- a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
> +++ b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
> @@ -69,6 +69,8 @@
>  #include <linux/module.h>
>  #include <linux/err.h>
>  #include <linux/regmap.h>
> +#include <linux/debugfs.h>
> +#include <linux/seq_file.h>
>  
>  #define WZRD_MAX_OUTPUTS	7
>  #define KHz			1000UL
> @@ -423,8 +425,63 @@ static unsigned long clk_wzrd_recalc_rate(struct clk_hw *hw,
>  	return clk_wzrd_calc_rate(parent_rate, ratio, cwc->flags);
>  }
>  
> +#ifdef CONFIG_DEBUG_FS
> +
> +static int clk_wzrd_flags_show(struct seq_file *s, void *data)
> +{
> +	struct clk_wzrd_clk_data *cwc = s->private;
> +
> +	seq_puts(s, "Flags:\n");
> +	if (cwc->flags & WZRD_FLAG_MULTIPLY)
> +		seq_puts(s, "WZRD_FLAG_MULTIPLY\n");
> +	if (cwc->flags & WZRD_FLAG_FRAC)
> +		seq_puts(s, "WZRD_FLAG_FRAC\n");
> +
> +	return 0;
> +}
> +DEFINE_SHOW_ATTRIBUTE(clk_wzrd_flags);
> +
> +static int clk_wzrd_ratio_show(struct seq_file *s, void *data)
> +{
> +	struct clk_wzrd_clk_data *cwc = s->private;
> +	unsigned int int_part, frac_part = 0;
> +
> +	regmap_field_read(cwc->int_field, &int_part);
> +	if (cwc->flags & WZRD_FLAG_FRAC) {
> +		regmap_field_read(cwc->frac_field, &frac_part);
> +		seq_printf(s, "%u.%u\n", int_part, frac_part);
> +	} else {
> +		seq_printf(s, "%u\n", int_part);
> +	}
> +
> +	return 0;
> +}
> +DEFINE_SHOW_ATTRIBUTE(clk_wzrd_ratio);
> +
> +static int clk_wzrd_debug_init(struct clk_hw *hw, struct dentry *dentry)
> +{
> +	struct dentry *d;
> +	struct clk_wzrd_clk_data *cwc = to_clk_wzrd_clk_data(hw);
> +
> +	d = debugfs_create_file_unsafe("clk_hw_flags", 0444, dentry, cwc,
> +				       &clk_wzrd_flags_fops);
> +	if (IS_ERR(d))
> +		return PTR_ERR(d);
> +
> +	d = debugfs_create_file_unsafe("clk_ratio", 0444, dentry, cwc,
> +				       &clk_wzrd_ratio_fops);
> +	if (IS_ERR(d))
> +		return PTR_ERR(d);

Would be good to keep coccinelle happy.

drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c:735:1-3:
WARNING: PTR_ERR_OR_ZERO can be used

Thanks,
Michal
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux