lkml.org 
[lkml]   [2020]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v5 0/5] Introduce the Counter character device interface
On Mon, Oct 12, 2020 at 07:35:11PM -0500, David Lechner wrote:
> On 9/26/20 9:18 PM, William Breathitt Gray wrote:
> > The following are some questions I have about this patchset:
> >
> > 1. Should standard Counter component data types be defined as u8 or u32?
> >
> > Many standard Counter component types such COUNTER_COMP_SIGNAL_LEVEL
> > have standard values defined (e.g. COUNTER_SIGNAL_LEVEL_LOW and
> > COUNTER_SIGNAL_LEVEL_HIGH). These values are currently handled by the
> > Counter subsystem code as u8 data types.
> >
> > If u32 is used for these values instead, C enum structures could be
> > used by driver authors to implicit cast these values via the driver
> > callback parameters; userspace would still use u32 with no issue.
> >
> > In theory this can work because GCC will treat enums are having a
> > 32-bit size; but I worry about the possibility of build targets that
> > have -fshort-enums enabled, resulting in enums having a size less
> > than 32 bits. Would this be a problem?
>
> We shouldn't have to worry about userspace programs using -fshort-enums
> since that would break all kernel interfaces that use enums, not just
> these - so no one should be using that compiler flag.
>
> So I am in favor of using strongly typed enums with u32 as the
> "generic" enum member type.

That reasoning pacifies my worries. I'll test out strongly typed enums
in the next revision of this patchset.

> >
> > 2. Should I have reserved members in the userspace structures?
> >
> > The structures in include/uapi/linux/counter.h are available to
> > userspace applications. Should I reserve space in these structures
> > for future additions and usage? Will endianess and packing be a
> > concern here?
> >
> Since there doesn't seem to be a large number of counter devices
> this probably isn't critical. Are there any aspects of counter
> devices in general that couldn't be described with the proposed
> structures? For example, could there be components more than two
> levels deep (i.e. it would need id, parent id and grandparent id
> to describe fully)?

I can't think of any devices that would require more depth, so we
probably don't need any additional members added to the userspace
structures. The current structure should be flexible enough for future
expansion, and any additional functionality we come across can be
handled by implementing new extension types as we have for the sysfs
attributes.

William Breathitt Gray
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2020-10-18 16:15    [W:0.185 / U:8.500 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site