diff mbox series

clk: si5341: Add sysfs property to check selected input

Message ID 20211203141515.2448129-1-dev_public@wujek.eu (mailing list archive)
State Changes Requested, archived
Headers show
Series clk: si5341: Add sysfs property to check selected input | expand

Commit Message

wujek dev Dec. 3, 2021, 2:15 p.m. UTC
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(+)

--
2.17.1

Comments

Stephen Boyd Dec. 6, 2021, 10:53 p.m. UTC | #1
Quoting Adam Wujek (2021-12-03 06:15:31)
> 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(+)

sysfs properties need documentation in Documentation/ABI/
wujek dev Dec. 6, 2021, 11:08 p.m. UTC | #2
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 ‐‐‐‐‐‐‐

On Monday, December 6th, 2021 at 23:53, Stephen Boyd <sboyd@kernel.org> wrote:

> Quoting Adam Wujek (2021-12-03 06:15:31)
>
> > 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(+)
>
> sysfs properties need documentation in Documentation/ABI/
Stephen Boyd Dec. 8, 2021, 4:30 a.m. UTC | #3
Quoting wujek dev (2021-12-06 15:08:03)
> 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?
wujek dev Dec. 9, 2021, 12:04 p.m. UTC | #4
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Wednesday, December 8th, 2021 at 05:30, Stephen Boyd <sboyd@kernel.org> wrote:

> Quoting wujek dev (2021-12-06 15:08:03)
>
> > 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).
Stephen Boyd Dec. 16, 2021, 6:32 a.m. UTC | #5
Quoting wujek dev (2021-12-09 04:04:48)
> 
> 
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> 
> On Wednesday, December 8th, 2021 at 05:30, Stephen Boyd <sboyd@kernel.org> wrote:
> 
> > Quoting wujek dev (2021-12-06 15:08:03)
> >
> > > 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?
wujek dev Dec. 16, 2021, 2:25 p.m. UTC | #6
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Thursday, December 16th, 2021 at 07:32, Stephen Boyd <sboyd@kernel.org> wrote:

> Quoting wujek dev (2021-12-09 04:04:48)
>
> > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> >
> > On Wednesday, December 8th, 2021 at 05:30, Stephen Boyd sboyd@kernel.org wrote:
> >
> > > Quoting wujek dev (2021-12-06 15:08:03)
> > >
> > > > 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?
So far, only the project specific program. I'm not aware about a standard tool that check other (already available) properties from this driver.
Stephen Boyd Dec. 17, 2021, 1:47 a.m. UTC | #7
Quoting wujek dev (2021-12-16 06:25:58)
> 
> 
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> 
> On Thursday, December 16th, 2021 at 07:32, Stephen Boyd <sboyd@kernel.org> wrote:
> 
> > Quoting wujek dev (2021-12-09 04:04:48)
> >
> > > ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> > >
> > > On Wednesday, December 8th, 2021 at 05:30, Stephen Boyd sboyd@kernel.org wrote:
> > >
> > > > Quoting wujek dev (2021-12-06 15:08:03)
> > > >
> > > > > 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?
> 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?
diff mbox series

Patch

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
 };