[PATCH 14/14] staging: clocking-wizard: Add debugfs entries to facilitate testing.

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

 



Adds test_round_rate and test_set_rate entries to debugfs so that the
driver can be tested by a user space test application.

It would appear that patches that allow access to clk_set_rate from user
space are controversial so there is no expectation that this patch can
be merged.

Signed-off-by: James Kelly <jamespeterkelly@xxxxxxxxx>
---
 .../clocking-wizard/clk-xlnx-clock-wizard.c        | 53 ++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
index bb64da849d9b..c37f0e4451b4 100644
--- a/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
+++ b/drivers/staging/clocking-wizard/clk-xlnx-clock-wizard.c
@@ -308,6 +308,12 @@ static const struct reg_field clk_wzrd_clkout_divide[WZRD_MAX_OUTPUTS] = {
 static const struct reg_field clk_wzrd_clkout0_frac = REG_FIELD(0x208, 8, 17);
 static const struct reg_field clk_wzrd_reconfig     = REG_FIELD(0x25C, 0,  1);
 
+#ifdef CONFIG_DEBUG_FS
+struct clk_wzrd_debug {
+	unsigned long round_rate;
+};
+#endif
+
 /**
  * struct clk_wzrd_clk_data - Clocking Wizard component clock provider data
  *
@@ -319,6 +325,7 @@ static const struct reg_field clk_wzrd_reconfig     = REG_FIELD(0x25C, 0,  1);
  * @max_parent:		maximum parent clk rate
  * @int_field:		pointer to regmap field for integer part
  * @frac_field:		pointer to regmap field for fractional part
+ * @debug:		debug information
  *
  * Flags:
  * WZRD_FLAG_MULTIPLY	Clock is a multiplier rather than a divider
@@ -334,6 +341,9 @@ struct clk_wzrd_clk_data {
 	unsigned long			max_parent;
 	struct regmap_field		*int_field;
 	struct regmap_field		*frac_field;
+#ifdef CONFIG_DEBUG_FS
+	struct clk_wzrd_debug		debug;
+#endif
 };
 
 #define to_clk_wzrd_clk_data(_hw) \
@@ -794,6 +804,39 @@ static int clk_wzrd_ratio_show(struct seq_file *s, void *data)
 }
 DEFINE_SHOW_ATTRIBUTE(clk_wzrd_ratio);
 
+static int clk_wzrd_test_get_round_rate(void *data, u64 *val)
+{
+	struct clk_wzrd_clk_data *cwc = data;
+
+	*val = cwc->debug.round_rate;
+	return 0;
+}
+
+static int clk_wzrd_test_set_round_rate(void *data, u64 val)
+{
+	long round_rate;
+	struct clk_wzrd_clk_data *cwc = data;
+
+	round_rate = clk_round_rate(cwc->hw.clk, (unsigned long)val);
+
+	if (round_rate < 0)
+		return round_rate;
+
+	cwc->debug.round_rate = round_rate;
+	return 0;
+}
+DEFINE_DEBUGFS_ATTRIBUTE(fops_test_round_rate, clk_wzrd_test_get_round_rate,
+			 clk_wzrd_test_set_round_rate, "%llu\n");
+
+static int clk_wzrd_test_set_set_rate(void *data, u64 val)
+{
+	struct clk_wzrd_clk_data *cwc = data;
+
+	return clk_set_rate(cwc->hw.clk, (unsigned long)val);
+}
+DEFINE_DEBUGFS_ATTRIBUTE(fops_test_set_rate, NULL,
+			 clk_wzrd_test_set_set_rate, "%llu\n");
+
 static int clk_wzrd_debug_init(struct clk_hw *hw, struct dentry *dentry)
 {
 	struct dentry *d;
@@ -841,6 +884,16 @@ static int clk_wzrd_debug_init(struct clk_hw *hw, struct dentry *dentry)
 	if (IS_ERR(d))
 		return PTR_ERR(d);
 
+	d = debugfs_create_file_unsafe("test_round_rate", 0644, dentry, cwc,
+				       &fops_test_round_rate);
+	if (IS_ERR(d))
+		return PTR_ERR(d);
+
+	d = debugfs_create_file_unsafe("test_set_rate", 0200, dentry, cwc,
+				       &fops_test_set_rate);
+	if (IS_ERR(d))
+		return PTR_ERR(d);
+
 	return 0;
 }
 #endif
-- 
2.15.1 (Apple Git-101)

_______________________________________________
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