linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] clk: si5341: Add sysfs property to check selected input
@ 2021-12-03 14:15 Adam Wujek
  2021-12-06 22:53 ` Stephen Boyd
  0 siblings, 1 reply; 8+ messages in thread
From: Adam Wujek @ 2021-12-03 14:15 UTC (permalink / raw)
  To: Michael Turquette, Stephen Boyd; +Cc: Adam Wujek, linux-clk, linux-kernel

Add a sysfs property to check the selected input.
<input_num> <input_name> <input_name_from_DTB>
E.g.:
cat input_selected
0 in0 WR25M

Signed-off-by: Adam Wujek <dev_public@wujek.eu>
---
 drivers/clk/clk-si5341.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/clk/clk-si5341.c b/drivers/clk/clk-si5341.c
index 57ae183982d8..b7641abe6747 100644
--- a/drivers/clk/clk-si5341.c
+++ b/drivers/clk/clk-si5341.c
@@ -1536,12 +1536,31 @@ static ssize_t clear_sticky_store(struct device *dev,
 }
 static DEVICE_ATTR_WO(clear_sticky);

+static ssize_t input_selected_show(struct device *dev,
+			       struct device_attribute *attr,
+			       char *buf)
+{
+	struct clk_si5341 *data = dev_get_drvdata(dev);
+	int res = si5341_clk_get_selected_input(data);
+	const char *input_name_dtb;
+
+	if (res < 0)
+		return res;
+	input_name_dtb =  __clk_get_name(devm_clk_get(dev,
+						si5341_input_clock_names[res]));
+	/* input id, input name, input name from DTB */
+	return snprintf(buf, PAGE_SIZE, "%d %s %s\n", res,
+			si5341_input_clock_names[res], input_name_dtb);
+}
+static DEVICE_ATTR_RO(input_selected);
+
 static const struct attribute *si5341_attributes[] = {
 	&dev_attr_input_present.attr,
 	&dev_attr_input_present_sticky.attr,
 	&dev_attr_pll_locked.attr,
 	&dev_attr_pll_locked_sticky.attr,
 	&dev_attr_clear_sticky.attr,
+	&dev_attr_input_selected.attr,
 	NULL
 };

--
2.17.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-12-17  1:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03 14:15 [PATCH] clk: si5341: Add sysfs property to check selected input Adam Wujek
2021-12-06 22:53 ` Stephen Boyd
2021-12-06 23:08   ` wujek dev
2021-12-08  4:30     ` Stephen Boyd
2021-12-09 12:04       ` wujek dev
2021-12-16  6:32         ` Stephen Boyd
2021-12-16 14:25           ` wujek dev
2021-12-17  1:47             ` Stephen Boyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).