Skip to contentSkip to conversation

clk: si5341: Add sysfs property to check selected input

PATCH In review Adam Wujek 2 participants 8 messages Dec 3, 2021 – Dec 17, 2021 Common clk

lore
Share & tools
lore

Adam Wujek

author
#0 lore raw

PATCH 1/1 clk: si5341: Add sysfs property to check selected input

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

---
 drivers/clk/clk-si5341.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/clk/clk-si5341.c +19 -0
index 57ae183982d8..b7641abe6747 100644
@@ -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

maintainer
#1 lore raw

Quoting Adam Wujek (2021-12-03 06:15:31)

Quoted 10 lines

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

---
 drivers/clk/clk-si5341.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

sysfs properties need documentation in Documentation/ABI/

author
#2 lore raw

Other sysfs properties used by this driver are not documented so I didn't add for this one. Even more not a single property from clk subsystem is described. Shall I the add description of this single property?

BR,
Adam

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Quoted 20 lines · Stephen Boyd

Quoting Adam Wujek (2021-12-03 06:15:31)

Quoted 8 lines

Add a sysfs property to check the selected input.

<input_num> <input_name> <input_name_from_DTB>

E.g.:

cat input_selected

Quoted 8 lines

0 in0 WR25M

---------------------------------------------

drivers/clk/clk-si5341.c | 19 +++++++++++++++++++

1 file changed, 19 insertions(+)

sysfs properties need documentation in Documentation/ABI/

maintainer
#3 lore raw

Quoting wujek dev (2021-12-06 15:08:03)

Quoted 2 lines

Other sysfs properties used by this driver are not documented so I didn't add for this one. Even more not a single property from clk subsystem is described. Shall I the add description of this single property?

Please don't top post. sysfs properties are supposed to be single value and for machine consumption. Is this a debugfs property?

author
#4 lore raw

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Quoted 7 lines · Stephen Boyd

Quoting wujek dev (2021-12-06 15:08:03)

Quoted 1 line

Other sysfs properties used by this driver are not documented so I didn't add for this one. Even more not a single property from clk subsystem is described. Shall I the add description of this single property?

Please don't top post. sysfs properties are supposed to be single value

and for machine consumption. Is this a debugfs property?

No, I think this is rather sysfs than debugfs. The type of information is similar to other reported by this driver. The values in the added property are the same, this is just a different representation (input selected as an int, as string based on manual and as string as described in the DTB).

maintainer
#5 lore raw

Quoting wujek dev (2021-12-09 04:04:48)

Quoted 6 lines

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Wednesday, December 8th, 2021 at 05:30, Stephen Boyd <[email protected]> wrote:

Quoted 8 lines
Quoted 7 lines

Quoting wujek dev (2021-12-06 15:08:03)

Quoted 1 line

Other sysfs properties used by this driver are not documented so I didn't add for this one. Even more not a single property from clk subsystem is described. Shall I the add description of this single property?

Please don't top post. sysfs properties are supposed to be single value

and for machine consumption. Is this a debugfs property?

No, I think this is rather sysfs than debugfs. The type of information is similar to other reported by this driver. The values in the added property are the same, this is just a different representation (input selected as an int, as string based on manual and as string as described in the DTB).

Ok what program is going to check the selected input?

author
#6 lore raw

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Quoted 10 lines · Stephen Boyd

Quoting wujek dev (2021-12-09 04:04:48)

Quoted 8 lines

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Quoted 4 lines · On Wednesday, December 8th, 2021 at 05:30, Stephen Boyd [email protected] wrote:

Quoting wujek dev (2021-12-06 15:08:03)

Quoted 1 line

Other sysfs properties used by this driver are not documented so I didn't add for this one. Even more not a single property from clk subsystem is described. Shall I the add description of this single property?

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

Please don't top post. sysfs properties are supposed to be single value

and for machine consumption. Is this a debugfs property?

No, I think this is rather sysfs than debugfs. The type of information is similar to other reported by this driver. The values in the added property are the same, this is just a different representation (input selected as an int, as string based on manual and as string as described in the DTB).

Ok what program is going to check the selected input?

So far, only the project specific program. I'm not aware about a standard tool that check other (already available) properties from this driver.

maintainer
#7 lore raw

Quoting wujek dev (2021-12-16 06:25:58)

Quoted 16 lines

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Quoted 10 lines · Stephen Boyd

Quoting wujek dev (2021-12-09 04:04:48)

Quoted 8 lines

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

Quoted 4 lines · On Wednesday, December 8th, 2021 at 05:30, Stephen Boyd [email protected] wrote:

Quoting wujek dev (2021-12-06 15:08:03)

Quoted 1 line

Other sysfs properties used by this driver are not documented so I didn't add for this one. Even more not a single property from clk subsystem is described. Shall I the add description of this single property?

Quoted 8 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines

Please don't top post. sysfs properties are supposed to be single value

and for machine consumption. Is this a debugfs property?

No, I think this is rather sysfs than debugfs. The type of information is similar to other reported by this driver. The values in the added property are the same, this is just a different representation (input selected as an int, as string based on manual and as string as described in the DTB).

Ok what program is going to check the selected input?

So far, only the project specific program. I'm not aware about a standard tool that check other (already available) properties from this driver.

Why doesn't clk debugfs that indicates the parents of a clk work here?