On Tue, Jun 14, 2022 at 12:13:02PM +0100, Jonathan Cameron wrote: > On Wed, 1 Jun 2022 16:36:29 -0400 > William Breathitt Gray <william.gray@xxxxxxxxxx> wrote: > > > Reduce magic numbers and improve code readability by implementing and > > utilizing named register data structures. > > > > Cc: Syed Nayyar Waris <syednwaris@xxxxxxxxx> > > Signed-off-by: William Breathitt Gray <william.gray@xxxxxxxxxx> > > In this particular case this does clean up the + 1's scattered through > the code to access the control registers so I'm more or less convinced > readability is improved. The access via an offset from a base is > a very common pattern though in kernel drivers, so reviewers tend > to be used to it, hence I'm not sure I'd want to see lots of drivers > go this way. Fine here though. > > Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx> > > > --- > > drivers/counter/104-quad-8.c | 166 ++++++++++++++++++++--------------- > > 1 file changed, 93 insertions(+), 73 deletions(-) > > > > diff --git a/drivers/counter/104-quad-8.c b/drivers/counter/104-quad-8.c > > index 43dde9abfdcf..a1ec04313926 100644 > > --- a/drivers/counter/104-quad-8.c > > +++ b/drivers/counter/104-quad-8.c > > @@ -33,6 +33,36 @@ MODULE_PARM_DESC(irq, "ACCES 104-QUAD-8 interrupt line numbers"); > > > > #define QUAD8_NUM_COUNTERS 8 > > > > +/** > > + * struct channel_reg - channel register structure > > + * @data: Count data > > + * @control: Channel flags and control > > + */ > > +struct channel_reg { > > + u8 data; > > + u8 control; > > +}; > > + > > +/** > > + * struct quad8_reg - device register structure > > + * @channel: quadrature counter data and control > > + * @interrupt_status: channel interrupt status > > + * @channel_oper: enable/reset counters and interrupt functions > > + * @index_interrupt: enable channel interrupts > > + * @reserved: reserved for Factory Use > > + * @index_input_levels: index signal logical input level > > + * @cable_status: differential encoder cable status > > + */ > > +struct quad8_reg { > > + struct channel_reg channel[QUAD_NUM_COUNTERS]; Oops, this should be QUAD8_NUM_COUNTERS here. I'll submit a v2 with this typo fixed when I get a chance and then give this patch some more time for others to test; assuming no other changes, I'll add your Reviewed-by tag as well. Thanks, William Breathitt Gray
Attachment:
signature.asc
Description: PGP signature