Message ID | 0e04a9e6455faf171e5dd7885676e55b5321b1ea.1625471640.git.vilhelm.gray@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Jonathan Cameron |
Headers | show |
Series | Introduce the Counter character device interface | expand |
On 7/5/21 3:19 AM, William Breathitt Gray wrote: > The Generic Counter chrdev interface expects users to supply component > IDs in order to select extensions for requests. In order for users to > know what component ID belongs to which extension this information must > be exposed. The *_component_id attribute provides a way for users to > discover what component ID belongs to which respective extension. > > Cc: David Lechner <david@lechnology.com> > Cc: Gwendal Grignou <gwendal@chromium.org> > Cc: Dan Carpenter <dan.carpenter@oracle.com> > Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> > --- > Documentation/ABI/testing/sysfs-bus-counter | 16 ++++++++++- > drivers/counter/counter-sysfs.c | 30 ++++++++++++++++----- > 2 files changed, 39 insertions(+), 7 deletions(-) > > diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter > index 9809d8a47431..e0e99adb0ecc 100644 > --- a/Documentation/ABI/testing/sysfs-bus-counter > +++ b/Documentation/ABI/testing/sysfs-bus-counter > @@ -203,12 +203,26 @@ Description: > both edges: > Any state transition. > > +What: /sys/bus/counter/devices/counterX/countY/ceiling_component_id > +What: /sys/bus/counter/devices/counterX/countY/floor_component_id > +What: /sys/bus/counter/devices/counterX/countY/count_mode_component_id > +What: /sys/bus/counter/devices/counterX/countY/direction_component_id > +What: /sys/bus/counter/devices/counterX/countY/enable_component_id > +What: /sys/bus/counter/devices/counterX/countY/error_noise_component_id > +What: /sys/bus/counter/devices/counterX/countY/prescaler_component_id > +What: /sys/bus/counter/devices/counterX/countY/preset_component_id > +What: /sys/bus/counter/devices/counterX/countY/preset_enable_component_id > What: /sys/bus/counter/devices/counterX/countY/signalZ_action_component_id > +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_component_id > +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_enable_component_id > +What: /sys/bus/counter/devices/counterX/signalY/filter_clock_prescaler_component_id > +What: /sys/bus/counter/devices/counterX/signalY/index_polarity_component_id > +What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode_component_id Could we just write a single line? What: /sys/bus/counter/devices/counterX/signalY/<component>_component_id > KernelVersion: 5.15 > Contact: linux-iio@vger.kernel.org > Description: > Read-only attribute that indicates the component ID of the > - respective Synapse of Count Y for Signal Z. > + respective extension or Synapse. > > What: /sys/bus/counter/devices/counterX/countY/spike_filter_ns > KernelVersion: 5.14 > diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c > index bb49a10f160b..eb1505bfbd89 100644 > --- a/drivers/counter/counter-sysfs.c > +++ b/drivers/counter/counter-sysfs.c > @@ -587,6 +587,7 @@ static int counter_signal_attrs_create(struct counter_device *const counter, > int err; > struct counter_comp comp; > size_t i; > + struct counter_comp *ext; > > /* Create main Signal attribute */ > comp = counter_signal_comp; > @@ -602,8 +603,13 @@ static int counter_signal_attrs_create(struct counter_device *const counter, > > /* Create an attribute for each extension */ > for (i = 0; i < signal->num_ext; i++) { > - err = counter_attr_create(dev, group, signal->ext + i, scope, > - signal); > + ext = signal->ext + i; > + > + err = counter_attr_create(dev, group, ext, scope, signal); > + if (err < 0) > + return err; > + > + err = counter_comp_id_attr_create(dev, group, ext->name, i); > if (err < 0) > return err; > } > @@ -694,6 +700,7 @@ static int counter_count_attrs_create(struct counter_device *const counter, > int err; > struct counter_comp comp; > size_t i; > + struct counter_comp *ext; > > /* Create main Count attribute */ > comp = counter_count_comp; > @@ -718,8 +725,13 @@ static int counter_count_attrs_create(struct counter_device *const counter, > > /* Create an attribute for each extension */ > for (i = 0; i < count->num_ext; i++) { > - err = counter_attr_create(dev, group, count->ext + i, scope, > - count); > + ext = count->ext + i; ext = &count->ext[i]; Could make it more clear we are dealing with pointers rather than integers. > + > + err = counter_attr_create(dev, group, ext, scope, count); > + if (err < 0) > + return err; > + > + err = counter_comp_id_attr_create(dev, group, ext->name, i); > if (err < 0) > return err; > } > @@ -783,6 +795,7 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, > struct device *const dev = &counter->dev; > int err; > size_t i; > + struct counter_comp *ext; > > /* Add Signals sysfs attributes */ > err = counter_sysfs_signals_add(counter, group); > @@ -815,8 +828,13 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, > > /* Create an attribute for each extension */ > for (i = 0; i < counter->num_ext; i++) { > - err = counter_attr_create(dev, group, counter->ext + i, scope, > - NULL); > + ext = counter->ext + i; ditto > + > + err = counter_attr_create(dev, group, ext, scope, NULL); > + if (err < 0) > + return err; > + > + err = counter_comp_id_attr_create(dev, group, ext->name, i); > if (err < 0) > return err; > } >
On Sat, 10 Jul 2021 12:06:53 -0500 David Lechner <david@lechnology.com> wrote: > On 7/5/21 3:19 AM, William Breathitt Gray wrote: > > The Generic Counter chrdev interface expects users to supply component > > IDs in order to select extensions for requests. In order for users to > > know what component ID belongs to which extension this information must > > be exposed. The *_component_id attribute provides a way for users to > > discover what component ID belongs to which respective extension. > > > > Cc: David Lechner <david@lechnology.com> > > Cc: Gwendal Grignou <gwendal@chromium.org> > > Cc: Dan Carpenter <dan.carpenter@oracle.com> > > Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> > > --- > > Documentation/ABI/testing/sysfs-bus-counter | 16 ++++++++++- > > drivers/counter/counter-sysfs.c | 30 ++++++++++++++++----- > > 2 files changed, 39 insertions(+), 7 deletions(-) > > > > diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter > > index 9809d8a47431..e0e99adb0ecc 100644 > > --- a/Documentation/ABI/testing/sysfs-bus-counter > > +++ b/Documentation/ABI/testing/sysfs-bus-counter > > @@ -203,12 +203,26 @@ Description: > > both edges: > > Any state transition. > > > > +What: /sys/bus/counter/devices/counterX/countY/ceiling_component_id > > +What: /sys/bus/counter/devices/counterX/countY/floor_component_id > > +What: /sys/bus/counter/devices/counterX/countY/count_mode_component_id > > +What: /sys/bus/counter/devices/counterX/countY/direction_component_id > > +What: /sys/bus/counter/devices/counterX/countY/enable_component_id > > +What: /sys/bus/counter/devices/counterX/countY/error_noise_component_id > > +What: /sys/bus/counter/devices/counterX/countY/prescaler_component_id > > +What: /sys/bus/counter/devices/counterX/countY/preset_component_id > > +What: /sys/bus/counter/devices/counterX/countY/preset_enable_component_id > > What: /sys/bus/counter/devices/counterX/countY/signalZ_action_component_id > > +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_component_id > > +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_enable_component_id > > +What: /sys/bus/counter/devices/counterX/signalY/filter_clock_prescaler_component_id > > +What: /sys/bus/counter/devices/counterX/signalY/index_polarity_component_id > > +What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode_component_id > > Could we just write a single line? > > What: /sys/bus/counter/devices/counterX/signalY/<component>_component_id Not nice for grepping so I think it's better to call them out explicitly. There has been a proposal to check this ABI doc against running kernels, and if we have too many wild cards that becomes very difficult to do. Jonathan > > > KernelVersion: 5.15 > > Contact: linux-iio@vger.kernel.org > > Description: > > Read-only attribute that indicates the component ID of the > > - respective Synapse of Count Y for Signal Z. > > + respective extension or Synapse. > > > > What: /sys/bus/counter/devices/counterX/countY/spike_filter_ns > > KernelVersion: 5.14 > > diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c > > index bb49a10f160b..eb1505bfbd89 100644 > > --- a/drivers/counter/counter-sysfs.c > > +++ b/drivers/counter/counter-sysfs.c > > @@ -587,6 +587,7 @@ static int counter_signal_attrs_create(struct counter_device *const counter, > > int err; > > struct counter_comp comp; > > size_t i; > > + struct counter_comp *ext; > > > > /* Create main Signal attribute */ > > comp = counter_signal_comp; > > @@ -602,8 +603,13 @@ static int counter_signal_attrs_create(struct counter_device *const counter, > > > > /* Create an attribute for each extension */ > > for (i = 0; i < signal->num_ext; i++) { > > - err = counter_attr_create(dev, group, signal->ext + i, scope, > > - signal); > > + ext = signal->ext + i; > > + > > + err = counter_attr_create(dev, group, ext, scope, signal); > > + if (err < 0) > > + return err; > > + > > + err = counter_comp_id_attr_create(dev, group, ext->name, i); > > if (err < 0) > > return err; > > } > > @@ -694,6 +700,7 @@ static int counter_count_attrs_create(struct counter_device *const counter, > > int err; > > struct counter_comp comp; > > size_t i; > > + struct counter_comp *ext; > > > > /* Create main Count attribute */ > > comp = counter_count_comp; > > @@ -718,8 +725,13 @@ static int counter_count_attrs_create(struct counter_device *const counter, > > > > /* Create an attribute for each extension */ > > for (i = 0; i < count->num_ext; i++) { > > - err = counter_attr_create(dev, group, count->ext + i, scope, > > - count); > > + ext = count->ext + i; > > ext = &count->ext[i]; > > Could make it more clear we are dealing with pointers rather than integers. > > > + > > + err = counter_attr_create(dev, group, ext, scope, count); > > + if (err < 0) > > + return err; > > + > > + err = counter_comp_id_attr_create(dev, group, ext->name, i); > > if (err < 0) > > return err; > > } > > @@ -783,6 +795,7 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, > > struct device *const dev = &counter->dev; > > int err; > > size_t i; > > + struct counter_comp *ext; > > > > /* Add Signals sysfs attributes */ > > err = counter_sysfs_signals_add(counter, group); > > @@ -815,8 +828,13 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, > > > > /* Create an attribute for each extension */ > > for (i = 0; i < counter->num_ext; i++) { > > - err = counter_attr_create(dev, group, counter->ext + i, scope, > > - NULL); > > + ext = counter->ext + i; > > ditto > > > + > > + err = counter_attr_create(dev, group, ext, scope, NULL); > > + if (err < 0) > > + return err; > > + > > + err = counter_comp_id_attr_create(dev, group, ext->name, i); > > if (err < 0) > > return err; > > } > > >
On 7/11/21 8:28 AM, Jonathan Cameron wrote: > On Sat, 10 Jul 2021 12:06:53 -0500 > David Lechner <david@lechnology.com> wrote: > >> On 7/5/21 3:19 AM, William Breathitt Gray wrote: >>> The Generic Counter chrdev interface expects users to supply component >>> IDs in order to select extensions for requests. In order for users to >>> know what component ID belongs to which extension this information must >>> be exposed. The *_component_id attribute provides a way for users to >>> discover what component ID belongs to which respective extension. >>> >>> Cc: David Lechner <david@lechnology.com> >>> Cc: Gwendal Grignou <gwendal@chromium.org> >>> Cc: Dan Carpenter <dan.carpenter@oracle.com> >>> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> >>> --- >>> Documentation/ABI/testing/sysfs-bus-counter | 16 ++++++++++- >>> drivers/counter/counter-sysfs.c | 30 ++++++++++++++++----- >>> 2 files changed, 39 insertions(+), 7 deletions(-) >>> >>> diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter >>> index 9809d8a47431..e0e99adb0ecc 100644 >>> --- a/Documentation/ABI/testing/sysfs-bus-counter >>> +++ b/Documentation/ABI/testing/sysfs-bus-counter >>> @@ -203,12 +203,26 @@ Description: >>> both edges: >>> Any state transition. >>> >>> +What: /sys/bus/counter/devices/counterX/countY/ceiling_component_id >>> +What: /sys/bus/counter/devices/counterX/countY/floor_component_id >>> +What: /sys/bus/counter/devices/counterX/countY/count_mode_component_id >>> +What: /sys/bus/counter/devices/counterX/countY/direction_component_id >>> +What: /sys/bus/counter/devices/counterX/countY/enable_component_id >>> +What: /sys/bus/counter/devices/counterX/countY/error_noise_component_id >>> +What: /sys/bus/counter/devices/counterX/countY/prescaler_component_id >>> +What: /sys/bus/counter/devices/counterX/countY/preset_component_id >>> +What: /sys/bus/counter/devices/counterX/countY/preset_enable_component_id >>> What: /sys/bus/counter/devices/counterX/countY/signalZ_action_component_id >>> +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_component_id >>> +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_enable_component_id >>> +What: /sys/bus/counter/devices/counterX/signalY/filter_clock_prescaler_component_id >>> +What: /sys/bus/counter/devices/counterX/signalY/index_polarity_component_id >>> +What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode_component_id >> >> Could we just write a single line? >> >> What: /sys/bus/counter/devices/counterX/signalY/<component>_component_id > > Not nice for grepping so I think it's better to call them out explicitly. > > There has been a proposal to check this ABI doc against running kernels, and if we have > too many wild cards that becomes very difficult to do. > > Jonathan > >> >>> KernelVersion: 5.15 Makes sense. Do we start a new group of similar names with the same description for each kernel release that includes new attributes then? >>> Contact: linux-iio@vger.kernel.org >>> Description: >>> Read-only attribute that indicates the component ID of the >>> - respective Synapse of Count Y for Signal Z. >>> + respective extension or Synapse. >>>
On Sun, 11 Jul 2021 09:08:29 -0500 David Lechner <david@lechnology.com> wrote: > On 7/11/21 8:28 AM, Jonathan Cameron wrote: > > On Sat, 10 Jul 2021 12:06:53 -0500 > > David Lechner <david@lechnology.com> wrote: > > > >> On 7/5/21 3:19 AM, William Breathitt Gray wrote: > >>> The Generic Counter chrdev interface expects users to supply component > >>> IDs in order to select extensions for requests. In order for users to > >>> know what component ID belongs to which extension this information must > >>> be exposed. The *_component_id attribute provides a way for users to > >>> discover what component ID belongs to which respective extension. > >>> > >>> Cc: David Lechner <david@lechnology.com> > >>> Cc: Gwendal Grignou <gwendal@chromium.org> > >>> Cc: Dan Carpenter <dan.carpenter@oracle.com> > >>> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> > >>> --- > >>> Documentation/ABI/testing/sysfs-bus-counter | 16 ++++++++++- > >>> drivers/counter/counter-sysfs.c | 30 ++++++++++++++++----- > >>> 2 files changed, 39 insertions(+), 7 deletions(-) > >>> > >>> diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter > >>> index 9809d8a47431..e0e99adb0ecc 100644 > >>> --- a/Documentation/ABI/testing/sysfs-bus-counter > >>> +++ b/Documentation/ABI/testing/sysfs-bus-counter > >>> @@ -203,12 +203,26 @@ Description: > >>> both edges: > >>> Any state transition. > >>> > >>> +What: /sys/bus/counter/devices/counterX/countY/ceiling_component_id > >>> +What: /sys/bus/counter/devices/counterX/countY/floor_component_id > >>> +What: /sys/bus/counter/devices/counterX/countY/count_mode_component_id > >>> +What: /sys/bus/counter/devices/counterX/countY/direction_component_id > >>> +What: /sys/bus/counter/devices/counterX/countY/enable_component_id > >>> +What: /sys/bus/counter/devices/counterX/countY/error_noise_component_id > >>> +What: /sys/bus/counter/devices/counterX/countY/prescaler_component_id > >>> +What: /sys/bus/counter/devices/counterX/countY/preset_component_id > >>> +What: /sys/bus/counter/devices/counterX/countY/preset_enable_component_id > >>> What: /sys/bus/counter/devices/counterX/countY/signalZ_action_component_id > >>> +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_component_id > >>> +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_enable_component_id > >>> +What: /sys/bus/counter/devices/counterX/signalY/filter_clock_prescaler_component_id > >>> +What: /sys/bus/counter/devices/counterX/signalY/index_polarity_component_id > >>> +What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode_component_id > >> > >> Could we just write a single line? > >> > >> What: /sys/bus/counter/devices/counterX/signalY/<component>_component_id > > > > Not nice for grepping so I think it's better to call them out explicitly. > > > > There has been a proposal to check this ABI doc against running kernels, and if we have > > too many wild cards that becomes very difficult to do. > > > > Jonathan > > > >> > >>> KernelVersion: 5.15 > > Makes sense. Do we start a new group of similar names with the same > description for each kernel release that includes new attributes then? You've spotted one of the short comings of current format. The scripts that produce the html docs don't cope with multiple version numbers. Mostly for IIO we've just been cynical and not had the correct kernel version for new ABI when it's added. It's not ideal though. The alternative, as you mention is to have a new block. Perhaps we can have that refer back to the existing one if the docs cover the new entries as well. @Mauro: Any suggestions for this? Thanks Jonathan > > >>> Contact: linux-iio@vger.kernel.org > >>> Description: > >>> Read-only attribute that indicates the component ID of the > >>> - respective Synapse of Count Y for Signal Z. > >>> + respective extension or Synapse. > >>>
diff --git a/Documentation/ABI/testing/sysfs-bus-counter b/Documentation/ABI/testing/sysfs-bus-counter index 9809d8a47431..e0e99adb0ecc 100644 --- a/Documentation/ABI/testing/sysfs-bus-counter +++ b/Documentation/ABI/testing/sysfs-bus-counter @@ -203,12 +203,26 @@ Description: both edges: Any state transition. +What: /sys/bus/counter/devices/counterX/countY/ceiling_component_id +What: /sys/bus/counter/devices/counterX/countY/floor_component_id +What: /sys/bus/counter/devices/counterX/countY/count_mode_component_id +What: /sys/bus/counter/devices/counterX/countY/direction_component_id +What: /sys/bus/counter/devices/counterX/countY/enable_component_id +What: /sys/bus/counter/devices/counterX/countY/error_noise_component_id +What: /sys/bus/counter/devices/counterX/countY/prescaler_component_id +What: /sys/bus/counter/devices/counterX/countY/preset_component_id +What: /sys/bus/counter/devices/counterX/countY/preset_enable_component_id What: /sys/bus/counter/devices/counterX/countY/signalZ_action_component_id +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_component_id +What: /sys/bus/counter/devices/counterX/signalY/cable_fault_enable_component_id +What: /sys/bus/counter/devices/counterX/signalY/filter_clock_prescaler_component_id +What: /sys/bus/counter/devices/counterX/signalY/index_polarity_component_id +What: /sys/bus/counter/devices/counterX/signalY/synchronous_mode_component_id KernelVersion: 5.15 Contact: linux-iio@vger.kernel.org Description: Read-only attribute that indicates the component ID of the - respective Synapse of Count Y for Signal Z. + respective extension or Synapse. What: /sys/bus/counter/devices/counterX/countY/spike_filter_ns KernelVersion: 5.14 diff --git a/drivers/counter/counter-sysfs.c b/drivers/counter/counter-sysfs.c index bb49a10f160b..eb1505bfbd89 100644 --- a/drivers/counter/counter-sysfs.c +++ b/drivers/counter/counter-sysfs.c @@ -587,6 +587,7 @@ static int counter_signal_attrs_create(struct counter_device *const counter, int err; struct counter_comp comp; size_t i; + struct counter_comp *ext; /* Create main Signal attribute */ comp = counter_signal_comp; @@ -602,8 +603,13 @@ static int counter_signal_attrs_create(struct counter_device *const counter, /* Create an attribute for each extension */ for (i = 0; i < signal->num_ext; i++) { - err = counter_attr_create(dev, group, signal->ext + i, scope, - signal); + ext = signal->ext + i; + + err = counter_attr_create(dev, group, ext, scope, signal); + if (err < 0) + return err; + + err = counter_comp_id_attr_create(dev, group, ext->name, i); if (err < 0) return err; } @@ -694,6 +700,7 @@ static int counter_count_attrs_create(struct counter_device *const counter, int err; struct counter_comp comp; size_t i; + struct counter_comp *ext; /* Create main Count attribute */ comp = counter_count_comp; @@ -718,8 +725,13 @@ static int counter_count_attrs_create(struct counter_device *const counter, /* Create an attribute for each extension */ for (i = 0; i < count->num_ext; i++) { - err = counter_attr_create(dev, group, count->ext + i, scope, - count); + ext = count->ext + i; + + err = counter_attr_create(dev, group, ext, scope, count); + if (err < 0) + return err; + + err = counter_comp_id_attr_create(dev, group, ext->name, i); if (err < 0) return err; } @@ -783,6 +795,7 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, struct device *const dev = &counter->dev; int err; size_t i; + struct counter_comp *ext; /* Add Signals sysfs attributes */ err = counter_sysfs_signals_add(counter, group); @@ -815,8 +828,13 @@ static int counter_sysfs_attr_add(struct counter_device *const counter, /* Create an attribute for each extension */ for (i = 0; i < counter->num_ext; i++) { - err = counter_attr_create(dev, group, counter->ext + i, scope, - NULL); + ext = counter->ext + i; + + err = counter_attr_create(dev, group, ext, scope, NULL); + if (err < 0) + return err; + + err = counter_comp_id_attr_create(dev, group, ext->name, i); if (err < 0) return err; }
The Generic Counter chrdev interface expects users to supply component IDs in order to select extensions for requests. In order for users to know what component ID belongs to which extension this information must be exposed. The *_component_id attribute provides a way for users to discover what component ID belongs to which respective extension. Cc: David Lechner <david@lechnology.com> Cc: Gwendal Grignou <gwendal@chromium.org> Cc: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: William Breathitt Gray <vilhelm.gray@gmail.com> --- Documentation/ABI/testing/sysfs-bus-counter | 16 ++++++++++- drivers/counter/counter-sysfs.c | 30 ++++++++++++++++----- 2 files changed, 39 insertions(+), 7 deletions(-)